UNPKG

@logicflow/extension

Version:
108 lines (107 loc) 4.07 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); 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); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.GatewayNodeFactory = exports.gatewayComposable = exports.gateway = void 0; var core_1 = require("@logicflow/core"); var utils_1 = require("../../utils"); exports.gateway = { exclusive: 0, inclusive: 1, parallel: 2, }; /** * index 0 排他网关 * index 1 包容网关 * index 2 并行网关 */ exports.gatewayComposable = [ [1, 1, 0], [0, 0, 1], [0, 1, 1], ]; /** * @param type 网关节点的type, 对应其XML定义中的节点名,如<bpmn:inclusiveGateway /> 其type为bpmn:inclusiveGateway * @param icon 网关节点左上角的图标,可以是svg path,也可以是h函数生成的svg * @param props (可选) 网关节点的属性 * @returns { type: string, model: any, view: any } */ function GatewayNodeFactory(type, icon, props) { var view = /** @class */ (function (_super) { __extends(view, _super); function view() { return _super !== null && _super.apply(this, arguments) || this; } view.prototype.getShape = function () { var model = this.props.model; var _a = model, x = _a.x, y = _a.y, width = _a.width, height = _a.height, points = _a.points; var style = model.getNodeStyle(); return (0, core_1.h)('g', { transform: "matrix(1 0 0 1 ".concat(x - width / 2, " ").concat(y - height / 2, ")"), }, (0, core_1.h)(core_1.Polygon, __assign(__assign({}, style), { x: x, y: y, points: points })), typeof icon === 'string' ? (0, core_1.h)('path', __assign(__assign({ d: icon }, style), { fill: 'rgb(34, 36, 42)', strokeWidth: 1 })) : icon); }; return view; }(core_1.PolygonNode)); var model = /** @class */ (function (_super) { __extends(model, _super); function model(data, graphModel) { var _this = this; if (!data.id) { data.id = "Gateway_".concat((0, utils_1.genBpmnId)()); } if (!data.text) { data.text = ''; } if (data.text && typeof data.text === 'string') { data.text = { value: data.text, x: data.x, y: data.y + 40, }; } data.properties = __assign(__assign({}, (props || {})), data.properties); _this = _super.call(this, data, graphModel) || this; _this.points = [ [25, 0], [50, 25], [25, 50], [0, 25], ]; utils_1.groupRule.call(_this); return _this; } return model; }(core_1.PolygonNodeModel)); return { type: type, view: view, model: model, }; } exports.GatewayNodeFactory = GatewayNodeFactory;