UNPKG

@uiw/react-json-view

Version:
44 lines 1.28 kB
import { useStore } from "../store.js"; import { useExpandsStore } from "../store/Expands.js"; import { BracketsClose } from "../symbol/index.js"; import { jsx as _jsx } from "react/jsx-runtime"; export var NestedClose = props => { var _expands$expandKey; var { value, expandKey, level, keys = [] } = props; var expands = useExpandsStore(); var isArray = Array.isArray(value); var { collapsed, shouldExpandNodeInitially } = useStore(); var isMySet = value instanceof Set; var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false; var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : defaultExpanded; var len = Object.keys(value).length; if (expands[expandKey] === undefined && shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, { value, keys, level })) { return null; } if (isExpanded || len === 0) { return null; } var style = { paddingLeft: 4 }; return /*#__PURE__*/_jsx("div", { style: style, children: /*#__PURE__*/_jsx(BracketsClose, { isBrackets: isArray || isMySet, isVisiable: true }) }); }; NestedClose.displayName = 'JVR.NestedClose';