@xrenders/xflow
Version:
一款功能强大、易用灵活的流程编辑器框架,帮助你轻松构建复杂的工作流和流程产品
81 lines (80 loc) • 5.39 kB
JavaScript
;
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("@xyflow/react");
var _classnames = _interopRequireDefault(require("classnames"));
var _react2 = _interopRequireWildcard(require("react"));
var _NodeContainer = _interopRequireDefault(require("../../components/NodeContainer"));
var _context = require("../../models/context");
var _SwitchBuildInNodeWidget = _interopRequireDefault(require("./SwitchBuildInNodeWidget"));
var _utils = require("../../utils");
require("./index.css");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
var _default = exports.default = /*#__PURE__*/(0, _react2.memo)(function (props) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
var onClick = props.onClick,
type = props.type,
data = props.data,
position = props.position,
isConnectable = props.isConnectable,
selected = props.selected,
isHovered = props.isHovered,
handleAddNode = props.handleAddNode,
id = props.id;
var _useContext = (0, _react2.useContext)(_context.ConfigContext),
settingMap = _useContext.settingMap,
widgets = _useContext.widgets,
iconFontUrl = _useContext.iconFontUrl,
globalConfig = _useContext.globalConfig,
openColorfulMode = _useContext.openColorfulMode;
var nodeSetting = settingMap[type] || {};
var NodeWidget = widgets[nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.nodeWidget] || undefined;
var nodeDescription = (nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.description) || '';
var hideDesc = (_d = (_b = (_a = nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.nodePanel) === null || _a === void 0 ? void 0 : _a.hideDesc) !== null && _b !== void 0 ? _b : (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.nodePanel) === null || _c === void 0 ? void 0 : _c.hideDesc) !== null && _d !== void 0 ? _d : false;
var hideTitleTips = (_f = (_e = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.nodeView) === null || _e === void 0 ? void 0 : _e.hideTitleTips) !== null && _f !== void 0 ? _f : false;
var isSwitchBottom = position === _react.Position.Bottom;
var SVGWidget = widgets[nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.iconSvg]; // 自定义面板配置组件
return /*#__PURE__*/_react2.default.createElement(_NodeContainer.default, {
className: (0, _classnames.default)('custom-node-code', {
'switch-node-code-bottom': isSwitchBottom
}),
title: (data === null || data === void 0 ? void 0 : data.title) || (nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.title) || 'Switch',
icon: {
type: ((_g = nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.icon) === null || _g === void 0 ? void 0 : _g.type) || 'icon-switch',
style: {
fontSize: 14,
color: '#fff'
},
bgColor: ((_h = nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.icon) === null || _h === void 0 ? void 0 : _h.bgColor) || '#06AED4'
},
onClick: onClick,
hideDesc: hideDesc,
desc: data === null || data === void 0 ? void 0 : data.desc,
iconFontUrl: iconFontUrl,
NodeWidget: /*#__PURE__*/_react2.default.createElement(_SwitchBuildInNodeWidget.default, {
data: data,
position: position,
isConnectable: isConnectable,
selected: selected,
isHovered: isHovered,
handleAddNode: handleAddNode,
CustomNodeWidget: NodeWidget,
isSwitchBottom: isSwitchBottom,
nodeSetting: nodeSetting,
id: id
}),
description: nodeDescription,
iconSvg: SVGWidget ? /*#__PURE__*/_react2.default.createElement(SVGWidget, {
setting: nodeSetting
}) : false,
hideTitleTips: hideTitleTips,
isSwitchBottom: isSwitchBottom,
nodeSettingTitle: (nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.title) || 'Switch',
style: Object.assign({}, (0, _utils.getColorfulModeBackground)((_j = nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.icon) === null || _j === void 0 ? void 0 : _j.bgColor, openColorfulMode))
});
});