@talend/react-components
Version:
Set of react components.
43 lines (42 loc) • 1.22 kB
JavaScript
import PropTypes from 'prop-types';
import TreeNode from '../TreeNode';
/**
* Render a list of TreeNode (branch or leaf).
*/
import { get } from "lodash";
import { jsx as _jsx } from "react/jsx-runtime";
export default function TreeNodeList({
treeClassName,
nodeClassName,
...props
}) {
return /*#__PURE__*/_jsx("ul", {
className: treeClassName,
children: props.value.map((node, index) => /*#__PURE__*/_jsx("li", {
className: nodeClassName,
children: /*#__PURE__*/_jsx(TreeNode, {
...props,
...node,
index: props.index || 0,
dataKey: get(node, 'dataKey'),
value: get(node, 'value'),
jsonpath: props.getJSONPath(get(node, 'dataKey'), {
jsonpath: props.jsonpath,
type: props.type,
value: node
})
})
}, index))
});
}
TreeNodeList.propTypes = {
dataKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
getJSONPath: PropTypes.func.isRequired,
index: PropTypes.number,
jsonpath: PropTypes.string,
nodeClassName: PropTypes.string,
treeClassName: PropTypes.string,
type: PropTypes.string,
value: PropTypes.array.isRequired
};
//# sourceMappingURL=TreeNodeList.component.js.map