ExclusiveGateway.js 3.3 KB

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