11import 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' ;
33import { CatalogItemWithName , CatalogItemCard , CatalogItem } from './PromptCard' ;
44import AddIcon from '@mui/icons-material/Add' ;
55import { Ref } from '../Refs' ;
@@ -19,8 +19,8 @@ interface CatalogGridProps {
1919 settingsBadgeProps : BadgeProps ;
2020}
2121
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 ( ) ) ) ) ;
2424
2525const NEVER_SHOW_AGAIN_KEY = 'registry-sync-never-show-again' ;
2626
@@ -36,8 +36,9 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
3636 const [ showRegistered , setShowRegistered ] = useState < boolean > ( true ) ;
3737 const [ showUnregistered , setShowUnregistered ] = useState < boolean > ( true ) ;
3838 const [ showReloadModal , setShowReloadModal ] = useState < boolean > ( false ) ;
39+ const [ search , setSearch ] = useState < string > ( '' ) ;
3940
40- const filteredCatalogItems = filterCatalog ( catalogItems , registryItems , showRegistered , showUnregistered ) ;
41+ const filteredCatalogItems = filterCatalog ( catalogItems , registryItems , showRegistered , showUnregistered , search ) ;
4142
4243 const loadCatalog = async ( showNotification = true ) => {
4344 const cachedCatalog = localStorage . getItem ( 'catalog' ) ;
@@ -142,6 +143,7 @@ export const CatalogGrid: React.FC<CatalogGridProps> = ({
142143 </ Alert > }
143144 < FormGroup sx = { { width : '100%' } } >
144145 < Stack direction = "row" spacing = { 1 } alignItems = 'center' >
146+ < TextField label = "Search" value = { search } onChange = { ( e ) => setSearch ( e . target . value ) } sx = { { width : 150 } } />
145147 < FormControlLabel control = { < Switch checked = { showRegistered } onChange = { ( e ) => setShowRegistered ( e . target . checked ) } /> } label = "Show Allowed Prompts" />
146148 < FormControlLabel control = { < Switch checked = { showUnregistered } onChange = { ( e ) => setShowUnregistered ( e . target . checked ) } /> } label = "Show Blocked Prompts" />
147149 < Link sx = { { fontWeight : 'bold' } } href = "https://vonwig.github.io/prompts.docs/tools/docs/" target = "_blank" rel = "noopener noreferrer" onClick = { ( ) => {
0 commit comments