UNPKG

@xrenders/xflow

Version:

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

61 lines (60 loc) 4.41 kB
"use strict"; 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 = _interopRequireWildcard(require("react")); var _NodeContainer = _interopRequireDefault(require("../../components/NodeContainer")); var _context = require("../../models/context"); var _utils = require("../../utils"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } 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; } var _default = exports.default = /*#__PURE__*/(0, _react.memo)(function (props) { var _a, _b, _c, _d, _e, _f, _g, _h, _j; var type = props.type, onClick = props.onClick, data = props.data, id = props.id; var _useContext = (0, _react.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 SVGWidget = widgets[nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.iconSvg]; // 自定义面板配置组件 return /*#__PURE__*/_react.default.createElement(_NodeContainer.default, { className: 'custom-node-code', title: (data === null || data === void 0 ? void 0 : data.title) || nodeSetting.title, icon: { type: (_g = nodeSetting === null || nodeSetting === void 0 ? void 0 : nodeSetting.icon) === null || _g === void 0 ? void 0 : _g.type, 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.default.createElement(NodeWidget, { data: data, id: id, nodeType: type }) : undefined, iconFontUrl: iconFontUrl, description: nodeDescription, iconSvg: SVGWidget ? /*#__PURE__*/_react.default.createElement(SVGWidget, { setting: nodeSetting }) : false, hideTitleTips: hideTitleTips, nodeSettingTitle: nodeSetting.title, 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)) }); });