@@ -5,20 +5,18 @@ import { useShowToolsDispatch } from '../store/ShowTools';
55import { Value } from './Value' ;
66import { KeyNameComp } from '../section/KeyName' ;
77import { RowComp } from '../section/Row' ;
8- import { Container } from '../Container' ;
8+ import { Container , type ContainerProps } from '../Container' ;
99import { Quote , Colon } from '../symbol' ;
1010import { useHighlight } from '../utils/useHighlight' ;
11+ import { type SectionElementResult } from '../store/Section' ;
1112
12- interface KeyValuesProps < T extends object > {
13- keyName ?: string | number ;
14- value ?: T ;
15- parentValue ?: T ;
13+ interface KeyValuesProps < T extends object > extends SectionElementResult < T > {
1614 expandKey ?: string ;
1715 level : number ;
1816}
1917
2018export const KeyValues = < T extends object > ( props : KeyValuesProps < T > ) => {
21- const { value, expandKey = '' , level } = props ;
19+ const { value, expandKey = '' , level, keys = [ ] } = props ;
2220 const expands = useExpandsStore ( ) ;
2321 const { objectSortKeys, indentWidth, collapsed } = useStore ( ) ;
2422 const isMyArray = Array . isArray ( value ) ;
@@ -49,7 +47,9 @@ export const KeyValues = <T extends object>(props: KeyValuesProps<T>) => {
4947 return (
5048 < div className = "w-rjv-wrap" style = { style } >
5149 { entries . map ( ( [ key , val ] , idx ) => {
52- return < KeyValuesItem parentValue = { value } keyName = { key } value = { val } key = { idx } level = { level } /> ;
50+ return (
51+ < KeyValuesItem parentValue = { value } keyName = { key } keys = { [ ...keys , key ] } value = { val } key = { idx } level = { level } />
52+ ) ;
5353 } ) }
5454 </ div >
5555 ) ;
@@ -81,7 +81,7 @@ export const KayName = <T extends object>(props: KayNameProps<T>) => {
8181KayName . displayName = 'JVR.KayName' ;
8282
8383export const KeyValuesItem = < T extends object > ( props : KeyValuesProps < T > ) => {
84- const { keyName, value, parentValue, level = 0 } = props ;
84+ const { keyName, value, parentValue, level = 0 , keys = [ ] } = props ;
8585 const dispatch = useShowToolsDispatch ( ) ;
8686 const subkeyid = useId ( ) ;
8787 const isMyArray = Array . isArray ( value ) ;
@@ -94,15 +94,22 @@ export const KeyValuesItem = <T extends object>(props: KeyValuesProps<T>) => {
9494 if ( isNested ) {
9595 const myValue = isMySet ? Array . from ( value as Set < any > ) : isMyMap ? Object . fromEntries ( value ) : value ;
9696 return (
97- < Container keyName = { keyName } value = { myValue } parentValue = { parentValue } initialValue = { value } level = { level + 1 } />
97+ < Container
98+ keyName = { keyName }
99+ value = { myValue }
100+ parentValue = { parentValue }
101+ initialValue = { value }
102+ keys = { keys }
103+ level = { level + 1 }
104+ />
98105 ) ;
99106 }
100107 const reset : React . HTMLAttributes < HTMLDivElement > = {
101108 onMouseEnter : ( ) => dispatch ( { [ subkeyid ] : true } ) ,
102109 onMouseLeave : ( ) => dispatch ( { [ subkeyid ] : false } ) ,
103110 } ;
104111 return (
105- < RowComp className = "w-rjv-line" value = { value } keyName = { keyName } parentValue = { parentValue } { ...reset } >
112+ < RowComp className = "w-rjv-line" value = { value } keyName = { keyName } keys = { keys } parentValue = { parentValue } { ...reset } >
106113 < KayName keyName = { keyName } value = { value } parentValue = { parentValue } />
107114 < Value keyName = { keyName ! } value = { value } expandKey = { subkeyid } />
108115 </ RowComp >
0 commit comments