UNPKG

@xrenders/xflow

Version:

一款功能强大、易用灵活的流程编辑器框架,帮助你轻松构建复杂的工作流和流程产品

53 lines 3.23 kB
import React, { memo, useContext } from 'react'; import NodeContainer from '../../components/NodeContainer'; import { ConfigContext } from '../../models/context'; import { getColorfulModeBackground } from '../../utils'; export default /*#__PURE__*/memo(function (props) { var _a, _b, _c, _d, _e, _f, _g, _h, _j; var onClick = props.onClick, type = props.type, data = props.data, id = props.id; var _useContext = useContext(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 gradientHeight = nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.gradientHeight; 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 SVGWidget = widgets[nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.iconSvg]; // 自定义面板配置组件 return /*#__PURE__*/React.createElement(NodeContainer, { className: 'custom-node-code', title: (data === null || data === void 0 ? void 0 : data.title) || (nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.title) || '结束', icon: { type: ((_g = nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.icon) === null || _g === void 0 ? void 0 : _g.type) || 'icon-end', style: { fontSize: 14, color: '#fff' }, bgColor: ((_h = nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.icon) === null || _h === void 0 ? void 0 : _h.bgColor) || '#F79009' }, onClick: onClick, hideDesc: hideDesc, desc: data === null || data === void 0 ? void 0 : data.desc, NodeWidget: NodeWidget ? /*#__PURE__*/React.createElement(NodeWidget, { data: data, id: id, nodeType: type }) : undefined, iconFontUrl: iconFontUrl, description: nodeDescription, iconSvg: SVGWidget ? /*#__PURE__*/React.createElement(SVGWidget, { setting: nodeSetting }) : false, hideTitleTips: hideTitleTips, nodeSettingTitle: nodeSetting.title || '结束', gradientHeight: gradientHeight, style: Object.assign({}, getColorfulModeBackground((_j = nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.icon) === null || _j === void 0 ? void 0 : _j.bgColor, openColorfulMode)) }); });