UNPKG

@bhplugin/vue3-datatable

Version:

Vue3 Datatable - fully customizable & easy to use datatable library

40 lines (39 loc) 1.52 kB
/** * Filter strategy pattern — maps column types × filter conditions to predicate functions. * Replaces the 130+ line if-else chain with a declarative lookup table. */ import type { IColumnType, IFilterCondition } from './types'; export interface INormalizedColumn { field: string; type: IColumnType; condition: IFilterCondition; value: string | number | boolean | undefined; filter: boolean; search: boolean; sort: boolean; hide: boolean; title?: string; width?: string; minWidth?: string; maxWidth?: string; headerClass?: string; cellClass?: string; isUnique?: boolean; html?: boolean; cellRenderer?: ((row: Record<string, unknown>) => string) | string; } /** * Apply column filters to a row set. * Returns a new array — does not mutate the input. */ export declare const applyColumnFilters: (rows: Array<Record<string, unknown>>, columns: INormalizedColumn[]) => Array<Record<string, unknown>>; /** * Apply global search across searchable columns. * Returns a new array — does not mutate the input. */ export declare const applyGlobalSearch: (rows: Array<Record<string, unknown>>, columns: INormalizedColumn[], search: string) => Array<Record<string, unknown>>; /** * Apply sorting to a row set. * Returns a new sorted array — does not mutate the input. */ export declare const applySorting: (rows: Array<Record<string, unknown>>, sortColumn: string, sortDirection: string, isNumeric: boolean) => Array<Record<string, unknown>>;