BpmnRules.d.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /**
  2. * BPMN-specific modeling rules.
  3. *
  4. */
  5. export default class BpmnRules extends RuleProvider {
  6. canConnectMessageFlow: typeof canConnectMessageFlow;
  7. canConnectSequenceFlow: typeof canConnectSequenceFlow;
  8. canConnectDataAssociation: typeof canConnectDataAssociation;
  9. canConnectAssociation: typeof canConnectAssociation;
  10. canConnectCompensationAssociation: typeof canConnectCompensationAssociation;
  11. canMove: typeof canMove;
  12. canAttach: typeof canAttach;
  13. canReplace: typeof canReplace;
  14. canDrop: typeof canDrop;
  15. canInsert: typeof canInsert;
  16. canCreate: typeof canCreate;
  17. canConnect: typeof canConnect;
  18. canResize: typeof canResize;
  19. canCopy: typeof canCopy;
  20. }
  21. type EventBus = import('diagram-js/lib/core/EventBus').default;
  22. type Connection = import('../../model/Types').Connection;
  23. type Element = import('../../model/Types').Element;
  24. type Shape = import('../../model/Types').Shape;
  25. type ModdleElement = import('../../model/Types').ModdleElement;
  26. type Point = import('diagram-js/lib/util/Types').Point;
  27. type Rect = import('diagram-js/lib/util/Types').Rect;
  28. export type CanConnectResult = {
  29. associationDirection?: 'None' | 'One' | 'Both';
  30. type: string;
  31. } | boolean | null;
  32. export type CanReplaceResult = {
  33. id: string;
  34. type: string;
  35. } | boolean;
  36. import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
  37. /**
  38. * @param source
  39. * @param target
  40. *
  41. * @return
  42. */
  43. declare function canConnectMessageFlow(source: Element, target: Element): boolean;
  44. /**
  45. * @param source
  46. * @param target
  47. *
  48. * @return
  49. */
  50. declare function canConnectSequenceFlow(source: Element, target: Element): boolean;
  51. /**
  52. * @param source
  53. * @param target
  54. *
  55. * @return
  56. */
  57. declare function canConnectDataAssociation(source: Element, target: Element): CanConnectResult;
  58. /**
  59. * @param source
  60. * @param target
  61. *
  62. * @return
  63. */
  64. declare function canConnectAssociation(source: Element, target: Element): CanConnectResult;
  65. /**
  66. * @param source
  67. * @param target
  68. *
  69. * @return
  70. */
  71. declare function canConnectCompensationAssociation(source: Element, target: Element): boolean;
  72. /**
  73. * @param elements
  74. * @param target
  75. *
  76. * @return
  77. */
  78. declare function canMove(elements: Element[], target: Shape): boolean;
  79. /**
  80. * TODO(philippfromme): remove `source` parameter
  81. *
  82. * @param elements
  83. * @param target
  84. * @param source
  85. * @param position
  86. *
  87. * @return
  88. */
  89. declare function canAttach(elements: Element[], target: Shape, source: Element, position?: Point): boolean | 'attach';
  90. /**
  91. * Check whether the given elements can be replaced. Return all elements which
  92. * can be replaced.
  93. *
  94. * @example
  95. *
  96. * ```javascript
  97. * [{
  98. * id: 'IntermediateEvent_1',
  99. * type: 'bpmn:StartEvent'
  100. * },
  101. * {
  102. * id: 'Task_1',
  103. * type: 'bpmn:ServiceTask'
  104. * }]
  105. * ```
  106. *
  107. * @param elements
  108. * @param target
  109. * @param position
  110. *
  111. * @return
  112. */
  113. declare function canReplace(elements: Element[], target?: Shape, position?: Point): CanReplaceResult;
  114. /**
  115. * Can an element be dropped into the target element.
  116. *
  117. * @param element
  118. * @param target
  119. *
  120. * @return
  121. */
  122. declare function canDrop(element: Element, target: Shape): boolean;
  123. /**
  124. * @param shape
  125. * @param connection
  126. * @param position
  127. *
  128. * @return
  129. */
  130. declare function canInsert(shape: Shape, connection: Connection, position: Point): boolean;
  131. /**
  132. * @param shape
  133. * @param target
  134. * @param source
  135. * @param position
  136. *
  137. * @return
  138. */
  139. declare function canCreate(shape: Shape, target: Shape, source: Element, position: Point): boolean;
  140. /**
  141. * @param source
  142. * @param target
  143. * @param connection
  144. *
  145. * @return
  146. */
  147. declare function canConnect(source: Element, target: Element, connection: Connection): CanConnectResult;
  148. /**
  149. * @param shape
  150. * @param newBounds
  151. *
  152. * @return
  153. */
  154. declare function canResize(shape: Shape, newBounds: Rect): boolean;
  155. /**
  156. * @param elements
  157. * @param element
  158. *
  159. * @return
  160. */
  161. declare function canCopy(elements: Element[], element: Element): boolean;
  162. export {};