refactor(table): move Column interface to separate types file for better organization

This commit is contained in:
Sam Chau
2025-11-05 07:35:48 +10:30
parent e7fac48962
commit f274c9900f
4 changed files with 25 additions and 23 deletions

View File

@@ -1,25 +1,5 @@
<script lang="ts" generics="T extends Record<string, any>">
import type { ComponentType } from 'svelte';
/**
* Column definition for table
*/
export interface Column<T> {
/** Unique key for the column */
key: string;
/** Header text to display */
header: string;
/** Optional icon component to display before header text */
headerIcon?: ComponentType;
/** Optional width class (e.g., 'w-32', 'w-1/4') */
width?: string;
/** Text alignment */
align?: 'left' | 'center' | 'right';
/** Whether column is sortable */
sortable?: boolean;
/** Custom cell renderer - receives the full row object */
cell?: (row: T) => string | ComponentType | { html: string };
}
import type { Column } from './types';
/**
* Props

View File

@@ -0,0 +1,21 @@
import type { ComponentType } from 'svelte';
/**
* Column definition for table
*/
export interface Column<T> {
/** Unique key for the column */
key: string;
/** Header text to display */
header: string;
/** Optional icon component to display before header text */
headerIcon?: ComponentType;
/** Optional width class (e.g., 'w-32', 'w-1/4') */
width?: string;
/** Text alignment */
align?: 'left' | 'center' | 'right';
/** Whether column is sortable */
sortable?: boolean;
/** Custom cell renderer - receives the full row object */
cell?: (row: T) => string | ComponentType | { html: string };
}

View File

@@ -7,7 +7,7 @@
import Modal from '$ui/modal/Modal.svelte';
import { alertStore } from '$alerts/store';
import type { PageData } from './$types';
import type { Column } from '$ui/table/Table.svelte';
import type { Column } from '$ui/table/types';
import type { DatabaseInstance } from '$db/queries/databaseInstances.ts';
export let data: PageData;

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import Table, { type Column } from '$ui/table/Table.svelte';
import Table from '$ui/table/Table.svelte';
import type { Column } from '$ui/table/types';
import type { QualityProfileTableRow } from '$lib/server/pcd/queries/qualityProfiles';
import { Tag, FileText, Layers, BookOpenText, Gauge, Earth } from 'lucide-svelte';
import { goto } from '$app/navigation';