ExclusiveGateway.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. var __assign = (this && this.__assign) || function () {
  16. __assign = Object.assign || function(t) {
  17. for (var s, i = 1, n = arguments.length; i < n; i++) {
  18. s = arguments[i];
  19. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  20. t[p] = s[p];
  21. }
  22. return t;
  23. };
  24. return __assign.apply(this, arguments);
  25. };
  26. Object.defineProperty(exports, "__esModule", { value: true });
  27. exports.ExclusiveGatewayModel = exports.ExclusiveGatewayView = void 0;
  28. var core_1 = require("@logicflow/core");
  29. var getBpmnId_1 = require("../getBpmnId");
  30. var ExclusiveGatewayModel = /** @class */ (function (_super) {
  31. __extends(ExclusiveGatewayModel, _super);
  32. function ExclusiveGatewayModel(data, graphModel) {
  33. var _this = this;
  34. if (!data.id) {
  35. data.id = "Gateway_" + getBpmnId_1.getBpmnId();
  36. }
  37. if (!data.text) {
  38. data.text = '';
  39. }
  40. if (data.text && typeof data.text === 'string') {
  41. data.text = {
  42. value: data.text,
  43. x: data.x,
  44. y: data.y + 40,
  45. };
  46. }
  47. _this = _super.call(this, data, graphModel) || this;
  48. _this.points = [
  49. [25, 0],
  50. [50, 25],
  51. [25, 50],
  52. [0, 25],
  53. ];
  54. return _this;
  55. }
  56. ExclusiveGatewayModel.extendKey = 'ExclusiveGatewayModel';
  57. return ExclusiveGatewayModel;
  58. }(core_1.PolygonNodeModel));
  59. exports.ExclusiveGatewayModel = ExclusiveGatewayModel;
  60. var ExclusiveGatewayView = /** @class */ (function (_super) {
  61. __extends(ExclusiveGatewayView, _super);
  62. function ExclusiveGatewayView() {
  63. return _super !== null && _super.apply(this, arguments) || this;
  64. }
  65. ExclusiveGatewayView.prototype.getShape = function () {
  66. var model = this.props.model;
  67. var x = model.x, y = model.y, width = model.width, height = model.height, points = model.points;
  68. var style = model.getNodeStyle();
  69. return core_1.h('g', {
  70. transform: "matrix(1 0 0 1 " + (x - width / 2) + " " + (y - height / 2) + ")",
  71. }, core_1.h('polygon', __assign(__assign({}, style), { x: x,
  72. y: y,
  73. points: points })), core_1.h('path', __assign({ d: 'm 16,15 7.42857142857143,9.714285714285715 -7.42857142857143,9.714285714285715 3.428571428571429,0 5.714285714285715,-7.464228571428572 5.714285714285715,7.464228571428572 3.428571428571429,0 -7.42857142857143,-9.714285714285715 7.42857142857143,-9.714285714285715 -3.428571428571429,0 -5.714285714285715,7.464228571428572 -5.714285714285715,-7.464228571428572 -3.428571428571429,0 z' }, style)));
  74. };
  75. ExclusiveGatewayView.extendKey = 'ExclusiveGatewayNode';
  76. return ExclusiveGatewayView;
  77. }(core_1.PolygonNode));
  78. exports.ExclusiveGatewayView = ExclusiveGatewayView;
  79. var ExclusiveGateway = {
  80. type: 'bpmn:exclusiveGateway',
  81. view: ExclusiveGatewayView,
  82. model: ExclusiveGatewayModel,
  83. };
  84. exports.default = ExclusiveGateway;