bpmn-js 17.6.2 → 17.6.4

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v17.6.2
2
+ * bpmn-js - bpmn-modeler v17.6.4
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2024-05-08
11
+ * Date: 2024-05-09
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -26976,6 +26976,8 @@
26976
26976
  alignElements: [ 'type', AlignElements$1 ]
26977
26977
  };
26978
26978
 
26979
+ var MARKER_HIDDEN$1 = 'djs-element-hidden';
26980
+
26979
26981
  /**
26980
26982
  * @typedef {import('../../model/Types').Element} Element
26981
26983
  *
@@ -27087,9 +27089,11 @@
27087
27089
  });
27088
27090
 
27089
27091
  this._eventBus.on('canvas.viewbox.changed', () => {
27090
- if (this.isOpen()) {
27091
- this._updatePosition();
27092
- }
27092
+ this._updatePosition();
27093
+ });
27094
+
27095
+ this._eventBus.on('element.marker.update', function(event) {
27096
+ self._updateVisibility();
27093
27097
  });
27094
27098
 
27095
27099
  this._container = this._createContainer();
@@ -27340,6 +27344,8 @@
27340
27344
 
27341
27345
  this._updatePosition();
27342
27346
 
27347
+ this._updateVisibility();
27348
+
27343
27349
  this._eventBus.fire('contextPad.open', { current: this._current });
27344
27350
  };
27345
27351
 
@@ -27481,6 +27487,8 @@
27481
27487
 
27482
27488
  classes$1(this._current.html).add('open');
27483
27489
 
27490
+ this._updatePosition();
27491
+
27484
27492
  this._eventBus.fire('contextPad.show', { current: this._current });
27485
27493
  };
27486
27494
 
@@ -27565,6 +27573,32 @@
27565
27573
  }
27566
27574
  };
27567
27575
 
27576
+ /**
27577
+ * Update context pad visibility. Hide if any of the target elements is hidden
27578
+ * using the `djs-element-hidden` or `djs-label-hidden` markers.
27579
+ */
27580
+ ContextPad.prototype._updateVisibility = function() {
27581
+ if (!this.isOpen()) {
27582
+ return;
27583
+ }
27584
+
27585
+ var self = this;
27586
+
27587
+ var target = this._current.target;
27588
+
27589
+ var targets = isArray$3(target) ? target : [ target ];
27590
+
27591
+ var isHidden = targets.some(function(target) {
27592
+ return self._canvas.hasMarker(target, MARKER_HIDDEN$1);
27593
+ });
27594
+
27595
+ if (isHidden) {
27596
+ self.hide();
27597
+ } else {
27598
+ self.show();
27599
+ }
27600
+ };
27601
+
27568
27602
  /**
27569
27603
  * Get bounding client rect of target element(s).
27570
27604
  *
@@ -56658,568 +56692,568 @@
56658
56692
  replaceMenuProvider: [ 'type', ReplaceMenuProvider ]
56659
56693
  };
56660
56694
 
56661
- /**
56662
- * @typedef {import('didi').Injector} Injector
56663
- * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
56664
- * @typedef {import('diagram-js/lib/features/context-pad/ContextPad').default} ContextPad
56665
- * @typedef {import('../modeling/Modeling').default} Modeling
56666
- * @typedef {import('../modeling/ElementFactory').default} ElementFactory
56667
- * @typedef {import('diagram-js/lib/features/connect/Connect').default} Connect
56668
- * @typedef {import('diagram-js/lib/features/create/Create').default} Create
56669
- * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenu').default} PopupMenu
56670
- * @typedef {import('diagram-js/lib/features/canvas/Canvas').default} Canvas
56671
- * @typedef {import('diagram-js/lib/features/rules/Rules').default} Rules
56672
- * @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
56673
- *
56674
- * @typedef {import('../../model/Types').Element} Element
56675
- * @typedef {import('../../model/Types').ModdleElement} ModdleElement
56676
- *
56677
- * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').default<Element>} BaseContextPadProvider
56678
- * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').ContextPadEntries} ContextPadEntries
56679
- * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').ContextPadEntry} ContextPadEntry
56680
- *
56681
- * @typedef { { autoPlace?: boolean; } } ContextPadConfig
56682
- */
56683
-
56684
- /**
56685
- * BPMN-specific context pad provider.
56686
- *
56687
- * @implements {BaseContextPadProvider}
56688
- *
56689
- * @param {ContextPadConfig} config
56690
- * @param {Injector} injector
56691
- * @param {EventBus} eventBus
56692
- * @param {ContextPad} contextPad
56693
- * @param {Modeling} modeling
56694
- * @param {ElementFactory} elementFactory
56695
- * @param {Connect} connect
56696
- * @param {Create} create
56697
- * @param {PopupMenu} popupMenu
56698
- * @param {Canvas} canvas
56699
- * @param {Rules} rules
56700
- * @param {Translate} translate
56701
- */
56702
- function ContextPadProvider(
56703
- config, injector, eventBus,
56704
- contextPad, modeling, elementFactory,
56705
- connect, create, popupMenu,
56706
- canvas, rules, translate, appendPreview) {
56707
-
56708
- config = config || {};
56709
-
56710
- contextPad.registerProvider(this);
56711
-
56712
- this._contextPad = contextPad;
56713
-
56714
- this._modeling = modeling;
56715
-
56716
- this._elementFactory = elementFactory;
56717
- this._connect = connect;
56718
- this._create = create;
56719
- this._popupMenu = popupMenu;
56720
- this._canvas = canvas;
56721
- this._rules = rules;
56722
- this._translate = translate;
56723
- this._eventBus = eventBus;
56724
- this._appendPreview = appendPreview;
56725
-
56726
- if (config.autoPlace !== false) {
56727
- this._autoPlace = injector.get('autoPlace', false);
56728
- }
56729
-
56730
- eventBus.on('create.end', 250, function(event) {
56731
- var context = event.context,
56732
- shape = context.shape;
56733
-
56734
- if (!hasPrimaryModifier(event) || !contextPad.isOpen(shape)) {
56735
- return;
56736
- }
56737
-
56738
- var entries = contextPad.getEntries(shape);
56739
-
56740
- if (entries.replace) {
56741
- entries.replace.action.click(event, shape);
56742
- }
56743
- });
56744
-
56745
- eventBus.on('contextPad.close', function() {
56746
- appendPreview.cleanUp();
56747
- });
56748
- }
56749
-
56750
- ContextPadProvider.$inject = [
56751
- 'config.contextPad',
56752
- 'injector',
56753
- 'eventBus',
56754
- 'contextPad',
56755
- 'modeling',
56756
- 'elementFactory',
56757
- 'connect',
56758
- 'create',
56759
- 'popupMenu',
56760
- 'canvas',
56761
- 'rules',
56762
- 'translate',
56763
- 'appendPreview'
56764
- ];
56765
-
56766
- /**
56767
- * @param {Element[]} elements
56768
- *
56769
- * @return {ContextPadEntries}
56770
- */
56771
- ContextPadProvider.prototype.getMultiElementContextPadEntries = function(elements) {
56772
- var modeling = this._modeling;
56773
-
56774
- var actions = {};
56775
-
56776
- if (this._isDeleteAllowed(elements)) {
56777
- assign$1(actions, {
56778
- 'delete': {
56779
- group: 'edit',
56780
- className: 'bpmn-icon-trash',
56781
- title: this._translate('Delete'),
56782
- action: {
56783
- click: function(event, elements) {
56784
- modeling.removeElements(elements.slice());
56785
- }
56786
- }
56787
- }
56788
- });
56789
- }
56790
-
56791
- return actions;
56792
- };
56793
-
56794
- /**
56795
- * @param {Element[]} elements
56796
- *
56797
- * @return {boolean}
56798
- */
56799
- ContextPadProvider.prototype._isDeleteAllowed = function(elements) {
56800
-
56801
- var baseAllowed = this._rules.allowed('elements.delete', {
56802
- elements: elements
56803
- });
56804
-
56805
- if (isArray$3(baseAllowed)) {
56806
- return every(baseAllowed, function(element) {
56807
- return includes$1(baseAllowed, element);
56808
- });
56809
- }
56810
-
56811
- return baseAllowed;
56812
- };
56813
-
56814
- /**
56815
- * @param {Element} element
56816
- *
56817
- * @return {ContextPadEntries}
56818
- */
56819
- ContextPadProvider.prototype.getContextPadEntries = function(element) {
56820
- var contextPad = this._contextPad,
56821
- modeling = this._modeling,
56822
- elementFactory = this._elementFactory,
56823
- connect = this._connect,
56824
- create = this._create,
56825
- popupMenu = this._popupMenu,
56826
- rules = this._rules,
56827
- autoPlace = this._autoPlace,
56828
- translate = this._translate,
56829
- appendPreview = this._appendPreview;
56830
-
56831
- var actions = {};
56832
-
56833
- if (element.type === 'label') {
56834
- return actions;
56835
- }
56836
-
56837
- var businessObject = element.businessObject;
56838
-
56839
- function startConnect(event, element) {
56840
- connect.start(event, element);
56841
- }
56842
-
56843
- function removeElement(e, element) {
56844
- modeling.removeElements([ element ]);
56845
- }
56846
-
56847
- function getReplaceMenuPosition(element) {
56848
-
56849
- var Y_OFFSET = 5;
56850
-
56851
- var pad = contextPad.getPad(element).html;
56852
-
56853
- var padRect = pad.getBoundingClientRect();
56854
-
56855
- var pos = {
56856
- x: padRect.left,
56857
- y: padRect.bottom + Y_OFFSET
56858
- };
56859
-
56860
- return pos;
56861
- }
56862
-
56863
- /**
56864
- * Create an append action.
56865
- *
56866
- * @param {string} type
56867
- * @param {string} className
56868
- * @param {string} title
56869
- * @param {Object} [options]
56870
- *
56871
- * @return {ContextPadEntry}
56872
- */
56873
- function appendAction(type, className, title, options) {
56874
-
56875
- function appendStart(event, element) {
56876
-
56877
- var shape = elementFactory.createShape(assign$1({ type: type }, options));
56878
-
56879
- create.start(event, shape, {
56880
- source: element
56881
- });
56882
- }
56883
-
56884
- var append = autoPlace ? function(_, element) {
56885
- var shape = elementFactory.createShape(assign$1({ type: type }, options));
56886
-
56887
- autoPlace.append(element, shape);
56888
- } : appendStart;
56889
-
56890
- var previewAppend = autoPlace ? function(_, element) {
56891
-
56892
- // mouseover
56893
- appendPreview.create(element, type, options);
56894
-
56895
- return () => {
56896
-
56897
- // mouseout
56898
- appendPreview.cleanUp();
56899
- };
56900
- } : null;
56901
-
56902
- return {
56903
- group: 'model',
56904
- className: className,
56905
- title: title,
56906
- action: {
56907
- dragstart: appendStart,
56908
- click: append,
56909
- hover: previewAppend
56910
- }
56911
- };
56912
- }
56913
-
56914
- function splitLaneHandler(count) {
56915
-
56916
- return function(_, element) {
56917
-
56918
- // actual split
56919
- modeling.splitLane(element, count);
56920
-
56921
- // refresh context pad after split to
56922
- // get rid of split icons
56923
- contextPad.open(element, true);
56924
- };
56925
- }
56926
-
56927
-
56928
- if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded(element)) {
56929
-
56930
- var childLanes = getChildLanes(element);
56931
-
56932
- assign$1(actions, {
56933
- 'lane-insert-above': {
56934
- group: 'lane-insert-above',
56935
- className: 'bpmn-icon-lane-insert-above',
56936
- title: translate('Add lane above'),
56937
- action: {
56938
- click: function(event, element) {
56939
- modeling.addLane(element, 'top');
56940
- }
56941
- }
56942
- }
56943
- });
56944
-
56945
- if (childLanes.length < 2) {
56946
-
56947
- if (isHorizontal$3(element) ? element.height >= 120 : element.width >= 120) {
56948
- assign$1(actions, {
56949
- 'lane-divide-two': {
56950
- group: 'lane-divide',
56951
- className: 'bpmn-icon-lane-divide-two',
56952
- title: translate('Divide into two lanes'),
56953
- action: {
56954
- click: splitLaneHandler(2)
56955
- }
56956
- }
56957
- });
56958
- }
56959
-
56960
- if (isHorizontal$3(element) ? element.height >= 180 : element.width >= 180) {
56961
- assign$1(actions, {
56962
- 'lane-divide-three': {
56963
- group: 'lane-divide',
56964
- className: 'bpmn-icon-lane-divide-three',
56965
- title: translate('Divide into three lanes'),
56966
- action: {
56967
- click: splitLaneHandler(3)
56968
- }
56969
- }
56970
- });
56971
- }
56972
- }
56973
-
56974
- assign$1(actions, {
56975
- 'lane-insert-below': {
56976
- group: 'lane-insert-below',
56977
- className: 'bpmn-icon-lane-insert-below',
56978
- title: translate('Add lane below'),
56979
- action: {
56980
- click: function(event, element) {
56981
- modeling.addLane(element, 'bottom');
56982
- }
56983
- }
56984
- }
56985
- });
56986
-
56987
- }
56988
-
56989
- if (is$1(businessObject, 'bpmn:FlowNode')) {
56990
-
56991
- if (is$1(businessObject, 'bpmn:EventBasedGateway')) {
56992
-
56993
- assign$1(actions, {
56994
- 'append.receive-task': appendAction(
56995
- 'bpmn:ReceiveTask',
56996
- 'bpmn-icon-receive-task',
56997
- translate('Append receive task')
56998
- ),
56999
- 'append.message-intermediate-event': appendAction(
57000
- 'bpmn:IntermediateCatchEvent',
57001
- 'bpmn-icon-intermediate-event-catch-message',
57002
- translate('Append message intermediate catch event'),
57003
- { eventDefinitionType: 'bpmn:MessageEventDefinition' }
57004
- ),
57005
- 'append.timer-intermediate-event': appendAction(
57006
- 'bpmn:IntermediateCatchEvent',
57007
- 'bpmn-icon-intermediate-event-catch-timer',
57008
- translate('Append timer intermediate catch event'),
57009
- { eventDefinitionType: 'bpmn:TimerEventDefinition' }
57010
- ),
57011
- 'append.condition-intermediate-event': appendAction(
57012
- 'bpmn:IntermediateCatchEvent',
57013
- 'bpmn-icon-intermediate-event-catch-condition',
57014
- translate('Append conditional intermediate catch event'),
57015
- { eventDefinitionType: 'bpmn:ConditionalEventDefinition' }
57016
- ),
57017
- 'append.signal-intermediate-event': appendAction(
57018
- 'bpmn:IntermediateCatchEvent',
57019
- 'bpmn-icon-intermediate-event-catch-signal',
57020
- translate('Append signal intermediate catch event'),
57021
- { eventDefinitionType: 'bpmn:SignalEventDefinition' }
57022
- )
57023
- });
57024
- } else
57025
-
57026
- if (isEventType(businessObject, 'bpmn:BoundaryEvent', 'bpmn:CompensateEventDefinition')) {
57027
-
57028
- assign$1(actions, {
57029
- 'append.compensation-activity':
57030
- appendAction(
57031
- 'bpmn:Task',
57032
- 'bpmn-icon-task',
57033
- translate('Append compensation activity'),
57034
- {
57035
- isForCompensation: true
57036
- }
57037
- )
57038
- });
57039
- } else
57040
-
57041
- if (!is$1(businessObject, 'bpmn:EndEvent') &&
57042
- !businessObject.isForCompensation &&
57043
- !isEventType(businessObject, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') &&
57044
- !isEventSubProcess(businessObject)) {
57045
-
57046
- assign$1(actions, {
57047
- 'append.end-event': appendAction(
57048
- 'bpmn:EndEvent',
57049
- 'bpmn-icon-end-event-none',
57050
- translate('Append end event')
57051
- ),
57052
- 'append.gateway': appendAction(
57053
- 'bpmn:ExclusiveGateway',
57054
- 'bpmn-icon-gateway-none',
57055
- translate('Append gateway')
57056
- ),
57057
- 'append.append-task': appendAction(
57058
- 'bpmn:Task',
57059
- 'bpmn-icon-task',
57060
- translate('Append task')
57061
- ),
57062
- 'append.intermediate-event': appendAction(
57063
- 'bpmn:IntermediateThrowEvent',
57064
- 'bpmn-icon-intermediate-event-none',
57065
- translate('Append intermediate/boundary event')
57066
- )
57067
- });
57068
- }
57069
- }
57070
-
57071
- if (!popupMenu.isEmpty(element, 'bpmn-replace')) {
57072
-
57073
- // Replace menu entry
57074
- assign$1(actions, {
57075
- 'replace': {
57076
- group: 'edit',
57077
- className: 'bpmn-icon-screw-wrench',
57078
- title: translate('Change element'),
57079
- action: {
57080
- click: function(event, element) {
57081
-
57082
- var position = assign$1(getReplaceMenuPosition(element), {
57083
- cursor: { x: event.x, y: event.y }
57084
- });
57085
-
57086
- popupMenu.open(element, 'bpmn-replace', position, {
57087
- title: translate('Change element'),
57088
- width: 300,
57089
- search: true
57090
- });
57091
- }
57092
- }
57093
- }
57094
- });
57095
- }
57096
-
57097
- if (is$1(businessObject, 'bpmn:SequenceFlow')) {
57098
- assign$1(actions, {
57099
- 'append.text-annotation': appendAction(
57100
- 'bpmn:TextAnnotation',
57101
- 'bpmn-icon-text-annotation',
57102
- translate('Add text annotation')
57103
- )
57104
- });
57105
- }
57106
-
57107
- if (
57108
- isAny(businessObject, [
57109
- 'bpmn:FlowNode',
57110
- 'bpmn:InteractionNode',
57111
- 'bpmn:DataObjectReference',
57112
- 'bpmn:DataStoreReference',
57113
- ])
57114
- ) {
57115
- assign$1(actions, {
57116
- 'append.text-annotation': appendAction(
57117
- 'bpmn:TextAnnotation',
57118
- 'bpmn-icon-text-annotation',
57119
- translate('Add text annotation')
57120
- ),
57121
- 'connect': {
57122
- group: 'connect',
57123
- className: 'bpmn-icon-connection-multi',
57124
- title: translate('Connect to other element'),
57125
- action: {
57126
- click: startConnect,
57127
- dragstart: startConnect,
57128
- },
57129
- },
57130
- });
57131
- }
57132
-
57133
- if (is$1(businessObject, 'bpmn:TextAnnotation')) {
57134
- assign$1(actions, {
57135
- 'connect': {
57136
- group: 'connect',
57137
- className: 'bpmn-icon-connection-multi',
57138
- title: translate('Connect using association'),
57139
- action: {
57140
- click: startConnect,
57141
- dragstart: startConnect,
57142
- },
57143
- },
57144
- });
57145
- }
57146
-
57147
- if (isAny(businessObject, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ])) {
57148
- assign$1(actions, {
57149
- 'connect': {
57150
- group: 'connect',
57151
- className: 'bpmn-icon-connection-multi',
57152
- title: translate('Connect using data input association'),
57153
- action: {
57154
- click: startConnect,
57155
- dragstart: startConnect
57156
- }
57157
- }
57158
- });
57159
- }
57160
-
57161
- if (is$1(businessObject, 'bpmn:Group')) {
57162
- assign$1(actions, {
57163
- 'append.text-annotation': appendAction(
57164
- 'bpmn:TextAnnotation',
57165
- 'bpmn-icon-text-annotation',
57166
- translate('Add text annotation')
57167
- )
57168
- });
57169
- }
57170
-
57171
- // delete element entry, only show if allowed by rules
57172
- var deleteAllowed = rules.allowed('elements.delete', { elements: [ element ] });
57173
-
57174
- if (isArray$3(deleteAllowed)) {
57175
-
57176
- // was the element returned as a deletion candidate?
57177
- deleteAllowed = deleteAllowed[0] === element;
57178
- }
57179
-
57180
- if (deleteAllowed) {
57181
- assign$1(actions, {
57182
- 'delete': {
57183
- group: 'edit',
57184
- className: 'bpmn-icon-trash',
57185
- title: translate('Delete'),
57186
- action: {
57187
- click: removeElement
57188
- }
57189
- }
57190
- });
57191
- }
57192
-
57193
- return actions;
57194
- };
57195
-
57196
-
57197
- // helpers /////////
57198
-
57199
- /**
57200
- * @param {ModdleElement} businessObject
57201
- * @param {string} type
57202
- * @param {string} eventDefinitionType
57203
- *
57204
- * @return {boolean}
57205
- */
57206
- function isEventType(businessObject, type, eventDefinitionType) {
57207
-
57208
- var isType = businessObject.$instanceOf(type);
57209
- var isDefinition = false;
57210
-
57211
- var definitions = businessObject.eventDefinitions || [];
57212
- forEach$1(definitions, function(def) {
57213
- if (def.$type === eventDefinitionType) {
57214
- isDefinition = true;
57215
- }
57216
- });
57217
-
57218
- return isType && isDefinition;
57219
- }
57220
-
57221
- function includes$1(array, item) {
57222
- return array.indexOf(item) !== -1;
56695
+ /**
56696
+ * @typedef {import('didi').Injector} Injector
56697
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
56698
+ * @typedef {import('diagram-js/lib/features/context-pad/ContextPad').default} ContextPad
56699
+ * @typedef {import('../modeling/Modeling').default} Modeling
56700
+ * @typedef {import('../modeling/ElementFactory').default} ElementFactory
56701
+ * @typedef {import('diagram-js/lib/features/connect/Connect').default} Connect
56702
+ * @typedef {import('diagram-js/lib/features/create/Create').default} Create
56703
+ * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenu').default} PopupMenu
56704
+ * @typedef {import('diagram-js/lib/features/canvas/Canvas').default} Canvas
56705
+ * @typedef {import('diagram-js/lib/features/rules/Rules').default} Rules
56706
+ * @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
56707
+ *
56708
+ * @typedef {import('../../model/Types').Element} Element
56709
+ * @typedef {import('../../model/Types').ModdleElement} ModdleElement
56710
+ *
56711
+ * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').default<Element>} BaseContextPadProvider
56712
+ * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').ContextPadEntries} ContextPadEntries
56713
+ * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').ContextPadEntry} ContextPadEntry
56714
+ *
56715
+ * @typedef { { autoPlace?: boolean; } } ContextPadConfig
56716
+ */
56717
+
56718
+ /**
56719
+ * BPMN-specific context pad provider.
56720
+ *
56721
+ * @implements {BaseContextPadProvider}
56722
+ *
56723
+ * @param {ContextPadConfig} config
56724
+ * @param {Injector} injector
56725
+ * @param {EventBus} eventBus
56726
+ * @param {ContextPad} contextPad
56727
+ * @param {Modeling} modeling
56728
+ * @param {ElementFactory} elementFactory
56729
+ * @param {Connect} connect
56730
+ * @param {Create} create
56731
+ * @param {PopupMenu} popupMenu
56732
+ * @param {Canvas} canvas
56733
+ * @param {Rules} rules
56734
+ * @param {Translate} translate
56735
+ */
56736
+ function ContextPadProvider(
56737
+ config, injector, eventBus,
56738
+ contextPad, modeling, elementFactory,
56739
+ connect, create, popupMenu,
56740
+ canvas, rules, translate, appendPreview) {
56741
+
56742
+ config = config || {};
56743
+
56744
+ contextPad.registerProvider(this);
56745
+
56746
+ this._contextPad = contextPad;
56747
+
56748
+ this._modeling = modeling;
56749
+
56750
+ this._elementFactory = elementFactory;
56751
+ this._connect = connect;
56752
+ this._create = create;
56753
+ this._popupMenu = popupMenu;
56754
+ this._canvas = canvas;
56755
+ this._rules = rules;
56756
+ this._translate = translate;
56757
+ this._eventBus = eventBus;
56758
+ this._appendPreview = appendPreview;
56759
+
56760
+ if (config.autoPlace !== false) {
56761
+ this._autoPlace = injector.get('autoPlace', false);
56762
+ }
56763
+
56764
+ eventBus.on('create.end', 250, function(event) {
56765
+ var context = event.context,
56766
+ shape = context.shape;
56767
+
56768
+ if (!hasPrimaryModifier(event) || !contextPad.isOpen(shape)) {
56769
+ return;
56770
+ }
56771
+
56772
+ var entries = contextPad.getEntries(shape);
56773
+
56774
+ if (entries.replace) {
56775
+ entries.replace.action.click(event, shape);
56776
+ }
56777
+ });
56778
+
56779
+ eventBus.on('contextPad.close', function() {
56780
+ appendPreview.cleanUp();
56781
+ });
56782
+ }
56783
+
56784
+ ContextPadProvider.$inject = [
56785
+ 'config.contextPad',
56786
+ 'injector',
56787
+ 'eventBus',
56788
+ 'contextPad',
56789
+ 'modeling',
56790
+ 'elementFactory',
56791
+ 'connect',
56792
+ 'create',
56793
+ 'popupMenu',
56794
+ 'canvas',
56795
+ 'rules',
56796
+ 'translate',
56797
+ 'appendPreview'
56798
+ ];
56799
+
56800
+ /**
56801
+ * @param {Element[]} elements
56802
+ *
56803
+ * @return {ContextPadEntries}
56804
+ */
56805
+ ContextPadProvider.prototype.getMultiElementContextPadEntries = function(elements) {
56806
+ var modeling = this._modeling;
56807
+
56808
+ var actions = {};
56809
+
56810
+ if (this._isDeleteAllowed(elements)) {
56811
+ assign$1(actions, {
56812
+ 'delete': {
56813
+ group: 'edit',
56814
+ className: 'bpmn-icon-trash',
56815
+ title: this._translate('Delete'),
56816
+ action: {
56817
+ click: function(event, elements) {
56818
+ modeling.removeElements(elements.slice());
56819
+ }
56820
+ }
56821
+ }
56822
+ });
56823
+ }
56824
+
56825
+ return actions;
56826
+ };
56827
+
56828
+ /**
56829
+ * @param {Element[]} elements
56830
+ *
56831
+ * @return {boolean}
56832
+ */
56833
+ ContextPadProvider.prototype._isDeleteAllowed = function(elements) {
56834
+
56835
+ var baseAllowed = this._rules.allowed('elements.delete', {
56836
+ elements: elements
56837
+ });
56838
+
56839
+ if (isArray$3(baseAllowed)) {
56840
+ return every(baseAllowed, function(element) {
56841
+ return includes$1(baseAllowed, element);
56842
+ });
56843
+ }
56844
+
56845
+ return baseAllowed;
56846
+ };
56847
+
56848
+ /**
56849
+ * @param {Element} element
56850
+ *
56851
+ * @return {ContextPadEntries}
56852
+ */
56853
+ ContextPadProvider.prototype.getContextPadEntries = function(element) {
56854
+ var contextPad = this._contextPad,
56855
+ modeling = this._modeling,
56856
+ elementFactory = this._elementFactory,
56857
+ connect = this._connect,
56858
+ create = this._create,
56859
+ popupMenu = this._popupMenu,
56860
+ rules = this._rules,
56861
+ autoPlace = this._autoPlace,
56862
+ translate = this._translate,
56863
+ appendPreview = this._appendPreview;
56864
+
56865
+ var actions = {};
56866
+
56867
+ if (element.type === 'label') {
56868
+ return actions;
56869
+ }
56870
+
56871
+ var businessObject = element.businessObject;
56872
+
56873
+ function startConnect(event, element) {
56874
+ connect.start(event, element);
56875
+ }
56876
+
56877
+ function removeElement(e, element) {
56878
+ modeling.removeElements([ element ]);
56879
+ }
56880
+
56881
+ function getReplaceMenuPosition(element) {
56882
+
56883
+ var Y_OFFSET = 5;
56884
+
56885
+ var pad = contextPad.getPad(element).html;
56886
+
56887
+ var padRect = pad.getBoundingClientRect();
56888
+
56889
+ var pos = {
56890
+ x: padRect.left,
56891
+ y: padRect.bottom + Y_OFFSET
56892
+ };
56893
+
56894
+ return pos;
56895
+ }
56896
+
56897
+ /**
56898
+ * Create an append action.
56899
+ *
56900
+ * @param {string} type
56901
+ * @param {string} className
56902
+ * @param {string} title
56903
+ * @param {Object} [options]
56904
+ *
56905
+ * @return {ContextPadEntry}
56906
+ */
56907
+ function appendAction(type, className, title, options) {
56908
+
56909
+ function appendStart(event, element) {
56910
+
56911
+ var shape = elementFactory.createShape(assign$1({ type: type }, options));
56912
+
56913
+ create.start(event, shape, {
56914
+ source: element
56915
+ });
56916
+ }
56917
+
56918
+ var append = autoPlace ? function(_, element) {
56919
+ var shape = elementFactory.createShape(assign$1({ type: type }, options));
56920
+
56921
+ autoPlace.append(element, shape);
56922
+ } : appendStart;
56923
+
56924
+ var previewAppend = autoPlace ? function(_, element) {
56925
+
56926
+ // mouseover
56927
+ appendPreview.create(element, type, options);
56928
+
56929
+ return () => {
56930
+
56931
+ // mouseout
56932
+ appendPreview.cleanUp();
56933
+ };
56934
+ } : null;
56935
+
56936
+ return {
56937
+ group: 'model',
56938
+ className: className,
56939
+ title: title,
56940
+ action: {
56941
+ dragstart: appendStart,
56942
+ click: append,
56943
+ hover: previewAppend
56944
+ }
56945
+ };
56946
+ }
56947
+
56948
+ function splitLaneHandler(count) {
56949
+
56950
+ return function(_, element) {
56951
+
56952
+ // actual split
56953
+ modeling.splitLane(element, count);
56954
+
56955
+ // refresh context pad after split to
56956
+ // get rid of split icons
56957
+ contextPad.open(element, true);
56958
+ };
56959
+ }
56960
+
56961
+
56962
+ if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded(element)) {
56963
+
56964
+ var childLanes = getChildLanes(element);
56965
+
56966
+ assign$1(actions, {
56967
+ 'lane-insert-above': {
56968
+ group: 'lane-insert-above',
56969
+ className: 'bpmn-icon-lane-insert-above',
56970
+ title: translate('Add lane above'),
56971
+ action: {
56972
+ click: function(event, element) {
56973
+ modeling.addLane(element, 'top');
56974
+ }
56975
+ }
56976
+ }
56977
+ });
56978
+
56979
+ if (childLanes.length < 2) {
56980
+
56981
+ if (isHorizontal$3(element) ? element.height >= 120 : element.width >= 120) {
56982
+ assign$1(actions, {
56983
+ 'lane-divide-two': {
56984
+ group: 'lane-divide',
56985
+ className: 'bpmn-icon-lane-divide-two',
56986
+ title: translate('Divide into two lanes'),
56987
+ action: {
56988
+ click: splitLaneHandler(2)
56989
+ }
56990
+ }
56991
+ });
56992
+ }
56993
+
56994
+ if (isHorizontal$3(element) ? element.height >= 180 : element.width >= 180) {
56995
+ assign$1(actions, {
56996
+ 'lane-divide-three': {
56997
+ group: 'lane-divide',
56998
+ className: 'bpmn-icon-lane-divide-three',
56999
+ title: translate('Divide into three lanes'),
57000
+ action: {
57001
+ click: splitLaneHandler(3)
57002
+ }
57003
+ }
57004
+ });
57005
+ }
57006
+ }
57007
+
57008
+ assign$1(actions, {
57009
+ 'lane-insert-below': {
57010
+ group: 'lane-insert-below',
57011
+ className: 'bpmn-icon-lane-insert-below',
57012
+ title: translate('Add lane below'),
57013
+ action: {
57014
+ click: function(event, element) {
57015
+ modeling.addLane(element, 'bottom');
57016
+ }
57017
+ }
57018
+ }
57019
+ });
57020
+
57021
+ }
57022
+
57023
+ if (is$1(businessObject, 'bpmn:FlowNode')) {
57024
+
57025
+ if (is$1(businessObject, 'bpmn:EventBasedGateway')) {
57026
+
57027
+ assign$1(actions, {
57028
+ 'append.receive-task': appendAction(
57029
+ 'bpmn:ReceiveTask',
57030
+ 'bpmn-icon-receive-task',
57031
+ translate('Append receive task')
57032
+ ),
57033
+ 'append.message-intermediate-event': appendAction(
57034
+ 'bpmn:IntermediateCatchEvent',
57035
+ 'bpmn-icon-intermediate-event-catch-message',
57036
+ translate('Append message intermediate catch event'),
57037
+ { eventDefinitionType: 'bpmn:MessageEventDefinition' }
57038
+ ),
57039
+ 'append.timer-intermediate-event': appendAction(
57040
+ 'bpmn:IntermediateCatchEvent',
57041
+ 'bpmn-icon-intermediate-event-catch-timer',
57042
+ translate('Append timer intermediate catch event'),
57043
+ { eventDefinitionType: 'bpmn:TimerEventDefinition' }
57044
+ ),
57045
+ 'append.condition-intermediate-event': appendAction(
57046
+ 'bpmn:IntermediateCatchEvent',
57047
+ 'bpmn-icon-intermediate-event-catch-condition',
57048
+ translate('Append conditional intermediate catch event'),
57049
+ { eventDefinitionType: 'bpmn:ConditionalEventDefinition' }
57050
+ ),
57051
+ 'append.signal-intermediate-event': appendAction(
57052
+ 'bpmn:IntermediateCatchEvent',
57053
+ 'bpmn-icon-intermediate-event-catch-signal',
57054
+ translate('Append signal intermediate catch event'),
57055
+ { eventDefinitionType: 'bpmn:SignalEventDefinition' }
57056
+ )
57057
+ });
57058
+ } else
57059
+
57060
+ if (isEventType(businessObject, 'bpmn:BoundaryEvent', 'bpmn:CompensateEventDefinition')) {
57061
+
57062
+ assign$1(actions, {
57063
+ 'append.compensation-activity':
57064
+ appendAction(
57065
+ 'bpmn:Task',
57066
+ 'bpmn-icon-task',
57067
+ translate('Append compensation activity'),
57068
+ {
57069
+ isForCompensation: true
57070
+ }
57071
+ )
57072
+ });
57073
+ } else
57074
+
57075
+ if (!is$1(businessObject, 'bpmn:EndEvent') &&
57076
+ !businessObject.isForCompensation &&
57077
+ !isEventType(businessObject, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') &&
57078
+ !isEventSubProcess(businessObject)) {
57079
+
57080
+ assign$1(actions, {
57081
+ 'append.end-event': appendAction(
57082
+ 'bpmn:EndEvent',
57083
+ 'bpmn-icon-end-event-none',
57084
+ translate('Append end event')
57085
+ ),
57086
+ 'append.gateway': appendAction(
57087
+ 'bpmn:ExclusiveGateway',
57088
+ 'bpmn-icon-gateway-none',
57089
+ translate('Append gateway')
57090
+ ),
57091
+ 'append.append-task': appendAction(
57092
+ 'bpmn:Task',
57093
+ 'bpmn-icon-task',
57094
+ translate('Append task')
57095
+ ),
57096
+ 'append.intermediate-event': appendAction(
57097
+ 'bpmn:IntermediateThrowEvent',
57098
+ 'bpmn-icon-intermediate-event-none',
57099
+ translate('Append intermediate/boundary event')
57100
+ )
57101
+ });
57102
+ }
57103
+ }
57104
+
57105
+ if (!popupMenu.isEmpty(element, 'bpmn-replace')) {
57106
+
57107
+ // Replace menu entry
57108
+ assign$1(actions, {
57109
+ 'replace': {
57110
+ group: 'edit',
57111
+ className: 'bpmn-icon-screw-wrench',
57112
+ title: translate('Change element'),
57113
+ action: {
57114
+ click: function(event, element) {
57115
+
57116
+ var position = assign$1(getReplaceMenuPosition(element), {
57117
+ cursor: { x: event.x, y: event.y }
57118
+ });
57119
+
57120
+ popupMenu.open(element, 'bpmn-replace', position, {
57121
+ title: translate('Change element'),
57122
+ width: 300,
57123
+ search: true
57124
+ });
57125
+ }
57126
+ }
57127
+ }
57128
+ });
57129
+ }
57130
+
57131
+ if (is$1(businessObject, 'bpmn:SequenceFlow')) {
57132
+ assign$1(actions, {
57133
+ 'append.text-annotation': appendAction(
57134
+ 'bpmn:TextAnnotation',
57135
+ 'bpmn-icon-text-annotation',
57136
+ translate('Add text annotation')
57137
+ )
57138
+ });
57139
+ }
57140
+
57141
+ if (
57142
+ isAny(businessObject, [
57143
+ 'bpmn:FlowNode',
57144
+ 'bpmn:InteractionNode',
57145
+ 'bpmn:DataObjectReference',
57146
+ 'bpmn:DataStoreReference',
57147
+ ])
57148
+ ) {
57149
+ assign$1(actions, {
57150
+ 'append.text-annotation': appendAction(
57151
+ 'bpmn:TextAnnotation',
57152
+ 'bpmn-icon-text-annotation',
57153
+ translate('Add text annotation')
57154
+ ),
57155
+ 'connect': {
57156
+ group: 'connect',
57157
+ className: 'bpmn-icon-connection-multi',
57158
+ title: translate('Connect to other element'),
57159
+ action: {
57160
+ click: startConnect,
57161
+ dragstart: startConnect,
57162
+ },
57163
+ },
57164
+ });
57165
+ }
57166
+
57167
+ if (is$1(businessObject, 'bpmn:TextAnnotation')) {
57168
+ assign$1(actions, {
57169
+ 'connect': {
57170
+ group: 'connect',
57171
+ className: 'bpmn-icon-connection-multi',
57172
+ title: translate('Connect using association'),
57173
+ action: {
57174
+ click: startConnect,
57175
+ dragstart: startConnect,
57176
+ },
57177
+ },
57178
+ });
57179
+ }
57180
+
57181
+ if (isAny(businessObject, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ])) {
57182
+ assign$1(actions, {
57183
+ 'connect': {
57184
+ group: 'connect',
57185
+ className: 'bpmn-icon-connection-multi',
57186
+ title: translate('Connect using data input association'),
57187
+ action: {
57188
+ click: startConnect,
57189
+ dragstart: startConnect
57190
+ }
57191
+ }
57192
+ });
57193
+ }
57194
+
57195
+ if (is$1(businessObject, 'bpmn:Group')) {
57196
+ assign$1(actions, {
57197
+ 'append.text-annotation': appendAction(
57198
+ 'bpmn:TextAnnotation',
57199
+ 'bpmn-icon-text-annotation',
57200
+ translate('Add text annotation')
57201
+ )
57202
+ });
57203
+ }
57204
+
57205
+ // delete element entry, only show if allowed by rules
57206
+ var deleteAllowed = rules.allowed('elements.delete', { elements: [ element ] });
57207
+
57208
+ if (isArray$3(deleteAllowed)) {
57209
+
57210
+ // was the element returned as a deletion candidate?
57211
+ deleteAllowed = deleteAllowed[0] === element;
57212
+ }
57213
+
57214
+ if (deleteAllowed) {
57215
+ assign$1(actions, {
57216
+ 'delete': {
57217
+ group: 'edit',
57218
+ className: 'bpmn-icon-trash',
57219
+ title: translate('Delete'),
57220
+ action: {
57221
+ click: removeElement
57222
+ }
57223
+ }
57224
+ });
57225
+ }
57226
+
57227
+ return actions;
57228
+ };
57229
+
57230
+
57231
+ // helpers /////////
57232
+
57233
+ /**
57234
+ * @param {ModdleElement} businessObject
57235
+ * @param {string} type
57236
+ * @param {string} eventDefinitionType
57237
+ *
57238
+ * @return {boolean}
57239
+ */
57240
+ function isEventType(businessObject, type, eventDefinitionType) {
57241
+
57242
+ var isType = businessObject.$instanceOf(type);
57243
+ var isDefinition = false;
57244
+
57245
+ var definitions = businessObject.eventDefinitions || [];
57246
+ forEach$1(definitions, function(def) {
57247
+ if (def.$type === eventDefinitionType) {
57248
+ isDefinition = true;
57249
+ }
57250
+ });
57251
+
57252
+ return isType && isDefinition;
57253
+ }
57254
+
57255
+ function includes$1(array, item) {
57256
+ return array.indexOf(item) !== -1;
57223
57257
  }
57224
57258
 
57225
57259
  var ContextPadModule = {