File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
tslib/react/src/components Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 11import {
22 Checkbox ,
3+ Divider ,
34 FormControlLabel ,
45 FormGroup ,
56 Grid ,
@@ -243,6 +244,16 @@ const useTargets = (
243244 const searchSpace = useMergedUnionSearchSpace ( study ?. union_search_space )
244245 const [ targets2 ] = useParamTargets ( searchSpace )
245246 const [ checked , setChecked ] = useState < boolean [ ] > ( [ true ] )
247+ const [ checkedAll , setCheckedAll ] = useState < boolean > ( true )
248+
249+ const toggleCheckedAll = ( ) => {
250+ if ( checkedAll ) {
251+ setChecked ( checked . map ( ( ) => false ) )
252+ } else {
253+ setChecked ( checked . map ( ( ) => true ) )
254+ }
255+ setCheckedAll ( ( prevCheckedAll ) => ! prevCheckedAll )
256+ }
246257
247258 const allTargets = [ ...targets1 , ...targets2 ]
248259 useEffect ( ( ) => {
@@ -276,6 +287,17 @@ const useTargets = (
276287
277288 const renderCheckBoxes = ( ) : ReactNode => (
278289 < FormGroup >
290+ < FormControlLabel
291+ control = {
292+ < Checkbox
293+ checked = { checkedAll }
294+ onChange = { toggleCheckedAll }
295+ name = "checkedAll"
296+ />
297+ }
298+ label = "Check All"
299+ />
300+ < Divider />
279301 { allTargets . map ( ( t , i ) => {
280302 const key = t . toLabel ( study ?. metric_names )
281303 return (
You can’t perform that action at this time.
0 commit comments