@@ -139,9 +139,11 @@ interface ICorpusTable {
139139 annotationSpans : AnnotationSpans
140140 searchType : string
141141 onSelectedSpanChanged ( arg0 : string , arg1 : number ) : void
142+ cosp : string [ ]
143+ setCosp : React . Dispatch < React . SetStateAction < string [ ] > >
142144}
143145
144- export default function CorpusTable ( { annotationSpans, searchType, onSelectedSpanChanged } : ICorpusTable ) {
146+ export default function CorpusTable ( { annotationSpans, searchType, onSelectedSpanChanged, cosp , setCosp } : ICorpusTable ) {
145147 const [ page , setPage ] = React . useState ( 0 ) ;
146148 const [ rowsPerPage , setRowsPerPage ] = React . useState ( 10 ) ;
147149 let groupedAnnotationSpans = Array . from ( annotationSpans . reduce (
@@ -211,13 +213,20 @@ export default function CorpusTable({ annotationSpans, searchType, onSelectedSpa
211213 { row . cosp && row . cosp . length > 0 &&
212214 < Box sx = { { mt : 0.5 , display : 'flex' , flexWrap : 'wrap' , gap : 0.5 } } >
213215 { ( row . cosp as string [ ] ) . slice ( 0 , 8 ) . map ( ( g ) => (
214- < Chip
215- key = { g }
216- label = { g }
217- size = "small"
218- variant = "outlined"
219- color = { g . startsWith ( 'SP1' ) ? 'primary' : 'secondary' }
220- />
216+ < Chip
217+ key = { g }
218+ label = { g }
219+ size = "small"
220+ variant = { cosp . includes ( g . replace ( / ^ S P [ 1 2 ] _ / , '' ) ) ? 'filled' : 'outlined' }
221+ color = { g . startsWith ( 'SP1' ) ? 'primary' : 'secondary' }
222+ onClick = { ( ) => {
223+ const label = g . replace ( / ^ S P [ 1 2 ] _ / , '' ) ;
224+ if ( ! cosp . includes ( label ) ) {
225+ setCosp ( [ ...cosp , label ] ) ;
226+ }
227+ } }
228+ sx = { { cursor : 'pointer' } }
229+ />
221230 ) ) }
222231 { row . cosp . length > 8 &&
223232 < Chip
0 commit comments