UNPKG

@difizen/mana-app

Version:

39 lines 1.67 kB
import { notEmpty } from '@difizen/mana-common'; import { ViewInstance } from '@difizen/mana-core'; import { useInject } from '@difizen/mana-observable'; import * as React from 'react'; import { TREE_NODE_SEGMENT_CLASS, TREE_NODE_TAIL_CLASS } from "../tree-protocol"; import { TreeViewDecorator } from "../view/tree-view-decorator"; import { jsx as _jsx } from "react/jsx-runtime"; export function TreeNodeTailDecorations(props) { var node = props.node; var treeViewDecorator = useInject(TreeViewDecorator); var treeView = useInject(ViewInstance); return /*#__PURE__*/_jsx(React.Fragment, { children: treeViewDecorator.getDecorationData(node, 'tailDecorations').filter(notEmpty).reduce(function (acc, current) { return acc.concat(current); }, []).map(function (decoration, index) { var tooltip = decoration.tooltip; var _ref = decoration, data = _ref.data, fontData = _ref.fontData; var _ref2 = decoration, color = _ref2.color; var icon = decoration.icon || decoration.iconClass; var className = [TREE_NODE_SEGMENT_CLASS, TREE_NODE_TAIL_CLASS].join(' '); // eslint-disable-next-line no-nested-ternary var style = fontData ? treeView.applyFontStyles({}, fontData) : color ? { color: color } : undefined; var content = data || (icon ? /*#__PURE__*/_jsx("span", { className: treeView.getIconClass(icon) }, "".concat(node.id, "icon").concat(index)) : ''); return /*#__PURE__*/_jsx("div", { className: className, style: style, title: tooltip, children: content }, node.id + className + index); }) }); }