camunda-bpmn-js 4.9.0 → 4.10.0

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.
@@ -85424,6 +85424,51 @@
85424
85424
  themeSpec[".cm-content"] = { caretColor: "transparent !important" };
85425
85425
  }
85426
85426
 
85427
+ let Placeholder$1 = class Placeholder extends WidgetType {
85428
+ constructor(content) {
85429
+ super();
85430
+ this.content = content;
85431
+ }
85432
+ toDOM() {
85433
+ let wrap = document.createElement("span");
85434
+ wrap.className = "cm-placeholder";
85435
+ wrap.style.pointerEvents = "none";
85436
+ wrap.appendChild(typeof this.content == "string" ? document.createTextNode(this.content) : this.content);
85437
+ if (typeof this.content == "string")
85438
+ wrap.setAttribute("aria-label", "placeholder " + this.content);
85439
+ else
85440
+ wrap.setAttribute("aria-hidden", "true");
85441
+ return wrap;
85442
+ }
85443
+ coordsAt(dom) {
85444
+ let rects = dom.firstChild ? clientRectsFor(dom.firstChild) : [];
85445
+ if (!rects.length)
85446
+ return null;
85447
+ let style = window.getComputedStyle(dom.parentNode);
85448
+ let rect = flattenRect(rects[0], style.direction != "rtl");
85449
+ let lineHeight = parseInt(style.lineHeight);
85450
+ if (rect.bottom - rect.top > lineHeight * 1.5)
85451
+ return { left: rect.left, right: rect.right, top: rect.top, bottom: rect.top + lineHeight };
85452
+ return rect;
85453
+ }
85454
+ ignoreEvent() { return false; }
85455
+ };
85456
+ /**
85457
+ Extension that enables a placeholder—a piece of example content
85458
+ to show when the editor is empty.
85459
+ */
85460
+ function placeholder(content) {
85461
+ return ViewPlugin.fromClass(class {
85462
+ constructor(view) {
85463
+ this.view = view;
85464
+ this.placeholder = content
85465
+ ? Decoration.set([Decoration.widget({ widget: new Placeholder$1(content), side: 1 }).range(0)])
85466
+ : Decoration.none;
85467
+ }
85468
+ get decorations() { return this.view.state.doc.length ? Decoration.none : this.placeholder; }
85469
+ }, { decorations: v => v.decorations });
85470
+ }
85471
+
85427
85472
  const Outside = "-10000px";
85428
85473
  class TooltipViewManager {
85429
85474
  constructor(view, facet, createTooltipView, removeTooltipView) {
@@ -95167,12 +95212,7 @@
95167
95212
 
95168
95213
  const variables = context.state.facet(variablesFacet)[0];
95169
95214
 
95170
- const options = variables.map(v => ({
95171
- label: v.name,
95172
- type: 'variable',
95173
- info: v.info,
95174
- detail: v.detail
95175
- }));
95215
+ const options = variables.map(v => createVariableSuggestion(v));
95176
95216
 
95177
95217
  // In most cases, use what is typed before the cursor
95178
95218
  let nodeBefore = syntaxTree(context.state).resolve(context.pos, -1);
@@ -95205,6 +95245,55 @@
95205
95245
  return result;
95206
95246
  };
95207
95247
 
95248
+ /**
95249
+ * @param {import('..').Variable} variable
95250
+ * @returns {import('@codemirror/autocomplete').Completion}
95251
+ */
95252
+ function createVariableSuggestion(variable) {
95253
+ if (variable.type === 'function') {
95254
+ return createFunctionVariable(variable);
95255
+ }
95256
+
95257
+ return {
95258
+ label: variable.name,
95259
+ type: 'variable',
95260
+ info: variable.info,
95261
+ detail: variable.detail
95262
+ };
95263
+ }
95264
+
95265
+ /**
95266
+ * @param {import('..').Variable} variable
95267
+ * @returns {import('@codemirror/autocomplete').Completion}
95268
+ */
95269
+ function createFunctionVariable(variable) {
95270
+ const {
95271
+ name,
95272
+ info,
95273
+ detail,
95274
+ params = []
95275
+ } = variable;
95276
+
95277
+ const paramsWithNames = params.map(({ name, type }, index) => ({
95278
+ name: name || `param ${index + 1}`,
95279
+ type
95280
+ }));
95281
+
95282
+ const template = `${name}(${paramsWithNames.map(p => '${' + p.name + '}').join(', ')})`;
95283
+
95284
+ const paramsSignature = paramsWithNames.map(({ name, type }) => (
95285
+ type ? `${name}: ${type}` : name
95286
+ )).join(', ');
95287
+ const label = `${name}(${paramsSignature})`;
95288
+
95289
+ return snippetCompletion(template, {
95290
+ label,
95291
+ type: 'function',
95292
+ info,
95293
+ detail
95294
+ });
95295
+ }
95296
+
95208
95297
  function autocompletion() {
95209
95298
  return [
95210
95299
  autocompletion$1({
@@ -95301,15 +95390,18 @@
95301
95390
 
95302
95391
  /**
95303
95392
  * @typedef {object} Variable
95304
- * @typedef {import('@codemirror/state').Extension} Extension
95305
95393
  * @property {string} name name or key of the variable
95306
95394
  * @property {string} [info] short information about the variable, e.g. type
95307
95395
  * @property {string} [detail] longer description of the variable content
95308
95396
  * @property {boolean} [isList] whether the variable is a list
95309
- * @property {array<Variable>} [schema] array of child variables if the variable is a context or list
95397
+ * @property {Array<Variable>} [schema] array of child variables if the variable is a context or list
95398
+ * @property {'function'|'variable'} [type] type of the variable
95399
+ * @property {Array<{name: string, type: string}>} [params] function parameters
95310
95400
  */
95311
95401
 
95312
95402
  const autocompletionConf = new Compartment();
95403
+ const placeholderConf = new Compartment();
95404
+
95313
95405
 
95314
95406
  /**
95315
95407
  * Creates a FEEL editor in the supplied container
@@ -95335,6 +95427,7 @@
95335
95427
  onChange = () => {},
95336
95428
  onKeyDown = () => {},
95337
95429
  onLint = () => {},
95430
+ placeholder: placeholder$1 = '',
95338
95431
  readOnly = false,
95339
95432
  value = '',
95340
95433
  variables = []
@@ -95391,6 +95484,7 @@
95391
95484
  language(),
95392
95485
  linter,
95393
95486
  lintHandler,
95487
+ placeholderConf.of(placeholder(placeholder$1)),
95394
95488
  tooltipLayout,
95395
95489
  theme,
95396
95490
  ...editorExtensions
@@ -95465,6 +95559,17 @@
95465
95559
  });
95466
95560
  };
95467
95561
 
95562
+ /**
95563
+ * Update placeholder text.
95564
+ * @param {string} placeholder
95565
+ * @returns {void}
95566
+ */
95567
+ FeelEditor.prototype.setPlaceholder = function(placeholder$1) {
95568
+ this._cmEditor.dispatch({
95569
+ effects: placeholderConf.reconfigure(placeholder(placeholder$1))
95570
+ });
95571
+ };
95572
+
95468
95573
  /*!
95469
95574
  * tabbable 6.2.0
95470
95575
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
@@ -97837,6 +97942,7 @@
97837
97942
  onFeelToggle = noop$5,
97838
97943
  onLint = noop$5,
97839
97944
  onPopupOpen = noop$5,
97945
+ placeholder,
97840
97946
  popupOpen,
97841
97947
  disabled,
97842
97948
  tooltipContainer,
@@ -97873,6 +97979,7 @@
97873
97979
  onChange: handleInput,
97874
97980
  onKeyDown: onKeyDown,
97875
97981
  onLint: onLint,
97982
+ placeholder: placeholder,
97876
97983
  tooltipContainer: tooltipContainer,
97877
97984
  value: localValue,
97878
97985
  variables: variables,
@@ -97902,6 +98009,12 @@
97902
98009
  }
97903
98010
  editor.setVariables(variables);
97904
98011
  }, [variables]);
98012
+ p(() => {
98013
+ if (!editor) {
98014
+ return;
98015
+ }
98016
+ editor.setPlaceholder(placeholder);
98017
+ }, [placeholder]);
97905
98018
  const handleClick = () => {
97906
98019
  ref.current.focus();
97907
98020
  };
@@ -98621,7 +98734,8 @@
98621
98734
  onInput,
98622
98735
  value,
98623
98736
  onFocus,
98624
- onBlur
98737
+ onBlur,
98738
+ placeholder
98625
98739
  } = props;
98626
98740
  const inputRef = _();
98627
98741
 
@@ -98654,6 +98768,7 @@
98654
98768
  onInput: e => onInput(e.target.value),
98655
98769
  onFocus: onFocus,
98656
98770
  onBlur: onBlur,
98771
+ placeholder: placeholder,
98657
98772
  value: value || ''
98658
98773
  });
98659
98774
  });
@@ -98711,7 +98826,8 @@
98711
98826
  onInput,
98712
98827
  value,
98713
98828
  onFocus,
98714
- onBlur
98829
+ onBlur,
98830
+ placeholder
98715
98831
  } = props;
98716
98832
  const inputRef = _();
98717
98833
 
@@ -98739,6 +98855,7 @@
98739
98855
  onInput: e => onInput(e.target.value),
98740
98856
  onFocus: onFocus,
98741
98857
  onBlur: onBlur,
98858
+ placeholder: placeholder,
98742
98859
  value: value || '',
98743
98860
  "data-gramm": "false"
98744
98861
  });
@@ -99379,6 +99496,7 @@
99379
99496
  onFocus,
99380
99497
  onBlur,
99381
99498
  autoResize,
99499
+ placeholder,
99382
99500
  rows = autoResize ? 1 : 2,
99383
99501
  tooltip
99384
99502
  } = props;
@@ -99421,6 +99539,7 @@
99421
99539
  onInput: handleInput,
99422
99540
  onFocus: onFocus,
99423
99541
  onBlur: onBlur,
99542
+ placeholder: placeholder,
99424
99543
  rows: rows,
99425
99544
  value: localValue,
99426
99545
  disabled: disabled,
@@ -99460,6 +99579,7 @@
99460
99579
  validate,
99461
99580
  onFocus,
99462
99581
  onBlur,
99582
+ placeholder,
99463
99583
  autoResize,
99464
99584
  tooltip
99465
99585
  } = props;
@@ -99495,6 +99615,7 @@
99495
99615
  debounce: debounce,
99496
99616
  monospace: monospace,
99497
99617
  disabled: disabled,
99618
+ placeholder: placeholder,
99498
99619
  autoResize: autoResize,
99499
99620
  tooltip: tooltip,
99500
99621
  element: element
@@ -99527,6 +99648,7 @@
99527
99648
  onInput,
99528
99649
  onFocus,
99529
99650
  onBlur,
99651
+ placeholder,
99530
99652
  value = '',
99531
99653
  tooltip
99532
99654
  } = props;
@@ -99568,6 +99690,7 @@
99568
99690
  onInput: handleInput,
99569
99691
  onFocus: onFocus,
99570
99692
  onBlur: onBlur,
99693
+ placeholder: placeholder,
99571
99694
  value: localValue
99572
99695
  })]
99573
99696
  });
@@ -99601,6 +99724,7 @@
99601
99724
  validate,
99602
99725
  onFocus,
99603
99726
  onBlur,
99727
+ placeholder,
99604
99728
  tooltip
99605
99729
  } = props;
99606
99730
  const globalError = useError(id);
@@ -99632,6 +99756,7 @@
99632
99756
  onInput: onInput,
99633
99757
  onFocus: onFocus,
99634
99758
  onBlur: onBlur,
99759
+ placeholder: placeholder,
99635
99760
  value: value,
99636
99761
  tooltip: tooltip,
99637
99762
  element: element