camunda-bpmn-js 4.6.0 → 4.6.1

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