UNPKG

@eccenca/gui-elements

Version:

GUI elements based on other libraries, usable in React application, written in Typescript.

38 lines 2.39 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; import React, { memo } from "react"; import { Position } from "@xyflow/react"; import { Tooltip } from "../../../index.js"; import { useReactFlowVersion } from "../versionsupport.js"; import { NodeContent } from "./NodeContent.js"; /** * The `NodeDefault` element manages the display of React-Flow nodes. * This element cannot be used directly, it must be connected via a `nodeTypes` definition and all properties need to be routed through the `elements` property items inside the `ReactFlow` container. * @see https://reactflow.dev/docs/api/nodes/ */ export var NodeDefault = memo(function (node) { var flowVersion = node.flowVersion, data = node.data, _a = node.targetPosition, targetPosition = _a === void 0 ? Position.Left : _a, _b = node.sourcePosition, sourcePosition = _b === void 0 ? Position.Right : _b, _c = node.isConnectable, isConnectable = _c === void 0 ? true : _c, selected = node.selected; var evaluateFlowVersion = useReactFlowVersion(); var flowVersionCheck = flowVersion || evaluateFlowVersion; var nodeEl = (React.createElement(NodeContent, __assign({ flowVersion: flowVersionCheck }, data, { targetPosition: targetPosition, sourcePosition: sourcePosition, isConnectable: isConnectable, selected: selected }))); if (!selected && (data === null || data === void 0 ? void 0 : data.minimalShape) !== "none" && !!(data === null || data === void 0 ? void 0 : data.getMinimalTooltipData)) { var tooltipData = data === null || data === void 0 ? void 0 : data.getMinimalTooltipData(node); if (!!tooltipData.label || !!tooltipData.content) { return (React.createElement(Tooltip, { content: React.createElement(React.Fragment, null, tooltipData.label && React.createElement("div", null, tooltipData.label), tooltipData.content && React.createElement("div", null, tooltipData.content)) }, nodeEl)); } } return nodeEl; }); export default NodeDefault; //# sourceMappingURL=NodeDefault.js.map