bpmn-js 17.6.2 → 17.6.3

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