camunda-bpmn-js 4.20.0 → 4.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6041,7 +6041,7 @@
6041
6041
  Canvas.prototype.viewbox = function(box) {
6042
6042
 
6043
6043
  if (box === undefined && this._cachedViewbox) {
6044
- return this._cachedViewbox;
6044
+ return structuredClone(this._cachedViewbox);
6045
6045
  }
6046
6046
 
6047
6047
  const viewport = this._viewport,
@@ -28164,7 +28164,6 @@
28164
28164
  scale,
28165
28165
  search,
28166
28166
  emptyPlaceholder,
28167
- searchFn,
28168
28167
  entries: originalEntries,
28169
28168
  onOpened,
28170
28169
  onClosed
@@ -28186,19 +28185,29 @@
28186
28185
  return originalEntries;
28187
28186
  }
28188
28187
 
28189
- if (!value) {
28190
- return originalEntries.filter(({ rank = 0 }) => rank >= 0);
28191
- }
28188
+ const filter = entry => {
28189
+ if (!value) {
28190
+ return (entry.rank || 0) >= 0;
28191
+ }
28192
+
28193
+ if (entry.searchable === false) {
28194
+ return false;
28195
+ }
28196
+
28197
+ const searchableFields = [
28198
+ entry.description || '',
28199
+ entry.label || '',
28200
+ entry.search || ''
28201
+ ].map(string => string.toLowerCase());
28192
28202
 
28193
- const searchableEntries = originalEntries.filter(({ searchable }) => searchable !== false);
28203
+ // every word of `value` should be included in one of the searchable fields
28204
+ return value
28205
+ .toLowerCase()
28206
+ .split(/\s/g)
28207
+ .every(word => searchableFields.some(field => field.includes(word)));
28208
+ };
28194
28209
 
28195
- return searchFn(searchableEntries, value, {
28196
- keys: [
28197
- 'label',
28198
- 'description',
28199
- 'search'
28200
- ]
28201
- }).map(({ item }) => item);
28210
+ return originalEntries.filter(filter);
28202
28211
  }, [ searchable ]);
28203
28212
 
28204
28213
  const [ entries, setEntries ] = p$2(filterEntries(originalEntries, value));
@@ -28455,10 +28464,9 @@
28455
28464
  * @param {EventBus} eventBus
28456
28465
  * @param {Canvas} canvas
28457
28466
  */
28458
- function PopupMenu(config, eventBus, canvas, search) {
28467
+ function PopupMenu(config, eventBus, canvas) {
28459
28468
  this._eventBus = eventBus;
28460
28469
  this._canvas = canvas;
28461
- this._search = search;
28462
28470
 
28463
28471
  this._current = null;
28464
28472
 
@@ -28490,8 +28498,7 @@
28490
28498
  PopupMenu.$inject = [
28491
28499
  'config.popupMenu',
28492
28500
  'eventBus',
28493
- 'canvas',
28494
- 'search'
28501
+ 'canvas'
28495
28502
  ];
28496
28503
 
28497
28504
  PopupMenu.prototype._render = function() {
@@ -28535,7 +28542,6 @@
28535
28542
  scale=${ scale }
28536
28543
  onOpened=${ this._onOpened.bind(this) }
28537
28544
  onClosed=${ this._onClosed.bind(this) }
28538
- searchFn=${ this._search }
28539
28545
  ...${{ ...options }}
28540
28546
  />
28541
28547
  `,
@@ -28946,6 +28952,7 @@
28946
28952
 
28947
28953
 
28948
28954
  PopupMenu.prototype._getEmptyPlaceholder = function(providers) {
28955
+
28949
28956
  const provider = providers.find(
28950
28957
  provider => isFunction(provider.getEmptyPlaceholder)
28951
28958
  );
@@ -29021,263 +29028,10 @@
29021
29028
  return entry;
29022
29029
  };
29023
29030
 
29024
- /**
29025
- * @typedef { {
29026
- * index: number;
29027
- * match: boolean;
29028
- * value: string;
29029
- * } } Token
29030
- *
29031
- * @typedef {Token[]} Tokens
29032
- *
29033
- * @typedef { {
29034
- * item: Object,
29035
- * tokens: Record<string, Tokens>
29036
- * } } SearchResult
29037
- *
29038
- * @typedef {SearchResult[]} SearchResults
29039
- */
29040
-
29041
- /**
29042
- * Search items by query.
29043
- *
29044
- * @param {Object[]} items
29045
- * @param {string} pattern
29046
- * @param { {
29047
- * keys: string[];
29048
- * } } options
29049
- *
29050
- * @returns {SearchResults}
29051
- */
29052
- function search(items, pattern, options) {
29053
- return items.reduce((results, item) => {
29054
- const tokens = getTokens(item, pattern, options.keys);
29055
-
29056
- if (Object.keys(tokens).length) {
29057
- const result = {
29058
- item,
29059
- tokens
29060
- };
29061
-
29062
- const index = getIndex(result, results, options.keys);
29063
-
29064
- results.splice(index, 0, result);
29065
- }
29066
-
29067
- return results;
29068
- }, []);
29069
- }
29070
-
29071
- /**
29072
- * Get tokens for item.
29073
- *
29074
- * @param {Object} item
29075
- * @param {string} pattern
29076
- * @param {string[]} keys
29077
- *
29078
- * @returns {Record<string, Tokens>}
29079
- */
29080
- function getTokens(item, pattern, keys) {
29081
- return keys.reduce((results, key) => {
29082
- const string = item[ key ];
29083
-
29084
- const tokens = getMatchingTokens(string, pattern);
29085
-
29086
- if (hasMatch$1(tokens)) {
29087
- results[ key ] = tokens;
29088
- }
29089
-
29090
- return results;
29091
- }, {});
29092
- }
29093
-
29094
- /**
29095
- * Get index of result in list of results.
29096
- *
29097
- * @param {SearchResult} result
29098
- * @param {SearchResults} results
29099
- * @param {string[]} keys
29100
- *
29101
- * @returns {number}
29102
- */
29103
- function getIndex(result, results, keys) {
29104
- if (!results.length) {
29105
- return 0;
29106
- }
29107
-
29108
- let index = 0;
29109
-
29110
- do {
29111
- for (const key of keys) {
29112
- const tokens = result.tokens[ key ],
29113
- tokensOther = results[ index ].tokens[ key ];
29114
-
29115
- if (tokens && !tokensOther) {
29116
- return index;
29117
- } else if (!tokens && tokensOther) {
29118
- index++;
29119
-
29120
- break;
29121
- } else if (!tokens && !tokensOther) {
29122
- continue;
29123
- }
29124
-
29125
- const tokenComparison = compareTokens$1(tokens, tokensOther);
29126
-
29127
- if (tokenComparison === -1) {
29128
- return index;
29129
- } else if (tokenComparison === 1) {
29130
- index++;
29131
-
29132
- break;
29133
- } else {
29134
- const stringComparison = compareStrings$1(result.item[ key ], results[ index ].item[ key ]);
29135
-
29136
- if (stringComparison === -1) {
29137
- return index;
29138
- } else if (stringComparison === 1) {
29139
- index++;
29140
-
29141
- break;
29142
- } else {
29143
- continue;
29144
- }
29145
- }
29146
- }
29147
- } while (index < results.length);
29148
-
29149
- return index;
29150
- }
29151
-
29152
- /**
29153
- * @param {Token} token
29154
- *
29155
- * @return {boolean}
29156
- */
29157
- function isMatch$1(token) {
29158
- return token.match;
29159
- }
29160
-
29161
- /**
29162
- * @param {Token[]} tokens
29163
- *
29164
- * @return {boolean}
29165
- */
29166
- function hasMatch$1(tokens) {
29167
- return tokens.find(isMatch$1);
29168
- }
29169
-
29170
- /**
29171
- * Compares two token arrays.
29172
- *
29173
- * @param {Token[]} tokensA
29174
- * @param {Token[]} tokensB
29175
- *
29176
- * @returns {number}
29177
- */
29178
- function compareTokens$1(tokensA, tokensB) {
29179
- const tokensAHasMatch = hasMatch$1(tokensA),
29180
- tokensBHasMatch = hasMatch$1(tokensB);
29181
-
29182
- if (tokensAHasMatch && !tokensBHasMatch) {
29183
- return -1;
29184
- }
29185
-
29186
- if (!tokensAHasMatch && tokensBHasMatch) {
29187
- return 1;
29188
- }
29189
-
29190
- if (!tokensAHasMatch && !tokensBHasMatch) {
29191
- return 0;
29192
- }
29193
-
29194
- const tokensAFirstMatch = tokensA.find(isMatch$1),
29195
- tokensBFirstMatch = tokensB.find(isMatch$1);
29196
-
29197
- if (tokensAFirstMatch.index < tokensBFirstMatch.index) {
29198
- return -1;
29199
- }
29200
-
29201
- if (tokensAFirstMatch.index > tokensBFirstMatch.index) {
29202
- return 1;
29203
- }
29204
-
29205
- return 0;
29206
- }
29207
-
29208
- /**
29209
- * Compares two strings.
29210
- *
29211
- * @param {string} a
29212
- * @param {string} b
29213
- *
29214
- * @returns {number}
29215
- */
29216
- function compareStrings$1(a, b) {
29217
- return a.localeCompare(b);
29218
- }
29219
-
29220
- /**
29221
- * @param {string} string
29222
- * @param {string} pattern
29223
- *
29224
- * @return {Token[]}
29225
- */
29226
- function getMatchingTokens(string, pattern) {
29227
- var tokens = [],
29228
- originalString = string;
29229
-
29230
- if (!string) {
29231
- return tokens;
29232
- }
29233
-
29234
- string = string.toLowerCase();
29235
- pattern = pattern.toLowerCase();
29236
-
29237
- var index = string.indexOf(pattern);
29238
-
29239
- if (index > -1) {
29240
- if (index !== 0) {
29241
- tokens.push({
29242
- value: originalString.slice(0, index),
29243
- index: 0
29244
- });
29245
- }
29246
-
29247
- tokens.push({
29248
- value: originalString.slice(index, index + pattern.length),
29249
- index: index,
29250
- match: true
29251
- });
29252
-
29253
- if (pattern.length + index < string.length) {
29254
- tokens.push({
29255
- value: originalString.slice(index + pattern.length),
29256
- index: index + pattern.length
29257
- });
29258
- }
29259
- } else {
29260
- tokens.push({
29261
- value: originalString,
29262
- index: 0
29263
- });
29264
- }
29265
-
29266
- return tokens;
29267
- }
29268
-
29269
- /**
29270
- * @type { import('didi').ModuleDeclaration }
29271
- */
29272
- var Search = {
29273
- search: [ 'value', search ]
29274
- };
29275
-
29276
29031
  /**
29277
29032
  * @type { import('didi').ModuleDeclaration }
29278
29033
  */
29279
29034
  var PopupMenuModule$1 = {
29280
- __depends__: [ Search ],
29281
29035
  __init__: [ 'popupMenu' ],
29282
29036
  popupMenu: [ 'type', PopupMenu ]
29283
29037
  };
@@ -65042,6 +64796,8 @@
65042
64796
  * @typedef {import('./SearchPadProvider').Token} Token
65043
64797
  */
65044
64798
 
64799
+ var SCROLL_TO_ELEMENT_PADDING = 300;
64800
+
65045
64801
  /**
65046
64802
  * Provides searching infrastructure.
65047
64803
  *
@@ -65052,7 +64808,7 @@
65052
64808
  */
65053
64809
  function SearchPad(canvas, eventBus, selection, translate) {
65054
64810
  this._open = false;
65055
- this._results = [];
64811
+ this._results = {};
65056
64812
  this._eventMaps = [];
65057
64813
 
65058
64814
  this._cachedRootElement = null;
@@ -65206,6 +64962,9 @@
65206
64962
  });
65207
64963
 
65208
64964
  if (!searchResults.length) {
64965
+ this._clearMarkers();
64966
+ this._selection.select(null);
64967
+
65209
64968
  return;
65210
64969
  }
65211
64970
 
@@ -65274,12 +65033,22 @@
65274
65033
  SearchPad.prototype._clearResults = function() {
65275
65034
  clear$1(this._resultsContainer);
65276
65035
 
65277
- this._results = [];
65036
+ this._results = {};
65278
65037
 
65279
65038
  this._eventBus.fire('searchPad.cleared');
65280
65039
  };
65281
65040
 
65282
65041
 
65042
+ /**
65043
+ * Clears all markers.
65044
+ */
65045
+ SearchPad.prototype._clearMarkers = function() {
65046
+ for (var id in this._results) {
65047
+ this._canvas.removeMarker(this._results[id].element, 'djs-search-preselected');
65048
+ }
65049
+ };
65050
+
65051
+
65283
65052
  /**
65284
65053
  * Get currently selected result.
65285
65054
  *
@@ -65396,6 +65165,8 @@
65396
65165
  classes$1(this._canvas.getContainer()).remove('djs-search-open');
65397
65166
  classes$1(this._container).remove('open');
65398
65167
 
65168
+ this._clearMarkers();
65169
+
65399
65170
  this._clearResults();
65400
65171
 
65401
65172
  this._searchInput.value = '';
@@ -65434,6 +65205,8 @@
65434
65205
  return;
65435
65206
  }
65436
65207
 
65208
+ this._clearMarkers();
65209
+
65437
65210
  // removing preselection from current node
65438
65211
  if (selectedNode) {
65439
65212
  classes$1(selectedNode).remove(SearchPad.RESULT_SELECTED_CLASS);
@@ -65444,14 +65217,14 @@
65444
65217
 
65445
65218
  classes$1(node).add(SearchPad.RESULT_SELECTED_CLASS);
65446
65219
 
65447
- this._canvas.zoom(1);
65448
-
65449
65220
  this._canvas.scrollToElement(element, {
65450
- top: 300
65221
+ top: SCROLL_TO_ELEMENT_PADDING
65451
65222
  });
65452
65223
 
65453
65224
  this._selection.select(element);
65454
65225
 
65226
+ this._canvas.addMarker(element, 'djs-search-preselected');
65227
+
65455
65228
  this._eventBus.fire('searchPad.preselected', element);
65456
65229
  };
65457
65230
 
@@ -65470,7 +65243,9 @@
65470
65243
 
65471
65244
  this.close(false);
65472
65245
 
65473
- this._canvas.scrollToElement(element, { top: 400 });
65246
+ this._canvas.scrollToElement(element, {
65247
+ top: SCROLL_TO_ELEMENT_PADDING
65248
+ });
65474
65249
 
65475
65250
  this._selection.select(element);
65476
65251
 
@@ -67457,57 +67232,64 @@
67457
67232
  http://jedwatson.github.io/classnames
67458
67233
  */
67459
67234
 
67460
- (function (module) {
67461
- /* global define */
67235
+ var hasRequiredClassnames;
67236
+
67237
+ function requireClassnames () {
67238
+ if (hasRequiredClassnames) return classnames$1.exports;
67239
+ hasRequiredClassnames = 1;
67240
+ (function (module) {
67241
+ /* global define */
67462
67242
 
67463
- (function () {
67243
+ (function () {
67464
67244
 
67465
- var hasOwn = {}.hasOwnProperty;
67245
+ var hasOwn = {}.hasOwnProperty;
67466
67246
 
67467
- function classNames() {
67468
- var classes = [];
67247
+ function classNames() {
67248
+ var classes = [];
67469
67249
 
67470
- for (var i = 0; i < arguments.length; i++) {
67471
- var arg = arguments[i];
67472
- if (!arg) continue;
67250
+ for (var i = 0; i < arguments.length; i++) {
67251
+ var arg = arguments[i];
67252
+ if (!arg) continue;
67473
67253
 
67474
- var argType = typeof arg;
67254
+ var argType = typeof arg;
67475
67255
 
67476
- if (argType === 'string' || argType === 'number') {
67477
- classes.push(arg);
67478
- } else if (Array.isArray(arg)) {
67479
- if (arg.length) {
67480
- var inner = classNames.apply(null, arg);
67481
- if (inner) {
67482
- classes.push(inner);
67256
+ if (argType === 'string' || argType === 'number') {
67257
+ classes.push(arg);
67258
+ } else if (Array.isArray(arg)) {
67259
+ if (arg.length) {
67260
+ var inner = classNames.apply(null, arg);
67261
+ if (inner) {
67262
+ classes.push(inner);
67263
+ }
67483
67264
  }
67484
- }
67485
- } else if (argType === 'object') {
67486
- if (arg.toString === Object.prototype.toString) {
67487
- for (var key in arg) {
67488
- if (hasOwn.call(arg, key) && arg[key]) {
67489
- classes.push(key);
67265
+ } else if (argType === 'object') {
67266
+ if (arg.toString === Object.prototype.toString) {
67267
+ for (var key in arg) {
67268
+ if (hasOwn.call(arg, key) && arg[key]) {
67269
+ classes.push(key);
67270
+ }
67490
67271
  }
67272
+ } else {
67273
+ classes.push(arg.toString());
67491
67274
  }
67492
- } else {
67493
- classes.push(arg.toString());
67494
67275
  }
67495
67276
  }
67496
- }
67497
67277
 
67498
- return classes.join(' ');
67499
- }
67278
+ return classes.join(' ');
67279
+ }
67500
67280
 
67501
- if (module.exports) {
67502
- classNames.default = classNames;
67503
- module.exports = classNames;
67504
- } else {
67505
- window.classNames = classNames;
67506
- }
67507
- }());
67508
- } (classnames$1));
67281
+ if (module.exports) {
67282
+ classNames.default = classNames;
67283
+ module.exports = classNames;
67284
+ } else {
67285
+ window.classNames = classNames;
67286
+ }
67287
+ }());
67288
+ } (classnames$1));
67289
+ return classnames$1.exports;
67290
+ }
67509
67291
 
67510
- var classnamesExports = classnames$1.exports;
67292
+ var classnamesExports = requireClassnames();
67511
67293
  var classnames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
67512
67294
 
67513
67295
  /**