@bpmn-io/form-js-playground 0.10.0 → 0.11.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.
@@ -12839,7 +12839,7 @@
12839
12839
  if (arguments.length !== 1) {
12840
12840
  return null;
12841
12841
  }
12842
- return toString(from);
12842
+ return toString$1(from);
12843
12843
  }, ['any']),
12844
12844
  // date(from) => date string
12845
12845
  // date(from) => date and time
@@ -13365,17 +13365,17 @@
13365
13365
  }
13366
13366
  function toKeyString(key) {
13367
13367
  if (typeof key === 'string' && /\W/.test(key)) {
13368
- return toString(key, true);
13368
+ return toString$1(key, true);
13369
13369
  }
13370
13370
  return key;
13371
13371
  }
13372
13372
  function toDeepString(obj) {
13373
- return toString(obj, true);
13373
+ return toString$1(obj, true);
13374
13374
  }
13375
13375
  function escapeStr(str) {
13376
13376
  return str.replace(/("|\\)/g, '\\$1');
13377
13377
  }
13378
- function toString(obj, wrap = false) {
13378
+ function toString$1(obj, wrap = false) {
13379
13379
  var _a, _b, _c, _d;
13380
13380
  const type = getType(obj);
13381
13381
  if (type === 'nil') {
@@ -18828,7 +18828,7 @@
18828
18828
  if (type === 'number') {
18829
18829
  const {
18830
18830
  decimalDigits,
18831
- step
18831
+ increment
18832
18832
  } = field;
18833
18833
  if (value === 'NaN') {
18834
18834
  errors = [...errors, 'Value is not a number.'];
@@ -18836,13 +18836,13 @@
18836
18836
  if (decimalDigits >= 0 && countDecimals$1(value) > decimalDigits) {
18837
18837
  errors = [...errors, 'Value is expected to ' + (decimalDigits === 0 ? 'be an integer' : `have at most ${decimalDigits} decimal digit${decimalDigits > 1 ? 's' : ''}`) + '.'];
18838
18838
  }
18839
- if (step) {
18839
+ if (increment) {
18840
18840
  const bigValue = Big$1(value);
18841
- const bigStep = Big$1(step);
18842
- const offset = bigValue.mod(bigStep);
18841
+ const bigIncrement = Big$1(increment);
18842
+ const offset = bigValue.mod(bigIncrement);
18843
18843
  if (offset.cmp(0) !== 0) {
18844
18844
  const previousValue = bigValue.minus(offset);
18845
- const nextValue = previousValue.plus(bigStep);
18845
+ const nextValue = previousValue.plus(bigIncrement);
18846
18846
  errors = [...errors, `Please select a valid value, the two nearest valid values are ${previousValue} and ${nextValue}.`];
18847
18847
  }
18848
18848
  }
@@ -18857,10 +18857,10 @@
18857
18857
  if (validate.required && (isNil$1(value) || value === '')) {
18858
18858
  errors = [...errors, 'Field is required.'];
18859
18859
  }
18860
- if ('min' in validate && value && value < validate.min) {
18860
+ if ('min' in validate && (value || value === 0) && value < validate.min) {
18861
18861
  errors = [...errors, `Field must have minimum value of ${validate.min}.`];
18862
18862
  }
18863
- if ('max' in validate && value && value > validate.max) {
18863
+ if ('max' in validate && (value || value === 0) && value > validate.max) {
18864
18864
  errors = [...errors, `Field must have maximum value of ${validate.max}.`];
18865
18865
  }
18866
18866
  if ('minLength' in validate && value && value.trim().length < validate.minLength) {
@@ -20065,7 +20065,7 @@
20065
20065
  fillRule: "evenodd",
20066
20066
  clipRule: "evenodd",
20067
20067
  d: "M19 2H9V0H7v2H2a2 2 0 00-2 2v24a2 2 0 002 2h24a2 2 0 002-2V4a2 2 0 00-2-2h-5V0h-2v2zM7 7V4H2v5h24V4h-5v3h-2V4H9v3H7zm-5 4v17h24V11H2z",
20068
- fill: "#000"
20068
+ fill: "currentColor"
20069
20069
  }));
20070
20070
  function InputAdorner(props) {
20071
20071
  const {
@@ -20128,10 +20128,6 @@
20128
20128
 
20129
20129
  // setup flatpickr instance
20130
20130
  y(() => {
20131
- if (disabled) {
20132
- setFlatpickrInstance(null);
20133
- return;
20134
- }
20135
20131
  let config = {
20136
20132
  allowInput: true,
20137
20133
  dateFormat: 'm/d/Y',
@@ -20164,7 +20160,7 @@
20164
20160
  // flatpicker logic that was lost when setting allowInput to true
20165
20161
  instance.config.onOpen = [() => instance.calendarContainer.addEventListener('focusout', onCalendarFocusOut), () => instance.calendarContainer.addEventListener('mousedown', onCalendarMouseDown)];
20166
20162
  instance.config.onClose = [() => instance.calendarContainer.removeEventListener('focusout', onCalendarFocusOut), () => instance.calendarContainer.removeEventListener('mousedown', onCalendarMouseDown)];
20167
- }, [disabled, disallowPassedDates]);
20163
+ }, [disallowPassedDates]);
20168
20164
 
20169
20165
  // onChange is updated dynamically, so not to re-render the flatpicker every time it changes
20170
20166
  y(() => {
@@ -20265,12 +20261,12 @@
20265
20261
  xmlns: "http://www.w3.org/2000/svg"
20266
20262
  }, props), /*#__PURE__*/React.createElement("path", {
20267
20263
  d: "M13 14.41L18.59 20 20 18.59l-5-5.01V5h-2v9.41z",
20268
- fill: "#000"
20264
+ fill: "currentColor"
20269
20265
  }), /*#__PURE__*/React.createElement("path", {
20270
20266
  fillRule: "evenodd",
20271
20267
  clipRule: "evenodd",
20272
20268
  d: "M6.222 25.64A14 14 0 1021.778 2.36 14 14 0 006.222 25.64zM7.333 4.023a12 12 0 1113.334 19.955A12 12 0 017.333 4.022z",
20273
- fill: "#000"
20269
+ fill: "currentColor"
20274
20270
  }));
20275
20271
  function useKeyDownAction(targetKey, action, listenerElement = window) {
20276
20272
  function downHandler({
@@ -20360,6 +20356,7 @@
20360
20356
  ref: dropdownContainer,
20361
20357
  tabIndex: -1,
20362
20358
  class: "fjs-dropdownlist",
20359
+ onMouseDown: e => e.preventDefault(),
20363
20360
  style: {
20364
20361
  maxHeight: height,
20365
20362
  scrollBehavior: smoothScrolling ? 'smooth' : 'auto'
@@ -20371,10 +20368,7 @@
20371
20368
  }),
20372
20369
  onMouseMove: mouseControl ? undefined : e => onMouseMovedInKeyboardMode(e, i),
20373
20370
  onMouseEnter: mouseControl ? () => setFocusedValueIndex(i) : undefined,
20374
- onMouseDown: e => {
20375
- e.preventDefault();
20376
- onValueSelected(v);
20377
- },
20371
+ onMouseDown: e => onValueSelected(v),
20378
20372
  children: getLabel(v)
20379
20373
  });
20380
20374
  }), !values.length && e$1("div", {
@@ -20573,31 +20567,29 @@
20573
20567
  date,
20574
20568
  time
20575
20569
  } = getNullDateTime();
20576
- if (!disabled) {
20577
- switch (subtype) {
20578
- case DATETIME_SUBTYPES.DATE:
20579
- {
20580
- date = new Date(Date.parse(value));
20581
- break;
20582
- }
20583
- case DATETIME_SUBTYPES.TIME:
20584
- {
20585
- time = parseIsoTime(value);
20586
- break;
20587
- }
20588
- case DATETIME_SUBTYPES.DATETIME:
20589
- {
20590
- date = new Date(Date.parse(value));
20591
- time = isValidDate(date) ? 60 * date.getHours() + date.getMinutes() : null;
20592
- break;
20593
- }
20594
- }
20570
+ switch (subtype) {
20571
+ case DATETIME_SUBTYPES.DATE:
20572
+ {
20573
+ date = new Date(Date.parse(value));
20574
+ break;
20575
+ }
20576
+ case DATETIME_SUBTYPES.TIME:
20577
+ {
20578
+ time = parseIsoTime(value);
20579
+ break;
20580
+ }
20581
+ case DATETIME_SUBTYPES.DATETIME:
20582
+ {
20583
+ date = new Date(Date.parse(value));
20584
+ time = isValidDate(date) ? 60 * date.getHours() + date.getMinutes() : null;
20585
+ break;
20586
+ }
20595
20587
  }
20596
20588
  setDateTime({
20597
20589
  date,
20598
20590
  time
20599
20591
  });
20600
- }, [subtype, value, disabled]);
20592
+ }, [subtype, value]);
20601
20593
  const computeAndSetState = A$1(({
20602
20594
  date,
20603
20595
  time
@@ -20996,6 +20988,7 @@
20996
20988
  }), [stringValueCache, value, field]);
20997
20989
  const displayValue = d(() => {
20998
20990
  if (value === 'NaN') return 'NaN';
20991
+ if (stringValueCache === '-') return '-';
20999
20992
  return cacheValueMatchesState ? stringValueCache : value || value === 0 ? Big$1(value).toFixed() : '';
21000
20993
  }, [stringValueCache, value, cacheValueMatchesState]);
21001
20994
  const arrowIncrementValue = d(() => {
@@ -21015,6 +21008,10 @@
21015
21008
 
21016
21009
  // treat commas as dots
21017
21010
  stringValue = stringValue.replaceAll(',', '.');
21011
+ if (stringValue === '-') {
21012
+ setStringValueCache('-');
21013
+ return;
21014
+ }
21018
21015
  if (isNaN(Number(stringValue))) {
21019
21016
  setStringValueCache('NaN');
21020
21017
  onChange({
@@ -21120,6 +21117,7 @@
21120
21117
  }),
21121
21118
  children: [e$1("button", {
21122
21119
  class: "fjs-number-arrow-up",
21120
+ type: "button",
21123
21121
  onClick: () => increment(),
21124
21122
  tabIndex: -1,
21125
21123
  children: "\u02C4"
@@ -21127,6 +21125,7 @@
21127
21125
  class: "fjs-number-arrow-separator"
21128
21126
  }), e$1("button", {
21129
21127
  class: "fjs-number-arrow-down",
21128
+ type: "button",
21130
21129
  onClick: () => decrement(),
21131
21130
  tabIndex: -1,
21132
21131
  children: "\u02C5"
@@ -21589,18 +21588,18 @@
21589
21588
  styles = {},
21590
21589
  ...props
21591
21590
  }) => /*#__PURE__*/React.createElement("svg", _extends$b({
21591
+ xmlns: "http://www.w3.org/2000/svg",
21592
21592
  width: "54",
21593
21593
  height: "54",
21594
- fill: "none",
21595
- xmlns: "http://www.w3.org/2000/svg"
21594
+ fill: "none"
21596
21595
  }, props), /*#__PURE__*/React.createElement("path", {
21597
21596
  fillRule: "evenodd",
21598
21597
  clipRule: "evenodd",
21599
- d: "M19 24h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6zm6 18h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6zm6-30h-6v6h6V8zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2V8a2 2 0 00-2-2h-6z",
21600
- fill: "#22242A"
21598
+ d: "M18 12h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6zM18 36h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6zM18 24h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6z",
21599
+ fill: "#161616"
21601
21600
  }), /*#__PURE__*/React.createElement("path", {
21602
- d: "M26 26a1 1 0 011-1h15a1 1 0 011 1v2a1 1 0 01-1 1H27a1 1 0 01-1-1v-2zm0 16a1 1 0 011-1h15a1 1 0 011 1v2a1 1 0 01-1 1H27a1 1 0 01-1-1v-2zm0-32a1 1 0 011-1h15a1 1 0 011 1v2a1 1 0 01-1 1H27a1 1 0 01-1-1v-2z",
21603
- fill: "#22242A"
21601
+ d: "M23 14.5a1 1 0 011-1h19a1 1 0 011 1v1a1 1 0 01-1 1H24a1 1 0 01-1-1v-1zM23 26.5a1 1 0 011-1h19a1 1 0 011 1v1a1 1 0 01-1 1H24a1 1 0 01-1-1v-1zM23 38.5a1 1 0 011-1h19a1 1 0 011 1v1a1 1 0 01-1 1H24a1 1 0 01-1-1v-1z",
21602
+ fill: "#161616"
21604
21603
  }));
21605
21604
  function _extends$a() {
21606
21605
  _extends$a = Object.assign ? Object.assign.bind() : function (target) {
@@ -29666,6 +29665,7 @@
29666
29665
  this.curLine = null;
29667
29666
  this.breakAtStart = 0;
29668
29667
  this.pendingBuffer = 0 /* Buf.No */;
29668
+ this.bufferMarks = [];
29669
29669
  // Set to false directly after a widget that covers the position after it
29670
29670
  this.atCursorPos = true;
29671
29671
  this.openStart = -1;
@@ -29687,7 +29687,7 @@
29687
29687
  }
29688
29688
  return this.curLine;
29689
29689
  }
29690
- flushBuffer(active) {
29690
+ flushBuffer(active = this.bufferMarks) {
29691
29691
  if (this.pendingBuffer) {
29692
29692
  this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
29693
29693
  this.pendingBuffer = 0 /* Buf.No */;
@@ -29695,12 +29695,12 @@
29695
29695
  }
29696
29696
 
29697
29697
  addBlockWidget(view) {
29698
- this.flushBuffer([]);
29698
+ this.flushBuffer();
29699
29699
  this.curLine = null;
29700
29700
  this.content.push(view);
29701
29701
  }
29702
29702
  finish(openEnd) {
29703
- if (!openEnd) this.flushBuffer([]);else this.pendingBuffer = 0 /* Buf.No */;
29703
+ if (this.pendingBuffer && openEnd <= this.bufferMarks.length) this.flushBuffer();else this.pendingBuffer = 0 /* Buf.No */;
29704
29704
  if (!this.posCovered()) this.getLine();
29705
29705
  }
29706
29706
  buildText(length, active, openStart) {
@@ -29716,8 +29716,9 @@
29716
29716
  if (lineBreak) {
29717
29717
  if (!this.posCovered()) this.getLine();
29718
29718
  if (this.content.length) this.content[this.content.length - 1].breakAfter = 1;else this.breakAtStart = 1;
29719
- this.flushBuffer([]);
29719
+ this.flushBuffer();
29720
29720
  this.curLine = null;
29721
+ this.atCursorPos = true;
29721
29722
  length--;
29722
29723
  continue;
29723
29724
  } else {
@@ -29755,7 +29756,7 @@
29755
29756
  } else {
29756
29757
  let view = WidgetView.create(deco.widget || new NullWidget("span"), len, len ? 0 : deco.startSide);
29757
29758
  let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
29758
- let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
29759
+ let cursorAfter = !view.isEditable && (from < to || openStart > active.length || deco.startSide <= 0);
29759
29760
  let line = this.getLine();
29760
29761
  if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore) this.pendingBuffer = 0 /* Buf.No */;
29761
29762
  this.flushBuffer(active);
@@ -29765,7 +29766,8 @@
29765
29766
  }
29766
29767
  line.append(wrapMarks(view, active), openStart);
29767
29768
  this.atCursorPos = cursorAfter;
29768
- this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;
29769
+ this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to || openStart > active.length ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;
29770
+ if (this.pendingBuffer) this.bufferMarks = active.slice();
29769
29771
  }
29770
29772
  } else if (this.doc.lineAt(this.pos).from == this.pos) {
29771
29773
  // Line decoration
@@ -33334,7 +33336,6 @@
33334
33336
  margin: 0,
33335
33337
  flexGrow: 2,
33336
33338
  flexShrink: 0,
33337
- minHeight: "100%",
33338
33339
  display: "block",
33339
33340
  whiteSpace: "pre",
33340
33341
  wordWrap: "normal",
@@ -33360,14 +33361,13 @@
33360
33361
  },
33361
33362
  ".cm-line": {
33362
33363
  display: "block",
33363
- padding: "0 2px 0 4px"
33364
- },
33365
- ".cm-selectionLayer": {
33366
- zIndex: -1,
33367
- contain: "size style"
33364
+ padding: "0 2px 0 6px"
33368
33365
  },
33369
- ".cm-selectionBackground": {
33370
- position: "absolute"
33366
+ ".cm-layer": {
33367
+ contain: "size style",
33368
+ "& > *": {
33369
+ position: "absolute"
33370
+ }
33371
33371
  },
33372
33372
  "&light .cm-selectionBackground": {
33373
33373
  background: "#d9d9d9"
@@ -33382,8 +33382,6 @@
33382
33382
  background: "#233"
33383
33383
  },
33384
33384
  ".cm-cursorLayer": {
33385
- zIndex: 100,
33386
- contain: "size style",
33387
33385
  pointerEvents: "none"
33388
33386
  },
33389
33387
  "&.cm-focused .cm-cursorLayer": {
@@ -33407,7 +33405,6 @@
33407
33405
  "100%": {}
33408
33406
  },
33409
33407
  ".cm-cursor, .cm-dropCursor": {
33410
- position: "absolute",
33411
33408
  borderLeft: "1.2px solid black",
33412
33409
  marginLeft: "-0.6px",
33413
33410
  pointerEvents: "none"
@@ -33509,6 +33506,21 @@
33509
33506
  display: "inline-block",
33510
33507
  verticalAlign: "top"
33511
33508
  },
33509
+ ".cm-highlightSpace:before": {
33510
+ content: "attr(data-display)",
33511
+ position: "absolute",
33512
+ pointerEvents: "none",
33513
+ color: "#888"
33514
+ },
33515
+ ".cm-highlightTab": {
33516
+ backgroundImage: `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,
33517
+ backgroundSize: "auto 100%",
33518
+ backgroundPosition: "right 90%",
33519
+ backgroundRepeat: "no-repeat"
33520
+ },
33521
+ ".cm-trailingSpace": {
33522
+ backgroundColor: "#ff332255"
33523
+ },
33512
33524
  ".cm-button": {
33513
33525
  verticalAlign: "middle",
33514
33526
  color: "inherit",
@@ -33815,7 +33827,8 @@
33815
33827
  this.lastChange = 0;
33816
33828
  this.scrollTargets = [];
33817
33829
  this.intersection = null;
33818
- this.resize = null;
33830
+ this.resizeScroll = null;
33831
+ this.resizeContent = null;
33819
33832
  this.intersecting = false;
33820
33833
  this.gapIntersection = null;
33821
33834
  this.gaps = [];
@@ -33848,11 +33861,13 @@
33848
33861
  this.onPrint = this.onPrint.bind(this);
33849
33862
  this.onScroll = this.onScroll.bind(this);
33850
33863
  if (typeof ResizeObserver == "function") {
33851
- this.resize = new ResizeObserver(() => {
33864
+ this.resizeScroll = new ResizeObserver(() => {
33852
33865
  var _a;
33853
33866
  if (((_a = this.view.docView) === null || _a === void 0 ? void 0 : _a.lastUpdate) < Date.now() - 75) this.onResize();
33854
33867
  });
33855
- this.resize.observe(view.scrollDOM);
33868
+ this.resizeScroll.observe(view.scrollDOM);
33869
+ this.resizeContent = new ResizeObserver(() => this.view.requestMeasure());
33870
+ this.resizeContent.observe(view.contentDOM);
33856
33871
  }
33857
33872
  this.addWindowListeners(this.win = view.win);
33858
33873
  this.start();
@@ -34149,11 +34164,12 @@
34149
34164
  win.document.removeEventListener("selectionchange", this.onSelectionChange);
34150
34165
  }
34151
34166
  destroy() {
34152
- var _a, _b, _c;
34167
+ var _a, _b, _c, _d;
34153
34168
  this.stop();
34154
34169
  (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
34155
34170
  (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
34156
- (_c = this.resize) === null || _c === void 0 ? void 0 : _c.disconnect();
34171
+ (_c = this.resizeScroll) === null || _c === void 0 ? void 0 : _c.disconnect();
34172
+ (_d = this.resizeContent) === null || _d === void 0 ? void 0 : _d.disconnect();
34157
34173
  for (let dom of this.scrollTargets) dom.removeEventListener("scroll", this.onScroll);
34158
34174
  this.removeWindowListeners(this.win);
34159
34175
  clearTimeout(this.parentCheck);
@@ -34255,7 +34271,7 @@
34255
34271
  this.scrollDOM.className = "cm-scroller";
34256
34272
  this.scrollDOM.appendChild(this.contentDOM);
34257
34273
  this.announceDOM = document.createElement("div");
34258
- this.announceDOM.style.cssText = "position: absolute; top: -10000px";
34274
+ this.announceDOM.style.cssText = "position: fixed; top: -10000px";
34259
34275
  this.announceDOM.setAttribute("aria-live", "polite");
34260
34276
  this.dom = document.createElement("div");
34261
34277
  this.dom.appendChild(this.announceDOM);
@@ -35283,46 +35299,22 @@
35283
35299
  }
35284
35300
  return fallthrough;
35285
35301
  }
35286
- const CanHidePrimary = !browser.ios; // FIXME test IE
35287
- const selectionConfig = /*@__PURE__*/Facet.define({
35288
- combine(configs) {
35289
- return combineConfig(configs, {
35290
- cursorBlinkRate: 1200,
35291
- drawRangeCursor: true
35292
- }, {
35293
- cursorBlinkRate: (a, b) => Math.min(a, b),
35294
- drawRangeCursor: (a, b) => a || b
35295
- });
35296
- }
35297
- });
35298
- /**
35299
- Returns an extension that hides the browser's native selection and
35300
- cursor, replacing the selection with a background behind the text
35301
- (with the `cm-selectionBackground` class), and the
35302
- cursors with elements overlaid over the code (using
35303
- `cm-cursor-primary` and `cm-cursor-secondary`).
35304
-
35305
- This allows the editor to display secondary selection ranges, and
35306
- tends to produce a type of selection more in line with that users
35307
- expect in a text editor (the native selection styling will often
35308
- leave gaps between lines and won't fill the horizontal space after
35309
- a line when the selection continues past it).
35310
35302
 
35311
- It does have a performance cost, in that it requires an extra DOM
35312
- layout cycle for many updates (the selection is drawn based on DOM
35313
- layout information that's only available after laying out the
35314
- content).
35303
+ /**
35304
+ Implementation of [`LayerMarker`](https://codemirror.net/6/docs/ref/#view.LayerMarker) that creates
35305
+ a rectangle at a given set of coordinates.
35315
35306
  */
35316
- function drawSelection(config = {}) {
35317
- return [selectionConfig.of(config), drawSelectionPlugin, hideNativeSelection, nativeSelectionHidden.of(true)];
35318
- }
35319
- class Piece {
35320
- constructor(left, top, width, height, className) {
35307
+ class RectangleMarker {
35308
+ /**
35309
+ Create a marker with the given class and dimensions. If `width`
35310
+ is null, the DOM element will get no width style.
35311
+ */
35312
+ constructor(className, left, top, width, height) {
35313
+ this.className = className;
35321
35314
  this.left = left;
35322
35315
  this.top = top;
35323
35316
  this.width = width;
35324
35317
  this.height = height;
35325
- this.className = className;
35326
35318
  }
35327
35319
  draw() {
35328
35320
  let elt = document.createElement("div");
@@ -35330,99 +35322,38 @@
35330
35322
  this.adjust(elt);
35331
35323
  return elt;
35332
35324
  }
35325
+ update(elt, prev) {
35326
+ if (prev.className != this.className) return false;
35327
+ this.adjust(elt);
35328
+ return true;
35329
+ }
35333
35330
  adjust(elt) {
35334
35331
  elt.style.left = this.left + "px";
35335
35332
  elt.style.top = this.top + "px";
35336
- if (this.width >= 0) elt.style.width = this.width + "px";
35333
+ if (this.width != null) elt.style.width = this.width + "px";
35337
35334
  elt.style.height = this.height + "px";
35338
35335
  }
35339
35336
  eq(p) {
35340
35337
  return this.left == p.left && this.top == p.top && this.width == p.width && this.height == p.height && this.className == p.className;
35341
35338
  }
35342
- }
35343
- const drawSelectionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
35344
- constructor(view) {
35345
- this.view = view;
35346
- this.rangePieces = [];
35347
- this.cursors = [];
35348
- this.measureReq = {
35349
- read: this.readPos.bind(this),
35350
- write: this.drawSel.bind(this)
35351
- };
35352
- this.selectionLayer = view.scrollDOM.appendChild(document.createElement("div"));
35353
- this.selectionLayer.className = "cm-selectionLayer";
35354
- this.selectionLayer.setAttribute("aria-hidden", "true");
35355
- this.cursorLayer = view.scrollDOM.appendChild(document.createElement("div"));
35356
- this.cursorLayer.className = "cm-cursorLayer";
35357
- this.cursorLayer.setAttribute("aria-hidden", "true");
35358
- view.requestMeasure(this.measureReq);
35359
- this.setBlinkRate();
35360
- }
35361
- setBlinkRate() {
35362
- this.cursorLayer.style.animationDuration = this.view.state.facet(selectionConfig).cursorBlinkRate + "ms";
35363
- }
35364
- update(update) {
35365
- let confChanged = update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
35366
- if (confChanged || update.selectionSet || update.geometryChanged || update.viewportChanged) this.view.requestMeasure(this.measureReq);
35367
- if (update.transactions.some(tr => tr.scrollIntoView)) this.cursorLayer.style.animationName = this.cursorLayer.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
35368
- if (confChanged) this.setBlinkRate();
35369
- }
35370
- readPos() {
35371
- let {
35372
- state
35373
- } = this.view,
35374
- conf = state.facet(selectionConfig);
35375
- let rangePieces = state.selection.ranges.map(r => r.empty ? [] : measureRange(this.view, r)).reduce((a, b) => a.concat(b));
35376
- let cursors = [];
35377
- for (let r of state.selection.ranges) {
35378
- let prim = r == state.selection.main;
35379
- if (r.empty ? !prim || CanHidePrimary : conf.drawRangeCursor) {
35380
- let piece = measureCursor(this.view, r, prim);
35381
- if (piece) cursors.push(piece);
35382
- }
35383
- }
35384
- return {
35385
- rangePieces,
35386
- cursors
35387
- };
35388
- }
35389
- drawSel({
35390
- rangePieces,
35391
- cursors
35392
- }) {
35393
- if (rangePieces.length != this.rangePieces.length || rangePieces.some((p, i) => !p.eq(this.rangePieces[i]))) {
35394
- this.selectionLayer.textContent = "";
35395
- for (let p of rangePieces) this.selectionLayer.appendChild(p.draw());
35396
- this.rangePieces = rangePieces;
35397
- }
35398
- if (cursors.length != this.cursors.length || cursors.some((c, i) => !c.eq(this.cursors[i]))) {
35399
- let oldCursors = this.cursorLayer.children;
35400
- if (oldCursors.length !== cursors.length) {
35401
- this.cursorLayer.textContent = "";
35402
- for (const c of cursors) this.cursorLayer.appendChild(c.draw());
35403
- } else {
35404
- cursors.forEach((c, idx) => c.adjust(oldCursors[idx]));
35405
- }
35406
- this.cursors = cursors;
35407
- }
35408
- }
35409
- destroy() {
35410
- this.selectionLayer.remove();
35411
- this.cursorLayer.remove();
35412
- }
35413
- });
35414
- const themeSpec = {
35415
- ".cm-line": {
35416
- "& ::selection": {
35417
- backgroundColor: "transparent !important"
35418
- },
35419
- "&::selection": {
35420
- backgroundColor: "transparent !important"
35339
+ /**
35340
+ Create a set of rectangles for the given selection range,
35341
+ assigning them theclass`className`. Will create a single
35342
+ rectangle for empty ranges, and a set of selection-style
35343
+ rectangles covering the range's content (in a bidi-aware
35344
+ way) for non-empty ones.
35345
+ */
35346
+ static forRange(view, className, range) {
35347
+ if (range.empty) {
35348
+ let pos = view.coordsAtPos(range.head, range.assoc || 1);
35349
+ if (!pos) return [];
35350
+ let base = getBase(view);
35351
+ return [new RectangleMarker(className, pos.left - base.left, pos.top - base.top, null, pos.bottom - pos.top)];
35352
+ } else {
35353
+ return rectanglesForRange(view, className, range);
35421
35354
  }
35422
35355
  }
35423
- };
35424
- if (CanHidePrimary) themeSpec[".cm-line"].caretColor = "transparent !important";
35425
- const hideNativeSelection = /*@__PURE__*/Prec.highest( /*@__PURE__*/EditorView.theme(themeSpec));
35356
+ }
35426
35357
  function getBase(view) {
35427
35358
  let rect = view.scrollDOM.getBoundingClientRect();
35428
35359
  let left = view.textDirection == Direction.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth;
@@ -35446,7 +35377,7 @@
35446
35377
  }
35447
35378
  return line;
35448
35379
  }
35449
- function measureRange(view, range) {
35380
+ function rectanglesForRange(view, className, range) {
35450
35381
  if (range.to <= view.viewport.from || range.from >= view.viewport.to) return [];
35451
35382
  let from = Math.max(range.from, view.viewport.from),
35452
35383
  to = Math.min(range.to, view.viewport.to);
@@ -35475,8 +35406,9 @@
35475
35406
  return pieces(top).concat(between).concat(pieces(bottom));
35476
35407
  }
35477
35408
  function piece(left, top, right, bottom) {
35478
- return new Piece(left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */, "cm-selectionBackground");
35409
+ return new RectangleMarker(className, left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */);
35479
35410
  }
35411
+
35480
35412
  function pieces({
35481
35413
  top,
35482
35414
  bottom,
@@ -35534,12 +35466,162 @@
35534
35466
  };
35535
35467
  }
35536
35468
  }
35537
- function measureCursor(view, cursor, primary) {
35538
- let pos = view.coordsAtPos(cursor.head, cursor.assoc || 1);
35539
- if (!pos) return null;
35540
- let base = getBase(view);
35541
- return new Piece(pos.left - base.left, pos.top - base.top, -1, pos.bottom - pos.top, primary ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary");
35469
+ function sameMarker(a, b) {
35470
+ return a.constructor == b.constructor && a.eq(b);
35471
+ }
35472
+ class LayerView {
35473
+ constructor(view, layer) {
35474
+ this.view = view;
35475
+ this.layer = layer;
35476
+ this.drawn = [];
35477
+ this.measureReq = {
35478
+ read: this.measure.bind(this),
35479
+ write: this.draw.bind(this)
35480
+ };
35481
+ this.dom = view.scrollDOM.appendChild(document.createElement("div"));
35482
+ this.dom.classList.add("cm-layer");
35483
+ if (layer.above) this.dom.classList.add("cm-layer-above");
35484
+ if (layer.class) this.dom.classList.add(layer.class);
35485
+ this.dom.setAttribute("aria-hidden", "true");
35486
+ this.setOrder(view.state);
35487
+ view.requestMeasure(this.measureReq);
35488
+ if (layer.mount) layer.mount(this.dom, view);
35489
+ }
35490
+ update(update) {
35491
+ if (update.startState.facet(layerOrder) != update.state.facet(layerOrder)) this.setOrder(update.state);
35492
+ if (this.layer.update(update, this.dom) || update.geometryChanged) update.view.requestMeasure(this.measureReq);
35493
+ }
35494
+ setOrder(state) {
35495
+ let pos = 0,
35496
+ order = state.facet(layerOrder);
35497
+ while (pos < order.length && order[pos] != this.layer) pos++;
35498
+ this.dom.style.zIndex = String((this.layer.above ? 150 : -1) - pos);
35499
+ }
35500
+ measure() {
35501
+ return this.layer.markers(this.view);
35502
+ }
35503
+ draw(markers) {
35504
+ if (markers.length != this.drawn.length || markers.some((p, i) => !sameMarker(p, this.drawn[i]))) {
35505
+ let old = this.dom.firstChild,
35506
+ oldI = 0;
35507
+ for (let marker of markers) {
35508
+ if (marker.update && old && marker.constructor && this.drawn[oldI].constructor && marker.update(old, this.drawn[oldI])) {
35509
+ old = old.nextSibling;
35510
+ oldI++;
35511
+ } else {
35512
+ this.dom.insertBefore(marker.draw(), old);
35513
+ }
35514
+ }
35515
+ while (old) {
35516
+ let next = old.nextSibling;
35517
+ old.remove();
35518
+ old = next;
35519
+ }
35520
+ this.drawn = markers;
35521
+ }
35522
+ }
35523
+ destroy() {
35524
+ if (this.layer.destroy) this.layer.destroy(this.dom, this.view);
35525
+ this.dom.remove();
35526
+ }
35527
+ }
35528
+ const layerOrder = /*@__PURE__*/Facet.define();
35529
+ /**
35530
+ Define a layer.
35531
+ */
35532
+ function layer(config) {
35533
+ return [ViewPlugin.define(v => new LayerView(v, config)), layerOrder.of(config)];
35542
35534
  }
35535
+ const CanHidePrimary = !browser.ios; // FIXME test IE
35536
+ const selectionConfig = /*@__PURE__*/Facet.define({
35537
+ combine(configs) {
35538
+ return combineConfig(configs, {
35539
+ cursorBlinkRate: 1200,
35540
+ drawRangeCursor: true
35541
+ }, {
35542
+ cursorBlinkRate: (a, b) => Math.min(a, b),
35543
+ drawRangeCursor: (a, b) => a || b
35544
+ });
35545
+ }
35546
+ });
35547
+ /**
35548
+ Returns an extension that hides the browser's native selection and
35549
+ cursor, replacing the selection with a background behind the text
35550
+ (with the `cm-selectionBackground` class), and the
35551
+ cursors with elements overlaid over the code (using
35552
+ `cm-cursor-primary` and `cm-cursor-secondary`).
35553
+
35554
+ This allows the editor to display secondary selection ranges, and
35555
+ tends to produce a type of selection more in line with that users
35556
+ expect in a text editor (the native selection styling will often
35557
+ leave gaps between lines and won't fill the horizontal space after
35558
+ a line when the selection continues past it).
35559
+
35560
+ It does have a performance cost, in that it requires an extra DOM
35561
+ layout cycle for many updates (the selection is drawn based on DOM
35562
+ layout information that's only available after laying out the
35563
+ content).
35564
+ */
35565
+ function drawSelection(config = {}) {
35566
+ return [selectionConfig.of(config), cursorLayer, selectionLayer, hideNativeSelection, nativeSelectionHidden.of(true)];
35567
+ }
35568
+ function configChanged(update) {
35569
+ return update.startState.facet(selectionConfig) != update.startState.facet(selectionConfig);
35570
+ }
35571
+ const cursorLayer = /*@__PURE__*/layer({
35572
+ above: true,
35573
+ markers(view) {
35574
+ let {
35575
+ state
35576
+ } = view,
35577
+ conf = state.facet(selectionConfig);
35578
+ let cursors = [];
35579
+ for (let r of state.selection.ranges) {
35580
+ let prim = r == state.selection.main;
35581
+ if (r.empty ? !prim || CanHidePrimary : conf.drawRangeCursor) {
35582
+ let className = prim ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary";
35583
+ let cursor = r.empty ? r : EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1);
35584
+ for (let piece of RectangleMarker.forRange(view, className, cursor)) cursors.push(piece);
35585
+ }
35586
+ }
35587
+ return cursors;
35588
+ },
35589
+ update(update, dom) {
35590
+ if (update.transactions.some(tr => tr.scrollIntoView)) dom.style.animationName = dom.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
35591
+ let confChange = configChanged(update);
35592
+ if (confChange) setBlinkRate(update.state, dom);
35593
+ return update.docChanged || update.selectionSet || confChange;
35594
+ },
35595
+ mount(dom, view) {
35596
+ setBlinkRate(view.state, dom);
35597
+ },
35598
+ class: "cm-cursorLayer"
35599
+ });
35600
+ function setBlinkRate(state, dom) {
35601
+ dom.style.animationDuration = state.facet(selectionConfig).cursorBlinkRate + "ms";
35602
+ }
35603
+ const selectionLayer = /*@__PURE__*/layer({
35604
+ above: false,
35605
+ markers(view) {
35606
+ return view.state.selection.ranges.map(r => r.empty ? [] : RectangleMarker.forRange(view, "cm-selectionBackground", r)).reduce((a, b) => a.concat(b));
35607
+ },
35608
+ update(update, dom) {
35609
+ return update.docChanged || update.selectionSet || update.viewportChanged || configChanged(update);
35610
+ },
35611
+ class: "cm-selectionLayer"
35612
+ });
35613
+ const themeSpec = {
35614
+ ".cm-line": {
35615
+ "& ::selection": {
35616
+ backgroundColor: "transparent !important"
35617
+ },
35618
+ "&::selection": {
35619
+ backgroundColor: "transparent !important"
35620
+ }
35621
+ }
35622
+ };
35623
+ if (CanHidePrimary) themeSpec[".cm-line"].caretColor = "transparent !important";
35624
+ const hideNativeSelection = /*@__PURE__*/Prec.highest( /*@__PURE__*/EditorView.theme(themeSpec));
35543
35625
  const setDropCursorPos = /*@__PURE__*/StateEffect.define({
35544
35626
  map(pos, mapping) {
35545
35627
  return pos == null ? null : mapping.mapPos(pos);
@@ -36292,6 +36374,16 @@
36292
36374
  let left = size.width > space.right - space.left ? ltr ? space.left : space.right - size.width : ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width) : Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);
36293
36375
  let above = !!tooltip.above;
36294
36376
  if (!tooltip.strictSide && (above ? pos.top - (size.bottom - size.top) - offset.y < space.top : pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) && above == space.bottom - pos.bottom > pos.top - space.top) above = !above;
36377
+ let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;
36378
+ if (spaceVert < height && tView.resize !== false) {
36379
+ if (spaceVert < this.view.defaultLineHeight) {
36380
+ dom.style.top = Outside;
36381
+ continue;
36382
+ }
36383
+ dom.style.height = (height = spaceVert) + "px";
36384
+ } else if (dom.style.height) {
36385
+ dom.style.height = "";
36386
+ }
36295
36387
  let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;
36296
36388
  let right = left + width;
36297
36389
  if (tView.overlap !== true) for (let r of others) if (r.left < right && r.right > left && r.top < top + height && r.bottom > top) top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;
@@ -36332,7 +36424,8 @@
36332
36424
  });
36333
36425
  const baseTheme$6 = /*@__PURE__*/EditorView.baseTheme({
36334
36426
  ".cm-tooltip": {
36335
- zIndex: 100
36427
+ zIndex: 100,
36428
+ boxSizing: "border-box"
36336
36429
  },
36337
36430
  "&light .cm-tooltip": {
36338
36431
  border: "1px solid #bbb",
@@ -40035,6 +40128,7 @@
40035
40128
  maxWidth: "min(700px, 95vw)",
40036
40129
  minWidth: "250px",
40037
40130
  maxHeight: "10em",
40131
+ height: "100%",
40038
40132
  listStyle: "none",
40039
40133
  margin: 0,
40040
40134
  padding: 0,
@@ -40753,7 +40847,7 @@
40753
40847
  /**
40754
40848
  Returns an extension that enables autocompletion.
40755
40849
  */
40756
- function autocompletion$1(config = {}) {
40850
+ function autocompletion$2(config = {}) {
40757
40851
  return [completionState, completionConfig.of(config), completionPlugin, completionKeymapExt, baseTheme$4];
40758
40852
  }
40759
40853
  /**
@@ -42525,6 +42619,17 @@
42525
42619
  key: "Alt-A",
42526
42620
  run: toggleBlockComment
42527
42621
  }].concat(standardKeymap);
42622
+ /**
42623
+ A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and
42624
+ Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).
42625
+ Please see the [Tab example](../../examples/tab/) before using
42626
+ this.
42627
+ */
42628
+ const indentWithTab = {
42629
+ key: "Tab",
42630
+ run: indentMore,
42631
+ shift: indentLess
42632
+ };
42528
42633
 
42529
42634
  function crelt() {
42530
42635
  var elt = arguments[0];
@@ -44670,13 +44775,13 @@
44670
44775
  /**
44671
44776
  * @type {Facet<import('..').Variable[]>} Variable
44672
44777
  */
44673
- const variablesFacet = Facet.define();
44778
+ const variablesFacet$1 = Facet.define();
44674
44779
 
44675
44780
  /**
44676
44781
  * @type {import('@codemirror/autocomplete').CompletionSource}
44677
44782
  */
44678
44783
  var variables = context => {
44679
- const variables = context.state.facet(variablesFacet)[0];
44784
+ const variables = context.state.facet(variablesFacet$1)[0];
44680
44785
  const options = variables.map(v => ({
44681
44786
  label: v.name,
44682
44787
  type: 'variable',
@@ -44709,8 +44814,8 @@
44709
44814
  }
44710
44815
  return result;
44711
44816
  };
44712
- function autocompletion() {
44713
- return [autocompletion$1({
44817
+ function autocompletion$1() {
44818
+ return [autocompletion$2({
44714
44819
  override: [variables, builtins, completeFromList(snippets)]
44715
44820
  })];
44716
44821
  }
@@ -44887,7 +44992,7 @@
44887
44992
  return tooltipContainer.getBoundingClientRect();
44888
44993
  }
44889
44994
  }) : [];
44890
- const extensions = [autocompletionConf.of(variablesFacet.of(variables)), autocompletion(), bracketMatching(), changeHandler, closeBrackets(), indentOnInput(), keyHandler, keymap.of([...defaultKeymap]), language(), linter, lintHandler, tooltipLayout, theme];
44995
+ const extensions = [autocompletionConf.of(variablesFacet$1.of(variables)), autocompletion$1(), bracketMatching(), changeHandler, closeBrackets(), indentOnInput(), keyHandler, keymap.of([...defaultKeymap]), language(), linter, lintHandler, tooltipLayout, theme];
44891
44996
  if (readOnly) {
44892
44997
  extensions.push(EditorView.editable.of(false));
44893
44998
  }
@@ -44954,7 +45059,7 @@
44954
45059
  */
44955
45060
  FeelEditor.prototype.setVariables = function (variables) {
44956
45061
  this._cmEditor.dispatch({
44957
- effects: autocompletionConf.reconfigure(variablesFacet.of(variables))
45062
+ effects: autocompletionConf.reconfigure(variablesFacet$1.of(variables))
44958
45063
  });
44959
45064
  };
44960
45065
 
@@ -51924,7 +52029,12 @@
51924
52029
  if (!isValidNumber(value)) return null;
51925
52030
  return value;
51926
52031
  };
51927
- const setValue = value => editField(field, ['increment'], value);
52032
+ const clearLeadingZeroes = value => {
52033
+ if (!value) return value;
52034
+ const trimmed = value.replace(/^0+/g, '');
52035
+ return (trimmed.startsWith('.') ? '0' : '') + trimmed;
52036
+ };
52037
+ const setValue = value => editField(field, ['increment'], clearLeadingZeroes(value));
51928
52038
  const decimalDigitsSet = decimalDigits || decimalDigits === 0;
51929
52039
  return TextfieldEntry({
51930
52040
  debounce,
@@ -52794,7 +52904,7 @@
52794
52904
  }
52795
52905
  const VALIDATION_TYPE_OPTIONS = {
52796
52906
  custom: {
52797
- value: 'custom',
52907
+ value: undefined,
52798
52908
  label: 'Custom'
52799
52909
  },
52800
52910
  email: {
@@ -52973,10 +53083,10 @@
52973
53083
  return NumberFieldEntry({
52974
53084
  debounce,
52975
53085
  element: field,
52976
- getValue: getValue('min'),
52977
53086
  id,
52978
53087
  label: 'Minimum',
52979
- min: 0,
53088
+ step: 'any',
53089
+ getValue: getValue('min'),
52980
53090
  setValue: onChange('min')
52981
53091
  });
52982
53092
  }
@@ -52991,10 +53101,10 @@
52991
53101
  return NumberFieldEntry({
52992
53102
  debounce,
52993
53103
  element: field,
52994
- getValue: getValue('max'),
52995
53104
  id,
52996
53105
  label: 'Maximum',
52997
- min: 0,
53106
+ step: 'any',
53107
+ getValue: getValue('max'),
52998
53108
  setValue: onChange('max')
52999
53109
  });
53000
53110
  }
@@ -53006,16 +53116,25 @@
53006
53116
  onChange
53007
53117
  } = props;
53008
53118
  const debounce = useService('debounce');
53119
+ const clearCustomValidation = () => {
53120
+ onChange('minLength')(undefined);
53121
+ onChange('maxLength')(undefined);
53122
+ onChange('pattern')(undefined);
53123
+ };
53124
+ const setValue = validationType => {
53125
+ if (validationType) {
53126
+ clearCustomValidation();
53127
+ }
53128
+ onChange('validationType')(validationType || undefined);
53129
+ };
53009
53130
  return SelectEntry({
53010
53131
  debounce,
53011
53132
  element: field,
53012
53133
  getValue: getValue('validationType'),
53013
53134
  id,
53014
53135
  label: 'Regular expression validation',
53015
- setValue: onChange('validationType'),
53016
- getOptions() {
53017
- return Object.values(VALIDATION_TYPE_OPTIONS);
53018
- }
53136
+ setValue,
53137
+ getOptions: () => Object.values(VALIDATION_TYPE_OPTIONS)
53019
53138
  });
53020
53139
  }
53021
53140
  function ValuesGroups(field, editField) {
@@ -55002,7 +55121,7 @@
55002
55121
  */
55003
55122
  const basicSetup = /*@__PURE__*/(() => [lineNumbers(), highlightActiveLineGutter(), highlightSpecialChars(), history(), foldGutter(), drawSelection(), dropCursor(), EditorState.allowMultipleSelections.of(true), indentOnInput(), syntaxHighlighting(defaultHighlightStyle, {
55004
55123
  fallback: true
55005
- }), bracketMatching(), closeBrackets(), autocompletion$1(), rectangularSelection(), crosshairCursor(), highlightActiveLine(), highlightSelectionMatches(), keymap.of([...closeBracketsKeymap, ...defaultKeymap, ...searchKeymap, ...historyKeymap, ...foldKeymap, ...completionKeymap, ...lintKeymap])])();
55124
+ }), bracketMatching(), closeBrackets(), autocompletion$2(), rectangularSelection(), crosshairCursor(), highlightActiveLine(), highlightSelectionMatches(), keymap.of([...closeBracketsKeymap, ...defaultKeymap, ...searchKeymap, ...historyKeymap, ...foldKeymap, ...completionKeymap, ...lintKeymap])])();
55006
55125
 
55007
55126
  const jsonHighlighting = styleTags({
55008
55127
  String: tags$1.string,
@@ -55093,18 +55212,56 @@
55093
55212
  return new LanguageSupport(jsonLanguage);
55094
55213
  }
55095
55214
 
55215
+ /**
55216
+ * @type {Facet<import('..').Variables>} Variables
55217
+ */
55218
+ const variablesFacet = Facet.define();
55219
+
55220
+ function autocompletion () {
55221
+ return [autocompletion$2({
55222
+ override: [completions]
55223
+ })];
55224
+ }
55225
+ function completions(context) {
55226
+ const variables = context.state.facet(variablesFacet)[0];
55227
+ const options = variables.map(v => ({
55228
+ label: v,
55229
+ type: 'variable'
55230
+ }));
55231
+ let nodeBefore = syntaxTree(context.state).resolve(context.pos, -1);
55232
+
55233
+ // handle inside property name as explicit call
55234
+ if (nodeBefore.type.name === 'PropertyName') {
55235
+ context.explicit = true;
55236
+ }
55237
+ let word = context.matchBefore(/\w*/);
55238
+ if (word.from == word.to && !context.explicit) {
55239
+ return null;
55240
+ }
55241
+ return {
55242
+ from: word.from,
55243
+ options
55244
+ };
55245
+ }
55246
+
55096
55247
  function JSONEditor(options = {}) {
55097
- const emitter = mitt();
55098
55248
  const {
55099
55249
  readonly = false
55100
55250
  } = options;
55251
+ const emitter = mitt();
55101
55252
  let language = new Compartment().of(json());
55102
55253
  let tabSize = new Compartment().of(EditorState.tabSize.of(2));
55254
+
55255
+ /**
55256
+ * @typedef {Array<string>} Variables
55257
+ */
55258
+
55259
+ const autocompletionConf = new Compartment();
55103
55260
  const linterExtension = linter$1(jsonParseLinter());
55104
- function createState(doc, extensions = []) {
55261
+ function createState(doc, extensions = [], variables = []) {
55105
55262
  return EditorState.create({
55106
55263
  doc,
55107
- extensions: [basicSetup, language, tabSize, linterExtension, lintGutter(), ...extensions]
55264
+ extensions: [basicSetup, language, tabSize, linterExtension, lintGutter(), autocompletionConf.of(variablesFacet.of(variables)), autocompletion(), keymap.of([indentWithTab]), ...extensions]
55108
55265
  });
55109
55266
  }
55110
55267
  function createView(readonly) {
@@ -55122,15 +55279,25 @@
55122
55279
  view.setValue = function (value) {
55123
55280
  this.setState(createState(value, [updateListener, editable]));
55124
55281
  };
55282
+ view.setVariables = function (variables) {
55283
+ this.setState(createState(view.state.doc.toString(), [updateListener, editable], variables));
55284
+ };
55125
55285
  return view;
55126
55286
  }
55127
- const view = createView(readonly);
55287
+ const view = this._view = createView(readonly);
55128
55288
  this.setValue = function (value) {
55129
55289
  view.setValue(value);
55130
55290
  };
55131
55291
  this.getValue = function () {
55132
55292
  return view.state.doc.toString();
55133
55293
  };
55294
+
55295
+ /**
55296
+ * @param {Variables} variables
55297
+ */
55298
+ this.setVariables = function (variables) {
55299
+ view.setVariables(variables);
55300
+ };
55134
55301
  this.on = emitter.on;
55135
55302
  this.off = emitter.off;
55136
55303
  this.emit = emitter.emit;
@@ -55179,16 +55346,12 @@
55179
55346
  function PlaygroundRoot(props) {
55180
55347
  const {
55181
55348
  actions: actionsConfig = {},
55182
- editor: editorConfig = {},
55183
55349
  emit,
55184
55350
  exporter: exporterConfig = {}
55185
55351
  } = props;
55186
55352
  const {
55187
55353
  display: displayActions = true
55188
55354
  } = actionsConfig;
55189
- const {
55190
- inlinePropertiesPanel = true
55191
- } = editorConfig;
55192
55355
  const paletteContainerRef = s$1();
55193
55356
  const editorContainerRef = s$1();
55194
55357
  const formContainerRef = s$1();
@@ -55232,11 +55395,11 @@
55232
55395
  }, [props.schema]);
55233
55396
  y(() => {
55234
55397
  const dataEditor = dataEditorRef.current = new JSONEditor({
55235
- value: toJSON(data)
55398
+ value: toString(data)
55236
55399
  });
55237
55400
  const resultView = resultViewRef.current = new JSONEditor({
55238
55401
  readonly: true,
55239
- value: toJSON(resultData)
55402
+ value: toString(resultData)
55240
55403
  });
55241
55404
  const form = formRef.current = new Form();
55242
55405
  const formEditor = formEditorRef.current = new FormEditor({
@@ -55247,7 +55410,7 @@
55247
55410
  parent: paletteContainerRef.current
55248
55411
  },
55249
55412
  propertiesPanel: {
55250
- parent: !inlinePropertiesPanel && propertiesPanelContainerRef.current
55413
+ parent: propertiesPanelContainerRef.current
55251
55414
  },
55252
55415
  exporter: exporterConfig
55253
55416
  });
@@ -55287,16 +55450,25 @@
55287
55450
  };
55288
55451
  }, []);
55289
55452
  y(() => {
55290
- dataEditorRef.current.setValue(toJSON(initialData));
55453
+ dataEditorRef.current.setValue(toString(initialData));
55291
55454
  }, [initialData]);
55292
55455
  y(() => {
55293
- initialSchema && formEditorRef.current.importSchema(initialSchema);
55456
+ if (initialSchema) {
55457
+ formEditorRef.current.importSchema(initialSchema);
55458
+ dataEditorRef.current.setVariables(getSchemaVariables(initialSchema));
55459
+ }
55294
55460
  }, [initialSchema]);
55461
+ y(() => {
55462
+ if (schema && dataContainerRef.current) {
55463
+ const variables = getSchemaVariables(schema);
55464
+ dataEditorRef.current.setVariables(variables);
55465
+ }
55466
+ }, [schema]);
55295
55467
  y(() => {
55296
55468
  schema && formRef.current.importSchema(schema, data);
55297
55469
  }, [schema, data]);
55298
55470
  y(() => {
55299
- resultViewRef.current.setValue(toJSON(resultData));
55471
+ resultViewRef.current.setValue(toString(resultData));
55300
55472
  }, [resultData]);
55301
55473
  y(() => {
55302
55474
  props.onStateChanged({
@@ -55314,9 +55486,7 @@
55314
55486
  setShowEmbed(true);
55315
55487
  }, []);
55316
55488
  return e$1("div", {
55317
- class: classNames('fjs-container', 'fjs-pgl-root', {
55318
- 'fjs-pgl-inline-editor-panel': inlinePropertiesPanel
55319
- }),
55489
+ class: classNames('fjs-container', 'fjs-pgl-root'),
55320
55490
  children: [e$1("div", {
55321
55491
  class: "fjs-pgl-modals",
55322
55492
  children: showEmbed ? e$1(EmbedModal, {
@@ -55355,13 +55525,13 @@
55355
55525
  class: "fjs-pgl-form-container"
55356
55526
  })
55357
55527
  }), e$1(Section, {
55358
- name: "Form Data (Input)",
55528
+ name: "Form Input",
55359
55529
  children: e$1("div", {
55360
55530
  ref: dataContainerRef,
55361
55531
  class: "fjs-pgl-text-container"
55362
55532
  })
55363
55533
  }), e$1(Section, {
55364
- name: "Form Data (Submit)",
55534
+ name: "Form Output",
55365
55535
  children: e$1("div", {
55366
55536
  ref: resultContainerRef,
55367
55537
  class: "fjs-pgl-text-container"
@@ -55376,7 +55546,7 @@
55376
55546
 
55377
55547
  // helpers ///////////////
55378
55548
 
55379
- function toJSON(obj) {
55549
+ function toString(obj) {
55380
55550
  return JSON.stringify(obj, null, ' ');
55381
55551
  }
55382
55552