Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 22x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 2x 117x 117x 22x | import { useStore } from '../store'; import { useExpandsStore } from '../store/Expands'; import { BracketsClose } from '../symbol'; interface NestedCloseProps<T extends object> { value?: T; expandKey: string; level: number; keys?: (string | number)[]; } export const NestedClose = <T extends object>(props: NestedCloseProps<T>) => { const { value, expandKey, level, keys = [] } = props; const expands = useExpandsStore(); const isArray = Array.isArray(value); const { collapsed, shouldExpandNodeInitially } = useStore(); const isMySet = value instanceof Set; const defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false; const isExpanded = expands[expandKey] ?? defaultExpanded; const len = Object.keys(value!).length; Iif ( expands[expandKey] === undefined && shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, { value, keys, level }) ) { return null; } if (isExpanded || len === 0) { return null; } const style: React.CSSProperties = { paddingLeft: 4, }; return ( <div style={style}> <BracketsClose isBrackets={isArray || isMySet} isVisiable={true} /> </div> ); }; NestedClose.displayName = 'JVR.NestedClose'; |