@@ -13,12 +13,27 @@ import { TagIcon } from "../../assets/icons/TagIcon";
13
13
import { useLiveQuery } from "dexie-react-hooks" ;
14
14
import { tagService } from "../../scripts/db/TagService" ;
15
15
import { TagConfig } from "./TagConfig/TagConfig" ;
16
+ import { Input } from "../../common/components/shadcn/input" ;
17
+ import { useState } from "react" ;
18
+ import { matchSorter } from "match-sorter" ;
16
19
17
20
export const TagEditor = ( ) => {
18
21
const tags = useLiveQuery ( ( ) => {
19
22
return tagService . listTags ( ) ;
20
23
} ) ;
21
24
25
+ const [ filter , setFilter ] = useState ( "" ) ;
26
+
27
+ const filteredTags = matchSorter ( tags ?? [ ] , filter , {
28
+ keys : [
29
+ "name" ,
30
+ {
31
+ key : "description" ,
32
+ maxRanking : matchSorter . rankings . STARTS_WITH ,
33
+ } ,
34
+ ] ,
35
+ } ) ;
36
+
22
37
return (
23
38
< >
24
39
< Drawer >
@@ -45,12 +60,25 @@ export const TagEditor = () => {
45
60
</ DrawerClose >
46
61
</ DrawerHeader >
47
62
</ div >
63
+ < div className = "grid grid-cols-[1fr_minmax(400px,_900px)_1fr] gap-4 p-4" >
64
+ < div />
65
+ < div className = "grid grid-cols-[300px_1fr]" >
66
+ < label className = "flex justify-center items-center gap-2" >
67
+ Filter:
68
+ < Input
69
+ value = { filter }
70
+ onChange = { ( e ) => setFilter ( e . target . value ) }
71
+ />
72
+ </ label >
73
+ </ div >
74
+ < div />
75
+ </ div >
48
76
< div className = "grid grid-cols-[1fr_minmax(400px,_900px)_1fr] gap-4 pb-10 overflow-y-auto max-h-96" >
49
77
{ ! tags || tags . length <= 0 ? (
50
78
< div > No tags yet.</ div >
51
79
) : (
52
80
< div className = "col-start-2 grid grid-cols-[200px_1fr_180px_100px_100px]" >
53
- { tags . map ( ( tag ) => (
81
+ { filteredTags . map ( ( tag ) => (
54
82
< TagConfig
55
83
key = { tag . name }
56
84
tag = { tag }
0 commit comments