1
1
import React , { useEffect , useState } from 'react' ;
2
- import { Card , CardContent , IconButton , Alert , Stack , Button , Typography , Grid2 , Select , MenuItem , FormControl , InputLabel , Switch , FormGroup , FormControlLabel , Dialog , DialogTitle , DialogContent , Checkbox , Badge , BadgeProps , Link } from '@mui/material' ;
2
+ import { Card , CardContent , IconButton , Alert , Stack , Button , Typography , Grid2 , Select , MenuItem , FormControl , InputLabel , Switch , FormGroup , FormControlLabel , Dialog , DialogTitle , DialogContent , Checkbox , Badge , BadgeProps , Link , TextField } from '@mui/material' ;
3
3
import { CatalogItemWithName , CatalogItemCard , CatalogItem } from './PromptCard' ;
4
4
import AddIcon from '@mui/icons-material/Add' ;
5
5
import { Ref } from '../Refs' ;
@@ -19,8 +19,8 @@ interface CatalogGridProps {
19
19
settingsBadgeProps : BadgeProps ;
20
20
}
21
21
22
- const filterCatalog = ( catalogItems : CatalogItemWithName [ ] , registryItems : { [ key : string ] : { ref : string } } , showRegistered : boolean , showUnregistered : boolean ) =>
23
- catalogItems . filter ( ( item ) => ( showRegistered || ! Object . keys ( registryItems ) . includes ( item . name ) ) && ( showUnregistered || Object . keys ( registryItems ) . includes ( item . name ) ) ) ;
22
+ const filterCatalog = ( catalogItems : CatalogItemWithName [ ] , registryItems : { [ key : string ] : { ref : string } } , showRegistered : boolean , showUnregistered : boolean , search : string ) =>
23
+ catalogItems . filter ( ( item ) => ( showRegistered || ! Object . keys ( registryItems ) . includes ( item . name ) ) && ( showUnregistered || Object . keys ( registryItems ) . includes ( item . name ) ) && ( item . name . toLowerCase ( ) . includes ( search . toLowerCase ( ) ) ) ) ;
24
24
25
25
const NEVER_SHOW_AGAIN_KEY = 'registry-sync-never-show-again' ;
26
26
@@ -36,8 +36,9 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
36
36
const [ showRegistered , setShowRegistered ] = useState < boolean > ( true ) ;
37
37
const [ showUnregistered , setShowUnregistered ] = useState < boolean > ( true ) ;
38
38
const [ showReloadModal , setShowReloadModal ] = useState < boolean > ( false ) ;
39
+ const [ search , setSearch ] = useState < string > ( '' ) ;
39
40
40
- const filteredCatalogItems = filterCatalog ( catalogItems , registryItems , showRegistered , showUnregistered ) ;
41
+ const filteredCatalogItems = filterCatalog ( catalogItems , registryItems , showRegistered , showUnregistered , search ) ;
41
42
42
43
const loadCatalog = async ( showNotification = true ) => {
43
44
const cachedCatalog = localStorage . getItem ( 'catalog' ) ;
@@ -142,6 +143,7 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
142
143
</ Alert > }
143
144
< FormGroup sx = { { width : '100%' } } >
144
145
< Stack direction = "row" spacing = { 1 } alignItems = 'center' >
146
+ < TextField label = "Search" value = { search } onChange = { ( e ) => setSearch ( e . target . value ) } sx = { { width : 150 } } />
145
147
< FormControlLabel control = { < Switch checked = { showRegistered } onChange = { ( e ) => setShowRegistered ( e . target . checked ) } /> } label = "Show Allowed Prompts" />
146
148
< FormControlLabel control = { < Switch checked = { showUnregistered } onChange = { ( e ) => setShowUnregistered ( e . target . checked ) } /> } label = "Show Blocked Prompts" />
147
149
< Link sx = { { fontWeight : 'bold' } } href = "https://vonwig.github.io/prompts.docs/tools/docs/" target = "_blank" rel = "noopener noreferrer" onClick = { ( ) => {
0 commit comments