camunda-bpmn-js 4.6.0 → 4.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27510,6 +27510,8 @@
27510
27510
  alignElements: [ 'type', AlignElements$1 ]
27511
27511
  };
27512
27512
 
27513
+ var MARKER_HIDDEN$1 = 'djs-element-hidden';
27514
+
27513
27515
  /**
27514
27516
  * @typedef {import('../../model/Types').Element} Element
27515
27517
  *
@@ -27621,9 +27623,11 @@
27621
27623
  });
27622
27624
 
27623
27625
  this._eventBus.on('canvas.viewbox.changed', () => {
27624
- if (this.isOpen()) {
27625
- this._updatePosition();
27626
- }
27626
+ this._updatePosition();
27627
+ });
27628
+
27629
+ this._eventBus.on('element.marker.update', function(event) {
27630
+ self._updateVisibility();
27627
27631
  });
27628
27632
 
27629
27633
  this._container = this._createContainer();
@@ -27874,6 +27878,8 @@
27874
27878
 
27875
27879
  this._updatePosition();
27876
27880
 
27881
+ this._updateVisibility();
27882
+
27877
27883
  this._eventBus.fire('contextPad.open', { current: this._current });
27878
27884
  };
27879
27885
 
@@ -28015,6 +28021,8 @@
28015
28021
 
28016
28022
  classes$1(this._current.html).add('open');
28017
28023
 
28024
+ this._updatePosition();
28025
+
28018
28026
  this._eventBus.fire('contextPad.show', { current: this._current });
28019
28027
  };
28020
28028
 
@@ -28099,6 +28107,32 @@
28099
28107
  }
28100
28108
  };
28101
28109
 
28110
+ /**
28111
+ * Update context pad visibility. Hide if any of the target elements is hidden
28112
+ * using the `djs-element-hidden` or `djs-label-hidden` markers.
28113
+ */
28114
+ ContextPad.prototype._updateVisibility = function() {
28115
+ if (!this.isOpen()) {
28116
+ return;
28117
+ }
28118
+
28119
+ var self = this;
28120
+
28121
+ var target = this._current.target;
28122
+
28123
+ var targets = isArray$b(target) ? target : [ target ];
28124
+
28125
+ var isHidden = targets.some(function(target) {
28126
+ return self._canvas.hasMarker(target, MARKER_HIDDEN$1);
28127
+ });
28128
+
28129
+ if (isHidden) {
28130
+ self.hide();
28131
+ } else {
28132
+ self.show();
28133
+ }
28134
+ };
28135
+
28102
28136
  /**
28103
28137
  * Get bounding client rect of target element(s).
28104
28138
  *
@@ -57384,568 +57418,568 @@
57384
57418
  replaceMenuProvider: [ 'type', ReplaceMenuProvider ]
57385
57419
  };
57386
57420
 
57387
- /**
57388
- * @typedef {import('didi').Injector} Injector
57389
- * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
57390
- * @typedef {import('diagram-js/lib/features/context-pad/ContextPad').default} ContextPad
57391
- * @typedef {import('../modeling/Modeling').default} Modeling
57392
- * @typedef {import('../modeling/ElementFactory').default} ElementFactory
57393
- * @typedef {import('diagram-js/lib/features/connect/Connect').default} Connect
57394
- * @typedef {import('diagram-js/lib/features/create/Create').default} Create
57395
- * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenu').default} PopupMenu
57396
- * @typedef {import('diagram-js/lib/features/canvas/Canvas').default} Canvas
57397
- * @typedef {import('diagram-js/lib/features/rules/Rules').default} Rules
57398
- * @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
57399
- *
57400
- * @typedef {import('../../model/Types').Element} Element
57401
- * @typedef {import('../../model/Types').ModdleElement} ModdleElement
57402
- *
57403
- * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').default<Element>} BaseContextPadProvider
57404
- * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').ContextPadEntries} ContextPadEntries
57405
- * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').ContextPadEntry} ContextPadEntry
57406
- *
57407
- * @typedef { { autoPlace?: boolean; } } ContextPadConfig
57408
- */
57409
-
57410
- /**
57411
- * BPMN-specific context pad provider.
57412
- *
57413
- * @implements {BaseContextPadProvider}
57414
- *
57415
- * @param {ContextPadConfig} config
57416
- * @param {Injector} injector
57417
- * @param {EventBus} eventBus
57418
- * @param {ContextPad} contextPad
57419
- * @param {Modeling} modeling
57420
- * @param {ElementFactory} elementFactory
57421
- * @param {Connect} connect
57422
- * @param {Create} create
57423
- * @param {PopupMenu} popupMenu
57424
- * @param {Canvas} canvas
57425
- * @param {Rules} rules
57426
- * @param {Translate} translate
57427
- */
57428
- function ContextPadProvider(
57429
- config, injector, eventBus,
57430
- contextPad, modeling, elementFactory,
57431
- connect, create, popupMenu,
57432
- canvas, rules, translate, appendPreview) {
57433
-
57434
- config = config || {};
57435
-
57436
- contextPad.registerProvider(this);
57437
-
57438
- this._contextPad = contextPad;
57439
-
57440
- this._modeling = modeling;
57441
-
57442
- this._elementFactory = elementFactory;
57443
- this._connect = connect;
57444
- this._create = create;
57445
- this._popupMenu = popupMenu;
57446
- this._canvas = canvas;
57447
- this._rules = rules;
57448
- this._translate = translate;
57449
- this._eventBus = eventBus;
57450
- this._appendPreview = appendPreview;
57451
-
57452
- if (config.autoPlace !== false) {
57453
- this._autoPlace = injector.get('autoPlace', false);
57454
- }
57455
-
57456
- eventBus.on('create.end', 250, function(event) {
57457
- var context = event.context,
57458
- shape = context.shape;
57459
-
57460
- if (!hasPrimaryModifier(event) || !contextPad.isOpen(shape)) {
57461
- return;
57462
- }
57463
-
57464
- var entries = contextPad.getEntries(shape);
57465
-
57466
- if (entries.replace) {
57467
- entries.replace.action.click(event, shape);
57468
- }
57469
- });
57470
-
57471
- eventBus.on('contextPad.close', function() {
57472
- appendPreview.cleanUp();
57473
- });
57474
- }
57475
-
57476
- ContextPadProvider.$inject = [
57477
- 'config.contextPad',
57478
- 'injector',
57479
- 'eventBus',
57480
- 'contextPad',
57481
- 'modeling',
57482
- 'elementFactory',
57483
- 'connect',
57484
- 'create',
57485
- 'popupMenu',
57486
- 'canvas',
57487
- 'rules',
57488
- 'translate',
57489
- 'appendPreview'
57490
- ];
57491
-
57492
- /**
57493
- * @param {Element[]} elements
57494
- *
57495
- * @return {ContextPadEntries}
57496
- */
57497
- ContextPadProvider.prototype.getMultiElementContextPadEntries = function(elements) {
57498
- var modeling = this._modeling;
57499
-
57500
- var actions = {};
57501
-
57502
- if (this._isDeleteAllowed(elements)) {
57503
- assign$4(actions, {
57504
- 'delete': {
57505
- group: 'edit',
57506
- className: 'bpmn-icon-trash',
57507
- title: this._translate('Delete'),
57508
- action: {
57509
- click: function(event, elements) {
57510
- modeling.removeElements(elements.slice());
57511
- }
57512
- }
57513
- }
57514
- });
57515
- }
57516
-
57517
- return actions;
57518
- };
57519
-
57520
- /**
57521
- * @param {Element[]} elements
57522
- *
57523
- * @return {boolean}
57524
- */
57525
- ContextPadProvider.prototype._isDeleteAllowed = function(elements) {
57526
-
57527
- var baseAllowed = this._rules.allowed('elements.delete', {
57528
- elements: elements
57529
- });
57530
-
57531
- if (isArray$b(baseAllowed)) {
57532
- return every$1(baseAllowed, function(element) {
57533
- return includes$1(baseAllowed, element);
57534
- });
57535
- }
57536
-
57537
- return baseAllowed;
57538
- };
57539
-
57540
- /**
57541
- * @param {Element} element
57542
- *
57543
- * @return {ContextPadEntries}
57544
- */
57545
- ContextPadProvider.prototype.getContextPadEntries = function(element) {
57546
- var contextPad = this._contextPad,
57547
- modeling = this._modeling,
57548
- elementFactory = this._elementFactory,
57549
- connect = this._connect,
57550
- create = this._create,
57551
- popupMenu = this._popupMenu,
57552
- rules = this._rules,
57553
- autoPlace = this._autoPlace,
57554
- translate = this._translate,
57555
- appendPreview = this._appendPreview;
57556
-
57557
- var actions = {};
57558
-
57559
- if (element.type === 'label') {
57560
- return actions;
57561
- }
57562
-
57563
- var businessObject = element.businessObject;
57564
-
57565
- function startConnect(event, element) {
57566
- connect.start(event, element);
57567
- }
57568
-
57569
- function removeElement(e, element) {
57570
- modeling.removeElements([ element ]);
57571
- }
57572
-
57573
- function getReplaceMenuPosition(element) {
57574
-
57575
- var Y_OFFSET = 5;
57576
-
57577
- var pad = contextPad.getPad(element).html;
57578
-
57579
- var padRect = pad.getBoundingClientRect();
57580
-
57581
- var pos = {
57582
- x: padRect.left,
57583
- y: padRect.bottom + Y_OFFSET
57584
- };
57585
-
57586
- return pos;
57587
- }
57588
-
57589
- /**
57590
- * Create an append action.
57591
- *
57592
- * @param {string} type
57593
- * @param {string} className
57594
- * @param {string} title
57595
- * @param {Object} [options]
57596
- *
57597
- * @return {ContextPadEntry}
57598
- */
57599
- function appendAction(type, className, title, options) {
57600
-
57601
- function appendStart(event, element) {
57602
-
57603
- var shape = elementFactory.createShape(assign$4({ type: type }, options));
57604
-
57605
- create.start(event, shape, {
57606
- source: element
57607
- });
57608
- }
57609
-
57610
- var append = autoPlace ? function(_, element) {
57611
- var shape = elementFactory.createShape(assign$4({ type: type }, options));
57612
-
57613
- autoPlace.append(element, shape);
57614
- } : appendStart;
57615
-
57616
- var previewAppend = autoPlace ? function(_, element) {
57617
-
57618
- // mouseover
57619
- appendPreview.create(element, type, options);
57620
-
57621
- return () => {
57622
-
57623
- // mouseout
57624
- appendPreview.cleanUp();
57625
- };
57626
- } : null;
57627
-
57628
- return {
57629
- group: 'model',
57630
- className: className,
57631
- title: title,
57632
- action: {
57633
- dragstart: appendStart,
57634
- click: append,
57635
- hover: previewAppend
57636
- }
57637
- };
57638
- }
57639
-
57640
- function splitLaneHandler(count) {
57641
-
57642
- return function(_, element) {
57643
-
57644
- // actual split
57645
- modeling.splitLane(element, count);
57646
-
57647
- // refresh context pad after split to
57648
- // get rid of split icons
57649
- contextPad.open(element, true);
57650
- };
57651
- }
57652
-
57653
-
57654
- if (isAny$1(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded$1(element)) {
57655
-
57656
- var childLanes = getChildLanes(element);
57657
-
57658
- assign$4(actions, {
57659
- 'lane-insert-above': {
57660
- group: 'lane-insert-above',
57661
- className: 'bpmn-icon-lane-insert-above',
57662
- title: translate('Add lane above'),
57663
- action: {
57664
- click: function(event, element) {
57665
- modeling.addLane(element, 'top');
57666
- }
57667
- }
57668
- }
57669
- });
57670
-
57671
- if (childLanes.length < 2) {
57672
-
57673
- if (isHorizontal$3(element) ? element.height >= 120 : element.width >= 120) {
57674
- assign$4(actions, {
57675
- 'lane-divide-two': {
57676
- group: 'lane-divide',
57677
- className: 'bpmn-icon-lane-divide-two',
57678
- title: translate('Divide into two lanes'),
57679
- action: {
57680
- click: splitLaneHandler(2)
57681
- }
57682
- }
57683
- });
57684
- }
57685
-
57686
- if (isHorizontal$3(element) ? element.height >= 180 : element.width >= 180) {
57687
- assign$4(actions, {
57688
- 'lane-divide-three': {
57689
- group: 'lane-divide',
57690
- className: 'bpmn-icon-lane-divide-three',
57691
- title: translate('Divide into three lanes'),
57692
- action: {
57693
- click: splitLaneHandler(3)
57694
- }
57695
- }
57696
- });
57697
- }
57698
- }
57699
-
57700
- assign$4(actions, {
57701
- 'lane-insert-below': {
57702
- group: 'lane-insert-below',
57703
- className: 'bpmn-icon-lane-insert-below',
57704
- title: translate('Add lane below'),
57705
- action: {
57706
- click: function(event, element) {
57707
- modeling.addLane(element, 'bottom');
57708
- }
57709
- }
57710
- }
57711
- });
57712
-
57713
- }
57714
-
57715
- if (is$6(businessObject, 'bpmn:FlowNode')) {
57716
-
57717
- if (is$6(businessObject, 'bpmn:EventBasedGateway')) {
57718
-
57719
- assign$4(actions, {
57720
- 'append.receive-task': appendAction(
57721
- 'bpmn:ReceiveTask',
57722
- 'bpmn-icon-receive-task',
57723
- translate('Append receive task')
57724
- ),
57725
- 'append.message-intermediate-event': appendAction(
57726
- 'bpmn:IntermediateCatchEvent',
57727
- 'bpmn-icon-intermediate-event-catch-message',
57728
- translate('Append message intermediate catch event'),
57729
- { eventDefinitionType: 'bpmn:MessageEventDefinition' }
57730
- ),
57731
- 'append.timer-intermediate-event': appendAction(
57732
- 'bpmn:IntermediateCatchEvent',
57733
- 'bpmn-icon-intermediate-event-catch-timer',
57734
- translate('Append timer intermediate catch event'),
57735
- { eventDefinitionType: 'bpmn:TimerEventDefinition' }
57736
- ),
57737
- 'append.condition-intermediate-event': appendAction(
57738
- 'bpmn:IntermediateCatchEvent',
57739
- 'bpmn-icon-intermediate-event-catch-condition',
57740
- translate('Append conditional intermediate catch event'),
57741
- { eventDefinitionType: 'bpmn:ConditionalEventDefinition' }
57742
- ),
57743
- 'append.signal-intermediate-event': appendAction(
57744
- 'bpmn:IntermediateCatchEvent',
57745
- 'bpmn-icon-intermediate-event-catch-signal',
57746
- translate('Append signal intermediate catch event'),
57747
- { eventDefinitionType: 'bpmn:SignalEventDefinition' }
57748
- )
57749
- });
57750
- } else
57751
-
57752
- if (isEventType(businessObject, 'bpmn:BoundaryEvent', 'bpmn:CompensateEventDefinition')) {
57753
-
57754
- assign$4(actions, {
57755
- 'append.compensation-activity':
57756
- appendAction(
57757
- 'bpmn:Task',
57758
- 'bpmn-icon-task',
57759
- translate('Append compensation activity'),
57760
- {
57761
- isForCompensation: true
57762
- }
57763
- )
57764
- });
57765
- } else
57766
-
57767
- if (!is$6(businessObject, 'bpmn:EndEvent') &&
57768
- !businessObject.isForCompensation &&
57769
- !isEventType(businessObject, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') &&
57770
- !isEventSubProcess(businessObject)) {
57771
-
57772
- assign$4(actions, {
57773
- 'append.end-event': appendAction(
57774
- 'bpmn:EndEvent',
57775
- 'bpmn-icon-end-event-none',
57776
- translate('Append end event')
57777
- ),
57778
- 'append.gateway': appendAction(
57779
- 'bpmn:ExclusiveGateway',
57780
- 'bpmn-icon-gateway-none',
57781
- translate('Append gateway')
57782
- ),
57783
- 'append.append-task': appendAction(
57784
- 'bpmn:Task',
57785
- 'bpmn-icon-task',
57786
- translate('Append task')
57787
- ),
57788
- 'append.intermediate-event': appendAction(
57789
- 'bpmn:IntermediateThrowEvent',
57790
- 'bpmn-icon-intermediate-event-none',
57791
- translate('Append intermediate/boundary event')
57792
- )
57793
- });
57794
- }
57795
- }
57796
-
57797
- if (!popupMenu.isEmpty(element, 'bpmn-replace')) {
57798
-
57799
- // Replace menu entry
57800
- assign$4(actions, {
57801
- 'replace': {
57802
- group: 'edit',
57803
- className: 'bpmn-icon-screw-wrench',
57804
- title: translate('Change element'),
57805
- action: {
57806
- click: function(event, element) {
57807
-
57808
- var position = assign$4(getReplaceMenuPosition(element), {
57809
- cursor: { x: event.x, y: event.y }
57810
- });
57811
-
57812
- popupMenu.open(element, 'bpmn-replace', position, {
57813
- title: translate('Change element'),
57814
- width: 300,
57815
- search: true
57816
- });
57817
- }
57818
- }
57819
- }
57820
- });
57821
- }
57822
-
57823
- if (is$6(businessObject, 'bpmn:SequenceFlow')) {
57824
- assign$4(actions, {
57825
- 'append.text-annotation': appendAction(
57826
- 'bpmn:TextAnnotation',
57827
- 'bpmn-icon-text-annotation',
57828
- translate('Add text annotation')
57829
- )
57830
- });
57831
- }
57832
-
57833
- if (
57834
- isAny$1(businessObject, [
57835
- 'bpmn:FlowNode',
57836
- 'bpmn:InteractionNode',
57837
- 'bpmn:DataObjectReference',
57838
- 'bpmn:DataStoreReference',
57839
- ])
57840
- ) {
57841
- assign$4(actions, {
57842
- 'append.text-annotation': appendAction(
57843
- 'bpmn:TextAnnotation',
57844
- 'bpmn-icon-text-annotation',
57845
- translate('Add text annotation')
57846
- ),
57847
- 'connect': {
57848
- group: 'connect',
57849
- className: 'bpmn-icon-connection-multi',
57850
- title: translate('Connect to other element'),
57851
- action: {
57852
- click: startConnect,
57853
- dragstart: startConnect,
57854
- },
57855
- },
57856
- });
57857
- }
57858
-
57859
- if (is$6(businessObject, 'bpmn:TextAnnotation')) {
57860
- assign$4(actions, {
57861
- 'connect': {
57862
- group: 'connect',
57863
- className: 'bpmn-icon-connection-multi',
57864
- title: translate('Connect using association'),
57865
- action: {
57866
- click: startConnect,
57867
- dragstart: startConnect,
57868
- },
57869
- },
57870
- });
57871
- }
57872
-
57873
- if (isAny$1(businessObject, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ])) {
57874
- assign$4(actions, {
57875
- 'connect': {
57876
- group: 'connect',
57877
- className: 'bpmn-icon-connection-multi',
57878
- title: translate('Connect using data input association'),
57879
- action: {
57880
- click: startConnect,
57881
- dragstart: startConnect
57882
- }
57883
- }
57884
- });
57885
- }
57886
-
57887
- if (is$6(businessObject, 'bpmn:Group')) {
57888
- assign$4(actions, {
57889
- 'append.text-annotation': appendAction(
57890
- 'bpmn:TextAnnotation',
57891
- 'bpmn-icon-text-annotation',
57892
- translate('Add text annotation')
57893
- )
57894
- });
57895
- }
57896
-
57897
- // delete element entry, only show if allowed by rules
57898
- var deleteAllowed = rules.allowed('elements.delete', { elements: [ element ] });
57899
-
57900
- if (isArray$b(deleteAllowed)) {
57901
-
57902
- // was the element returned as a deletion candidate?
57903
- deleteAllowed = deleteAllowed[0] === element;
57904
- }
57905
-
57906
- if (deleteAllowed) {
57907
- assign$4(actions, {
57908
- 'delete': {
57909
- group: 'edit',
57910
- className: 'bpmn-icon-trash',
57911
- title: translate('Delete'),
57912
- action: {
57913
- click: removeElement
57914
- }
57915
- }
57916
- });
57917
- }
57918
-
57919
- return actions;
57920
- };
57921
-
57922
-
57923
- // helpers /////////
57924
-
57925
- /**
57926
- * @param {ModdleElement} businessObject
57927
- * @param {string} type
57928
- * @param {string} eventDefinitionType
57929
- *
57930
- * @return {boolean}
57931
- */
57932
- function isEventType(businessObject, type, eventDefinitionType) {
57933
-
57934
- var isType = businessObject.$instanceOf(type);
57935
- var isDefinition = false;
57936
-
57937
- var definitions = businessObject.eventDefinitions || [];
57938
- forEach$4(definitions, function(def) {
57939
- if (def.$type === eventDefinitionType) {
57940
- isDefinition = true;
57941
- }
57942
- });
57943
-
57944
- return isType && isDefinition;
57945
- }
57946
-
57947
- function includes$1(array, item) {
57948
- return array.indexOf(item) !== -1;
57421
+ /**
57422
+ * @typedef {import('didi').Injector} Injector
57423
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
57424
+ * @typedef {import('diagram-js/lib/features/context-pad/ContextPad').default} ContextPad
57425
+ * @typedef {import('../modeling/Modeling').default} Modeling
57426
+ * @typedef {import('../modeling/ElementFactory').default} ElementFactory
57427
+ * @typedef {import('diagram-js/lib/features/connect/Connect').default} Connect
57428
+ * @typedef {import('diagram-js/lib/features/create/Create').default} Create
57429
+ * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenu').default} PopupMenu
57430
+ * @typedef {import('diagram-js/lib/features/canvas/Canvas').default} Canvas
57431
+ * @typedef {import('diagram-js/lib/features/rules/Rules').default} Rules
57432
+ * @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
57433
+ *
57434
+ * @typedef {import('../../model/Types').Element} Element
57435
+ * @typedef {import('../../model/Types').ModdleElement} ModdleElement
57436
+ *
57437
+ * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').default<Element>} BaseContextPadProvider
57438
+ * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').ContextPadEntries} ContextPadEntries
57439
+ * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').ContextPadEntry} ContextPadEntry
57440
+ *
57441
+ * @typedef { { autoPlace?: boolean; } } ContextPadConfig
57442
+ */
57443
+
57444
+ /**
57445
+ * BPMN-specific context pad provider.
57446
+ *
57447
+ * @implements {BaseContextPadProvider}
57448
+ *
57449
+ * @param {ContextPadConfig} config
57450
+ * @param {Injector} injector
57451
+ * @param {EventBus} eventBus
57452
+ * @param {ContextPad} contextPad
57453
+ * @param {Modeling} modeling
57454
+ * @param {ElementFactory} elementFactory
57455
+ * @param {Connect} connect
57456
+ * @param {Create} create
57457
+ * @param {PopupMenu} popupMenu
57458
+ * @param {Canvas} canvas
57459
+ * @param {Rules} rules
57460
+ * @param {Translate} translate
57461
+ */
57462
+ function ContextPadProvider(
57463
+ config, injector, eventBus,
57464
+ contextPad, modeling, elementFactory,
57465
+ connect, create, popupMenu,
57466
+ canvas, rules, translate, appendPreview) {
57467
+
57468
+ config = config || {};
57469
+
57470
+ contextPad.registerProvider(this);
57471
+
57472
+ this._contextPad = contextPad;
57473
+
57474
+ this._modeling = modeling;
57475
+
57476
+ this._elementFactory = elementFactory;
57477
+ this._connect = connect;
57478
+ this._create = create;
57479
+ this._popupMenu = popupMenu;
57480
+ this._canvas = canvas;
57481
+ this._rules = rules;
57482
+ this._translate = translate;
57483
+ this._eventBus = eventBus;
57484
+ this._appendPreview = appendPreview;
57485
+
57486
+ if (config.autoPlace !== false) {
57487
+ this._autoPlace = injector.get('autoPlace', false);
57488
+ }
57489
+
57490
+ eventBus.on('create.end', 250, function(event) {
57491
+ var context = event.context,
57492
+ shape = context.shape;
57493
+
57494
+ if (!hasPrimaryModifier(event) || !contextPad.isOpen(shape)) {
57495
+ return;
57496
+ }
57497
+
57498
+ var entries = contextPad.getEntries(shape);
57499
+
57500
+ if (entries.replace) {
57501
+ entries.replace.action.click(event, shape);
57502
+ }
57503
+ });
57504
+
57505
+ eventBus.on('contextPad.close', function() {
57506
+ appendPreview.cleanUp();
57507
+ });
57508
+ }
57509
+
57510
+ ContextPadProvider.$inject = [
57511
+ 'config.contextPad',
57512
+ 'injector',
57513
+ 'eventBus',
57514
+ 'contextPad',
57515
+ 'modeling',
57516
+ 'elementFactory',
57517
+ 'connect',
57518
+ 'create',
57519
+ 'popupMenu',
57520
+ 'canvas',
57521
+ 'rules',
57522
+ 'translate',
57523
+ 'appendPreview'
57524
+ ];
57525
+
57526
+ /**
57527
+ * @param {Element[]} elements
57528
+ *
57529
+ * @return {ContextPadEntries}
57530
+ */
57531
+ ContextPadProvider.prototype.getMultiElementContextPadEntries = function(elements) {
57532
+ var modeling = this._modeling;
57533
+
57534
+ var actions = {};
57535
+
57536
+ if (this._isDeleteAllowed(elements)) {
57537
+ assign$4(actions, {
57538
+ 'delete': {
57539
+ group: 'edit',
57540
+ className: 'bpmn-icon-trash',
57541
+ title: this._translate('Delete'),
57542
+ action: {
57543
+ click: function(event, elements) {
57544
+ modeling.removeElements(elements.slice());
57545
+ }
57546
+ }
57547
+ }
57548
+ });
57549
+ }
57550
+
57551
+ return actions;
57552
+ };
57553
+
57554
+ /**
57555
+ * @param {Element[]} elements
57556
+ *
57557
+ * @return {boolean}
57558
+ */
57559
+ ContextPadProvider.prototype._isDeleteAllowed = function(elements) {
57560
+
57561
+ var baseAllowed = this._rules.allowed('elements.delete', {
57562
+ elements: elements
57563
+ });
57564
+
57565
+ if (isArray$b(baseAllowed)) {
57566
+ return every$1(baseAllowed, function(element) {
57567
+ return includes$1(baseAllowed, element);
57568
+ });
57569
+ }
57570
+
57571
+ return baseAllowed;
57572
+ };
57573
+
57574
+ /**
57575
+ * @param {Element} element
57576
+ *
57577
+ * @return {ContextPadEntries}
57578
+ */
57579
+ ContextPadProvider.prototype.getContextPadEntries = function(element) {
57580
+ var contextPad = this._contextPad,
57581
+ modeling = this._modeling,
57582
+ elementFactory = this._elementFactory,
57583
+ connect = this._connect,
57584
+ create = this._create,
57585
+ popupMenu = this._popupMenu,
57586
+ rules = this._rules,
57587
+ autoPlace = this._autoPlace,
57588
+ translate = this._translate,
57589
+ appendPreview = this._appendPreview;
57590
+
57591
+ var actions = {};
57592
+
57593
+ if (element.type === 'label') {
57594
+ return actions;
57595
+ }
57596
+
57597
+ var businessObject = element.businessObject;
57598
+
57599
+ function startConnect(event, element) {
57600
+ connect.start(event, element);
57601
+ }
57602
+
57603
+ function removeElement(e, element) {
57604
+ modeling.removeElements([ element ]);
57605
+ }
57606
+
57607
+ function getReplaceMenuPosition(element) {
57608
+
57609
+ var Y_OFFSET = 5;
57610
+
57611
+ var pad = contextPad.getPad(element).html;
57612
+
57613
+ var padRect = pad.getBoundingClientRect();
57614
+
57615
+ var pos = {
57616
+ x: padRect.left,
57617
+ y: padRect.bottom + Y_OFFSET
57618
+ };
57619
+
57620
+ return pos;
57621
+ }
57622
+
57623
+ /**
57624
+ * Create an append action.
57625
+ *
57626
+ * @param {string} type
57627
+ * @param {string} className
57628
+ * @param {string} title
57629
+ * @param {Object} [options]
57630
+ *
57631
+ * @return {ContextPadEntry}
57632
+ */
57633
+ function appendAction(type, className, title, options) {
57634
+
57635
+ function appendStart(event, element) {
57636
+
57637
+ var shape = elementFactory.createShape(assign$4({ type: type }, options));
57638
+
57639
+ create.start(event, shape, {
57640
+ source: element
57641
+ });
57642
+ }
57643
+
57644
+ var append = autoPlace ? function(_, element) {
57645
+ var shape = elementFactory.createShape(assign$4({ type: type }, options));
57646
+
57647
+ autoPlace.append(element, shape);
57648
+ } : appendStart;
57649
+
57650
+ var previewAppend = autoPlace ? function(_, element) {
57651
+
57652
+ // mouseover
57653
+ appendPreview.create(element, type, options);
57654
+
57655
+ return () => {
57656
+
57657
+ // mouseout
57658
+ appendPreview.cleanUp();
57659
+ };
57660
+ } : null;
57661
+
57662
+ return {
57663
+ group: 'model',
57664
+ className: className,
57665
+ title: title,
57666
+ action: {
57667
+ dragstart: appendStart,
57668
+ click: append,
57669
+ hover: previewAppend
57670
+ }
57671
+ };
57672
+ }
57673
+
57674
+ function splitLaneHandler(count) {
57675
+
57676
+ return function(_, element) {
57677
+
57678
+ // actual split
57679
+ modeling.splitLane(element, count);
57680
+
57681
+ // refresh context pad after split to
57682
+ // get rid of split icons
57683
+ contextPad.open(element, true);
57684
+ };
57685
+ }
57686
+
57687
+
57688
+ if (isAny$1(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded$1(element)) {
57689
+
57690
+ var childLanes = getChildLanes(element);
57691
+
57692
+ assign$4(actions, {
57693
+ 'lane-insert-above': {
57694
+ group: 'lane-insert-above',
57695
+ className: 'bpmn-icon-lane-insert-above',
57696
+ title: translate('Add lane above'),
57697
+ action: {
57698
+ click: function(event, element) {
57699
+ modeling.addLane(element, 'top');
57700
+ }
57701
+ }
57702
+ }
57703
+ });
57704
+
57705
+ if (childLanes.length < 2) {
57706
+
57707
+ if (isHorizontal$3(element) ? element.height >= 120 : element.width >= 120) {
57708
+ assign$4(actions, {
57709
+ 'lane-divide-two': {
57710
+ group: 'lane-divide',
57711
+ className: 'bpmn-icon-lane-divide-two',
57712
+ title: translate('Divide into two lanes'),
57713
+ action: {
57714
+ click: splitLaneHandler(2)
57715
+ }
57716
+ }
57717
+ });
57718
+ }
57719
+
57720
+ if (isHorizontal$3(element) ? element.height >= 180 : element.width >= 180) {
57721
+ assign$4(actions, {
57722
+ 'lane-divide-three': {
57723
+ group: 'lane-divide',
57724
+ className: 'bpmn-icon-lane-divide-three',
57725
+ title: translate('Divide into three lanes'),
57726
+ action: {
57727
+ click: splitLaneHandler(3)
57728
+ }
57729
+ }
57730
+ });
57731
+ }
57732
+ }
57733
+
57734
+ assign$4(actions, {
57735
+ 'lane-insert-below': {
57736
+ group: 'lane-insert-below',
57737
+ className: 'bpmn-icon-lane-insert-below',
57738
+ title: translate('Add lane below'),
57739
+ action: {
57740
+ click: function(event, element) {
57741
+ modeling.addLane(element, 'bottom');
57742
+ }
57743
+ }
57744
+ }
57745
+ });
57746
+
57747
+ }
57748
+
57749
+ if (is$6(businessObject, 'bpmn:FlowNode')) {
57750
+
57751
+ if (is$6(businessObject, 'bpmn:EventBasedGateway')) {
57752
+
57753
+ assign$4(actions, {
57754
+ 'append.receive-task': appendAction(
57755
+ 'bpmn:ReceiveTask',
57756
+ 'bpmn-icon-receive-task',
57757
+ translate('Append receive task')
57758
+ ),
57759
+ 'append.message-intermediate-event': appendAction(
57760
+ 'bpmn:IntermediateCatchEvent',
57761
+ 'bpmn-icon-intermediate-event-catch-message',
57762
+ translate('Append message intermediate catch event'),
57763
+ { eventDefinitionType: 'bpmn:MessageEventDefinition' }
57764
+ ),
57765
+ 'append.timer-intermediate-event': appendAction(
57766
+ 'bpmn:IntermediateCatchEvent',
57767
+ 'bpmn-icon-intermediate-event-catch-timer',
57768
+ translate('Append timer intermediate catch event'),
57769
+ { eventDefinitionType: 'bpmn:TimerEventDefinition' }
57770
+ ),
57771
+ 'append.condition-intermediate-event': appendAction(
57772
+ 'bpmn:IntermediateCatchEvent',
57773
+ 'bpmn-icon-intermediate-event-catch-condition',
57774
+ translate('Append conditional intermediate catch event'),
57775
+ { eventDefinitionType: 'bpmn:ConditionalEventDefinition' }
57776
+ ),
57777
+ 'append.signal-intermediate-event': appendAction(
57778
+ 'bpmn:IntermediateCatchEvent',
57779
+ 'bpmn-icon-intermediate-event-catch-signal',
57780
+ translate('Append signal intermediate catch event'),
57781
+ { eventDefinitionType: 'bpmn:SignalEventDefinition' }
57782
+ )
57783
+ });
57784
+ } else
57785
+
57786
+ if (isEventType(businessObject, 'bpmn:BoundaryEvent', 'bpmn:CompensateEventDefinition')) {
57787
+
57788
+ assign$4(actions, {
57789
+ 'append.compensation-activity':
57790
+ appendAction(
57791
+ 'bpmn:Task',
57792
+ 'bpmn-icon-task',
57793
+ translate('Append compensation activity'),
57794
+ {
57795
+ isForCompensation: true
57796
+ }
57797
+ )
57798
+ });
57799
+ } else
57800
+
57801
+ if (!is$6(businessObject, 'bpmn:EndEvent') &&
57802
+ !businessObject.isForCompensation &&
57803
+ !isEventType(businessObject, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') &&
57804
+ !isEventSubProcess(businessObject)) {
57805
+
57806
+ assign$4(actions, {
57807
+ 'append.end-event': appendAction(
57808
+ 'bpmn:EndEvent',
57809
+ 'bpmn-icon-end-event-none',
57810
+ translate('Append end event')
57811
+ ),
57812
+ 'append.gateway': appendAction(
57813
+ 'bpmn:ExclusiveGateway',
57814
+ 'bpmn-icon-gateway-none',
57815
+ translate('Append gateway')
57816
+ ),
57817
+ 'append.append-task': appendAction(
57818
+ 'bpmn:Task',
57819
+ 'bpmn-icon-task',
57820
+ translate('Append task')
57821
+ ),
57822
+ 'append.intermediate-event': appendAction(
57823
+ 'bpmn:IntermediateThrowEvent',
57824
+ 'bpmn-icon-intermediate-event-none',
57825
+ translate('Append intermediate/boundary event')
57826
+ )
57827
+ });
57828
+ }
57829
+ }
57830
+
57831
+ if (!popupMenu.isEmpty(element, 'bpmn-replace')) {
57832
+
57833
+ // Replace menu entry
57834
+ assign$4(actions, {
57835
+ 'replace': {
57836
+ group: 'edit',
57837
+ className: 'bpmn-icon-screw-wrench',
57838
+ title: translate('Change element'),
57839
+ action: {
57840
+ click: function(event, element) {
57841
+
57842
+ var position = assign$4(getReplaceMenuPosition(element), {
57843
+ cursor: { x: event.x, y: event.y }
57844
+ });
57845
+
57846
+ popupMenu.open(element, 'bpmn-replace', position, {
57847
+ title: translate('Change element'),
57848
+ width: 300,
57849
+ search: true
57850
+ });
57851
+ }
57852
+ }
57853
+ }
57854
+ });
57855
+ }
57856
+
57857
+ if (is$6(businessObject, 'bpmn:SequenceFlow')) {
57858
+ assign$4(actions, {
57859
+ 'append.text-annotation': appendAction(
57860
+ 'bpmn:TextAnnotation',
57861
+ 'bpmn-icon-text-annotation',
57862
+ translate('Add text annotation')
57863
+ )
57864
+ });
57865
+ }
57866
+
57867
+ if (
57868
+ isAny$1(businessObject, [
57869
+ 'bpmn:FlowNode',
57870
+ 'bpmn:InteractionNode',
57871
+ 'bpmn:DataObjectReference',
57872
+ 'bpmn:DataStoreReference',
57873
+ ])
57874
+ ) {
57875
+ assign$4(actions, {
57876
+ 'append.text-annotation': appendAction(
57877
+ 'bpmn:TextAnnotation',
57878
+ 'bpmn-icon-text-annotation',
57879
+ translate('Add text annotation')
57880
+ ),
57881
+ 'connect': {
57882
+ group: 'connect',
57883
+ className: 'bpmn-icon-connection-multi',
57884
+ title: translate('Connect to other element'),
57885
+ action: {
57886
+ click: startConnect,
57887
+ dragstart: startConnect,
57888
+ },
57889
+ },
57890
+ });
57891
+ }
57892
+
57893
+ if (is$6(businessObject, 'bpmn:TextAnnotation')) {
57894
+ assign$4(actions, {
57895
+ 'connect': {
57896
+ group: 'connect',
57897
+ className: 'bpmn-icon-connection-multi',
57898
+ title: translate('Connect using association'),
57899
+ action: {
57900
+ click: startConnect,
57901
+ dragstart: startConnect,
57902
+ },
57903
+ },
57904
+ });
57905
+ }
57906
+
57907
+ if (isAny$1(businessObject, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ])) {
57908
+ assign$4(actions, {
57909
+ 'connect': {
57910
+ group: 'connect',
57911
+ className: 'bpmn-icon-connection-multi',
57912
+ title: translate('Connect using data input association'),
57913
+ action: {
57914
+ click: startConnect,
57915
+ dragstart: startConnect
57916
+ }
57917
+ }
57918
+ });
57919
+ }
57920
+
57921
+ if (is$6(businessObject, 'bpmn:Group')) {
57922
+ assign$4(actions, {
57923
+ 'append.text-annotation': appendAction(
57924
+ 'bpmn:TextAnnotation',
57925
+ 'bpmn-icon-text-annotation',
57926
+ translate('Add text annotation')
57927
+ )
57928
+ });
57929
+ }
57930
+
57931
+ // delete element entry, only show if allowed by rules
57932
+ var deleteAllowed = rules.allowed('elements.delete', { elements: [ element ] });
57933
+
57934
+ if (isArray$b(deleteAllowed)) {
57935
+
57936
+ // was the element returned as a deletion candidate?
57937
+ deleteAllowed = deleteAllowed[0] === element;
57938
+ }
57939
+
57940
+ if (deleteAllowed) {
57941
+ assign$4(actions, {
57942
+ 'delete': {
57943
+ group: 'edit',
57944
+ className: 'bpmn-icon-trash',
57945
+ title: translate('Delete'),
57946
+ action: {
57947
+ click: removeElement
57948
+ }
57949
+ }
57950
+ });
57951
+ }
57952
+
57953
+ return actions;
57954
+ };
57955
+
57956
+
57957
+ // helpers /////////
57958
+
57959
+ /**
57960
+ * @param {ModdleElement} businessObject
57961
+ * @param {string} type
57962
+ * @param {string} eventDefinitionType
57963
+ *
57964
+ * @return {boolean}
57965
+ */
57966
+ function isEventType(businessObject, type, eventDefinitionType) {
57967
+
57968
+ var isType = businessObject.$instanceOf(type);
57969
+ var isDefinition = false;
57970
+
57971
+ var definitions = businessObject.eventDefinitions || [];
57972
+ forEach$4(definitions, function(def) {
57973
+ if (def.$type === eventDefinitionType) {
57974
+ isDefinition = true;
57975
+ }
57976
+ });
57977
+
57978
+ return isType && isDefinition;
57979
+ }
57980
+
57981
+ function includes$1(array, item) {
57982
+ return array.indexOf(item) !== -1;
57949
57983
  }
57950
57984
 
57951
57985
  var ContextPadModule = {