aboutsummaryrefslogtreecommitdiff
path: root/src/lib/components/fuzzy-search.ts
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-09-07 22:31:23 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-09-07 22:31:23 +0200
commit992e40835af1600a0961ec2454fb78ff43aec3c6 (patch)
tree3c0602ae64a186ce5ac51be6b0795037488f552a /src/lib/components/fuzzy-search.ts
parente4a158965f3fcfe6fac65a1eba7b456d615e7dca (diff)
Add routine archives: archive date, searchable archived list, frozen page
- Stamp archived_at on the archived snapshot; copy it on edit - loadArchived(projectId) + collapsible fuzzy-searched "Archivées" section on the project page - Archived routine pages open read-only with the health chart ending at the archive date; edit/complete actions reject archived routines
Diffstat (limited to 'src/lib/components/fuzzy-search.ts')
-rw-r--r--src/lib/components/fuzzy-search.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/components/fuzzy-search.ts b/src/lib/components/fuzzy-search.ts
index 31597b0..ade48fe 100644
--- a/src/lib/components/fuzzy-search.ts
+++ b/src/lib/components/fuzzy-search.ts
@@ -5,19 +5,19 @@ export type FuzzyItem = { id: number; name: string };
export const FUZZ_LIMIT = 8;
export const FUZZ_THRESHOLD = 0.2;
-export type FuzzyMatch = KeyResult<FuzzyItem>;
+export type FuzzyMatch<T extends FuzzyItem = FuzzyItem> = KeyResult<T>;
/** Fuzzy-match `items` against `query`, ranked best-first. Empty/whitespace
* query returns no matches. Results carry `.score`, `.target`, `.highlight()`
* and `.obj` (the matched item). */
-export function matchItems(
- items: FuzzyItem[],
+export function matchItems<T extends FuzzyItem>(
+ items: T[],
query: string,
{
limit = FUZZ_LIMIT,
threshold = FUZZ_THRESHOLD,
}: { limit?: number; threshold?: number } = {},
-): FuzzyMatch[] {
+): FuzzyMatch<T>[] {
const q = query.trim();
if (q === '') return [];
const snap = fuzzysort.snapshot(items, { key: 'name' });