/** * grid-select - pure helper behind : filter option rows by a * free-text query across a set of fields (case-insensitive substring match). * Framework-free + pure so it is unit-tested directly. */ export type Row = Record /** Rows where ANY of `fields` contains `query` (case-insensitive). Blank query * returns every row. */ export function filterGridRows( rows: ReadonlyArray, fields: ReadonlyArray, query: string, ): T[] { const q = query.trim().toLowerCase() if (!q) return [...rows] return rows.filter((row) => fields.some((f) => String(row[f] ?? '').toLowerCase().includes(q)), ) }