refactor(app): sheet list hooks split, rows memoised, phone clear button
- useSearch holds the query, its field and clearSearch; useListView keeps the filters and the sort (8 bindings down to 5) - the search term is folded once per search (sheetNameMatcher beside matchesSheetName, whose signature and behaviour stay), each date read once before the sort, the shown rows memoised on list, filters, search, sort and language - long className strings hoisted into module constants, no class changed - the no-result block's clear button takes the page's 44 px phone height - labels.ts: the SheetSummary alias removed; ResultsProps declared first No test changed: the existing unit suites are the oracle.
This commit is contained in:
1 parent
374e300895
commit
1758276087
4 files changed
+99
-53
No files matched your search
@@ -54,10 +54,23 @@ export function folded(text: string): string {
|
||||
return text.normalize('NFD').replace(/\p{Diacritic}/gu, '').toLowerCase()
|
||||
}
|
||||
|
||||
/** A sheet name contains the search, in French or in English, accents and case ignored. */
|
||||
export function matchesSheetName(name: { fr: string; en: string }, query: string): boolean {
|
||||
/** The search folded once, then tested on each name: what a long list needs per keystroke. */
|
||||
export function sheetNameMatcher(
|
||||
query: string,
|
||||
): (name: { fr: string; en: string }) => boolean {
|
||||
const term = folded(query.trim())
|
||||
return term === '' || folded(name.fr).includes(term) || folded(name.en).includes(term)
|
||||
return (name) =>
|
||||
term === '' ||
|
||||
folded(name.fr).includes(term) ||
|
||||
folded(name.en).includes(term)
|
||||
}
|
||||
|
||||
/** A sheet name contains the search, in French or in English, accents and case ignored. */
|
||||
export function matchesSheetName(
|
||||
name: { fr: string; en: string },
|
||||
query: string,
|
||||
): boolean {
|
||||
return sheetNameMatcher(query)(name)
|
||||
}
|
||||
|
||||
/** Search by sheet name only, French or English (BDR-095), then the species chip. */
|
||||
|
||||
Reference in new issue
Block a user