99  displayValue , 
1010  updateNestedDataByPath , 
1111}  from  './utils' 
12- import  {  CopiedCopier ,  Copier ,  ErrorCopier ,  List ,  Trash  }  from  './icons' 
12+ import  {  Check ,   CopiedCopier ,  Copier ,  ErrorCopier ,  List ,  Trash  }  from  './icons' 
1313import  {  useQueryDevtoolsContext  }  from  './Context' 
1414import  type  {  Query  }  from  '@tanstack/query-core' 
1515
@@ -171,6 +171,34 @@ const DeleteItemButton = (props: {
171171  ) 
172172} 
173173
174+ const  ToggleValueButton  =  ( props : { 
175+   dataPath : Array < string > 
176+   activeQuery : Query 
177+   value : boolean 
178+ } )  =>  { 
179+   const  styles  =  getStyles ( ) 
180+   const  queryClient  =  useQueryDevtoolsContext ( ) . client 
181+ 
182+   return  ( 
183+     < button 
184+       class = { cx ( styles . actionButton ) } 
185+       title = { 'Toggle value' } 
186+       aria-label = { 'Toggle value' } 
187+       onClick = { ( )  =>  { 
188+         const  oldData  =  props . activeQuery . state . data 
189+         const  newData  =  updateNestedDataByPath ( 
190+           oldData , 
191+           props . dataPath , 
192+           ! props . value , 
193+         ) 
194+         queryClient . setQueryData ( props . activeQuery . queryKey ,  newData ) 
195+       } } 
196+     > 
197+       < Check  checked = { props . value }  /> 
198+     </ button > 
199+   ) 
200+ } 
201+ 
174202type  ExplorerProps  =  { 
175203  editable ?: boolean 
176204  label : string 
@@ -359,30 +387,53 @@ export default function Explorer(props: ExplorerProps) {
359387            when = { 
360388              props . editable  && 
361389              props . activeQuery  !==  undefined  && 
362-               ( type ( )  ===  'string'  ||  type ( )  ===  'number' ) 
390+               ( type ( )  ===  'string'  || 
391+                 type ( )  ===  'number'  || 
392+                 type ( )  ===  'boolean' ) 
363393            } 
364394            fallback = { 
365395              < span  class = { styles . value } > { displayValue ( props . value ) } </ span > 
366396            } 
367397          > 
368-             < input 
369-               type = { type ( )  ===  'number'  ? 'number'  : 'text' } 
370-               class = { cx ( styles . value ,  styles . editableInput ) } 
371-               value = { props . value  as  string  |  number } 
372-               onChange = { ( changeEvent )  =>  { 
373-                 const  oldData  =  props . activeQuery ! . state . data 
374- 
375-                 const  newData  =  updateNestedDataByPath ( 
376-                   oldData , 
377-                   currentDataPath , 
378-                   type ( )  ===  'number' 
379-                     ? changeEvent . target . valueAsNumber 
380-                     : changeEvent . target . value , 
381-                 ) 
382- 
383-                 queryClient . setQueryData ( props . activeQuery ! . queryKey ,  newData ) 
384-               } } 
385-             /> 
398+             < Show 
399+               when = { 
400+                 props . editable  && 
401+                 props . activeQuery  !==  undefined  && 
402+                 ( type ( )  ===  'string'  ||  type ( )  ===  'number' ) 
403+               } 
404+             > 
405+               < input 
406+                 type = { type ( )  ===  'number'  ? 'number'  : 'text' } 
407+                 class = { cx ( styles . value ,  styles . editableInput ) } 
408+                 value = { props . value  as  string  |  number } 
409+                 onChange = { ( changeEvent )  =>  { 
410+                   const  oldData  =  props . activeQuery ! . state . data 
411+ 
412+                   const  newData  =  updateNestedDataByPath ( 
413+                     oldData , 
414+                     currentDataPath , 
415+                     type ( )  ===  'number' 
416+                       ? changeEvent . target . valueAsNumber 
417+                       : changeEvent . target . value , 
418+                   ) 
419+ 
420+                   queryClient . setQueryData ( props . activeQuery ! . queryKey ,  newData ) 
421+                 } } 
422+               /> 
423+             </ Show > 
424+ 
425+             < Show  when = { type ( )  ===  'boolean' } > 
426+               < span 
427+                 class = { cx ( styles . value ,  styles . actions ,  styles . editableInput ) } 
428+               > 
429+                 < ToggleValueButton 
430+                   activeQuery = { props . activeQuery ! } 
431+                   dataPath = { currentDataPath } 
432+                   value = { props . value  as  boolean } 
433+                 /> 
434+                 { displayValue ( props . value ) } 
435+               </ span > 
436+             </ Show > 
386437          </ Show > 
387438
388439          < Show 
@@ -483,17 +534,19 @@ const getStyles = () => {
483534    actions : css ` 
484535      display :  inline-flex; 
485536      gap : ${ size [ 2 ] }  
537+       align-items :  center; 
486538    ` , 
487539    row : css ` 
488540      display :  inline-flex; 
489541      gap : ${ size [ 2 ] }  
490542      width :  100%  ; 
491543      margin-bottom : ${ size [ 0.5 ] }  
492544      line-height :  1.125rem  ; 
545+       align-items :  center; 
493546    ` , 
494547    editableInput : css ` 
495548      border :  none; 
496-       padding :  0 px ${ size [ 1 ] }  
549+       padding : ${ size [ 0.5 ] } ${ size [ 1 ] }  
497550      flex-grow :  1 ; 
498551      background-color : ${ colors . gray [ 900 ] }  
499552
@@ -516,6 +569,7 @@ const getStyles = () => {
516569
517570      & : hover  svg  { 
518571        .copier ,  
572+         .check ,  
519573        .list  { 
520574          stroke :  ${ colors . gray [ 500 ] } !important ; 
521575        } 
0 commit comments