@humanspeak/svelte-headless-table
Version:
A powerful, headless table library for Svelte that provides complete control over table UI while handling complex data operations like sorting, filtering, pagination, grouping, and row expansion. Build custom, accessible data tables with zero styling opin
29 lines (28 loc) • 1.07 kB
TypeScript
import { type Readable, type Writable } from 'svelte/store';
import type { BodyRow } from '../bodyRows.js';
import type { NewTablePropSet, TablePlugin } from '../types/TablePlugin.js';
export interface TableFilterConfig {
fn?: TableFilterFn;
initialFilterValue?: string;
includeHiddenColumns?: boolean;
serverSide?: boolean;
}
export interface TableFilterState<Item> {
filterValue: Writable<string>;
preFilteredRows: Readable<BodyRow<Item>[]>;
}
export interface TableFilterColumnOptions<Item> {
exclude?: boolean;
getFilterValue?: (value: any) => string;
}
export type TableFilterFn = (props: TableFilterFnProps) => boolean;
export type TableFilterFnProps = {
filterValue: string;
value: string;
};
export type TableFilterPropSet = NewTablePropSet<{
'tbody.tr.td': {
matches: boolean;
};
}>;
export declare const addTableFilter: <Item>({ fn, initialFilterValue, includeHiddenColumns, serverSide }?: TableFilterConfig) => TablePlugin<Item, TableFilterState<Item>, TableFilterColumnOptions<Item>, TableFilterPropSet>;