@bpmn-io/form-js-playground 1.3.0 → 1.3.1

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.
@@ -54616,29 +54616,6 @@
54616
54616
  return callback;
54617
54617
  }
54618
54618
 
54619
- /**
54620
- * Throttle fn, calling at most once
54621
- * in the given interval.
54622
- *
54623
- * @param {Function} fn
54624
- * @param {Number} interval
54625
- *
54626
- * @return {Function} throttled function
54627
- */
54628
- function throttle$1(fn, interval) {
54629
- let throttling = false;
54630
- return function (...args) {
54631
- if (throttling) {
54632
- return;
54633
- }
54634
- fn(...args);
54635
- throttling = true;
54636
- setTimeout(() => {
54637
- throttling = false;
54638
- }, interval);
54639
- };
54640
- }
54641
-
54642
54619
  /**
54643
54620
  * Bind function against target <this>.
54644
54621
  *
@@ -65031,20 +65008,24 @@
65031
65008
 
65032
65009
  // set edited state depending on all entries
65033
65010
  y(() => {
65034
- const hasOneEditedEntry = entries.find(entry => {
65035
- const {
65036
- id,
65037
- isEdited
65038
- } = entry;
65039
- const entryNode = query(`[data-entry-id="${id}"]`);
65040
- if (!isFunction(isEdited) || !entryNode) {
65041
- return false;
65042
- }
65043
- const inputNode = query('.bio-properties-panel-input', entryNode);
65044
- return isEdited(inputNode);
65011
+ // TODO(@barmac): replace with CSS when `:has()` is supported in all major browsers, or rewrite as in https://github.com/camunda/camunda-modeler/issues/3815#issuecomment-1733038161
65012
+ const scheduled = requestAnimationFrame(() => {
65013
+ const hasOneEditedEntry = entries.find(entry => {
65014
+ const {
65015
+ id,
65016
+ isEdited
65017
+ } = entry;
65018
+ const entryNode = query(`[data-entry-id="${id}"]`);
65019
+ if (!isFunction(isEdited) || !entryNode) {
65020
+ return false;
65021
+ }
65022
+ const inputNode = query('.bio-properties-panel-input', entryNode);
65023
+ return isEdited(inputNode);
65024
+ });
65025
+ setEdited(hasOneEditedEntry);
65045
65026
  });
65046
- setEdited(hasOneEditedEntry);
65047
- }, [entries]);
65027
+ return () => cancelAnimationFrame(scheduled);
65028
+ }, [entries, setEdited]);
65048
65029
 
65049
65030
  // set error state depending on all entries
65050
65031
  const allErrors = useErrors();
@@ -65472,7 +65453,11 @@
65472
65453
  // (2) setup drag listeners
65473
65454
 
65474
65455
  // attach drag + cleanup event
65475
- document.addEventListener('dragover', onDrag);
65456
+ // we need to do this to make sure we track cursor
65457
+ // movements before we reach other drag event handlers,
65458
+ // e.g. in child containers.
65459
+ document.addEventListener('dragover', onDrag, true);
65460
+ document.addEventListener('dragenter', preventDefault, true);
65476
65461
  document.addEventListener('dragend', onEnd);
65477
65462
  document.addEventListener('drop', preventDefault);
65478
65463
  }
@@ -65486,7 +65471,8 @@
65486
65471
  return fn.call(self, event, delta);
65487
65472
  }
65488
65473
  function onEnd() {
65489
- document.removeEventListener('dragover', onDrag);
65474
+ document.removeEventListener('dragover', onDrag, true);
65475
+ document.removeEventListener('dragenter', preventDefault, true);
65490
65476
  document.removeEventListener('dragend', onEnd);
65491
65477
  document.removeEventListener('drop', preventDefault);
65492
65478
  }
@@ -65517,8 +65503,9 @@
65517
65503
  * @param {boolean} [props.returnFocus]
65518
65504
  * @param {boolean} [props.closeOnEscape]
65519
65505
  * @param {string} props.title
65506
+ * @param {Ref} [ref]
65520
65507
  */
65521
- function Popup(props) {
65508
+ function PopupComponent(props, globalRef) {
65522
65509
  const {
65523
65510
  container,
65524
65511
  className,
@@ -65534,7 +65521,8 @@
65534
65521
  title
65535
65522
  } = props;
65536
65523
  const focusTrapRef = s$1(null);
65537
- const popupRef = s$1(null);
65524
+ const localRef = s$1(null);
65525
+ const popupRef = globalRef || localRef;
65538
65526
  const handleKeydown = event => {
65539
65527
  // do not allow keyboard events to bubble
65540
65528
  event.stopPropagation();
@@ -65596,6 +65584,7 @@
65596
65584
  children: props.children
65597
65585
  }), container || document.body);
65598
65586
  }
65587
+ const Popup = x$1(PopupComponent);
65599
65588
  Popup.Title = Title;
65600
65589
  Popup.Body = Body;
65601
65590
  Popup.Footer = Footer;
@@ -65604,6 +65593,7 @@
65604
65593
  children,
65605
65594
  className,
65606
65595
  draggable,
65596
+ emit = () => {},
65607
65597
  title,
65608
65598
  ...rest
65609
65599
  } = props;
@@ -65616,7 +65606,8 @@
65616
65606
  });
65617
65607
  const dragPreviewRef = s$1();
65618
65608
  const titleRef = s$1();
65619
- const onMove = throttle$1((_, delta) => {
65609
+ const onMove = (event, delta) => {
65610
+ cancel(event);
65620
65611
  const {
65621
65612
  x: dx,
65622
65613
  y: dy
@@ -65628,20 +65619,33 @@
65628
65619
  const popupParent = getPopupParent(titleRef.current);
65629
65620
  popupParent.style.top = newPosition.y + 'px';
65630
65621
  popupParent.style.left = newPosition.x + 'px';
65631
- });
65622
+
65623
+ // notify interested parties
65624
+ emit('dragover', {
65625
+ newPosition,
65626
+ delta
65627
+ });
65628
+ };
65632
65629
  const onMoveStart = event => {
65633
65630
  // initialize drag handler
65634
65631
  const onDragStart = createDragger(onMove, dragPreviewRef.current);
65635
65632
  onDragStart(event);
65633
+ event.stopPropagation();
65636
65634
  const popupParent = getPopupParent(titleRef.current);
65637
65635
  const bounds = popupParent.getBoundingClientRect();
65638
65636
  context.current.startPosition = {
65639
65637
  x: bounds.left,
65640
65638
  y: bounds.top
65641
65639
  };
65640
+
65641
+ // notify interested parties
65642
+ emit('dragstart');
65642
65643
  };
65643
65644
  const onMoveEnd = () => {
65644
65645
  context.current.newPosition = null;
65646
+
65647
+ // notify interested parties
65648
+ emit('dragend');
65645
65649
  };
65646
65650
  return e$1("div", {
65647
65651
  class: classNames('bio-properties-panel-popup__header', draggable && 'draggable', className),
@@ -65694,11 +65698,19 @@
65694
65698
  function getPopupParent(node) {
65695
65699
  return node.closest('.bio-properties-panel-popup');
65696
65700
  }
65701
+ function cancel(event) {
65702
+ event.preventDefault();
65703
+ event.stopPropagation();
65704
+ }
65697
65705
  const FEEL_POPUP_WIDTH = 700;
65698
65706
  const FEEL_POPUP_HEIGHT = 250;
65699
65707
 
65700
65708
  /**
65701
- * FEEL popup component, built as a singleton.
65709
+ * FEEL popup component, built as a singleton. Emits lifecycle events as follows:
65710
+ * - `feelPopup.open` - fired before the popup is mounted
65711
+ * - `feelPopup.opened` - fired after the popup is mounted. Event context contains the DOM node of the popup
65712
+ * - `feelPopup.close` - fired before the popup is unmounted. Event context contains the DOM node of the popup
65713
+ * - `feelPopup.closed` - fired after the popup is unmounted
65702
65714
  */
65703
65715
  function FEELPopupRoot(props) {
65704
65716
  const {
@@ -65721,17 +65733,21 @@
65721
65733
  const isOpen = A$1(() => {
65722
65734
  return !!open;
65723
65735
  }, [open]);
65736
+ useUpdateEffect(() => {
65737
+ if (!open) {
65738
+ emit('closed');
65739
+ }
65740
+ }, [open]);
65724
65741
  const handleOpen = (entryId, config, _sourceElement) => {
65725
65742
  setSource(entryId);
65726
65743
  setPopupConfig(config);
65727
65744
  setOpen(true);
65728
65745
  setSourceElement(_sourceElement);
65729
- emit('opened');
65746
+ emit('open');
65730
65747
  };
65731
65748
  const handleClose = () => {
65732
65749
  setOpen(false);
65733
65750
  setSource(null);
65734
- emit('closed');
65735
65751
  };
65736
65752
  const feelPopupContext = {
65737
65753
  open: handleOpen,
@@ -65774,6 +65790,7 @@
65774
65790
  onClose: handleClose,
65775
65791
  container: popupContainer,
65776
65792
  sourceElement: sourceElement,
65793
+ emit: emit,
65777
65794
  ...popupConfig
65778
65795
  }), props.children]
65779
65796
  });
@@ -65792,9 +65809,11 @@
65792
65809
  tooltipContainer,
65793
65810
  type,
65794
65811
  value,
65795
- variables
65812
+ variables,
65813
+ emit
65796
65814
  } = props;
65797
65815
  const editorRef = s$1();
65816
+ const popupRef = s$1();
65798
65817
  const isAutoCompletionOpen = s$1(false);
65799
65818
  const handleSetReturnFocus = () => {
65800
65819
  sourceElement && sourceElement.focus();
@@ -65817,9 +65836,18 @@
65817
65836
  }
65818
65837
  }
65819
65838
  };
65839
+ y(() => {
65840
+ emit('opened', {
65841
+ domNode: popupRef.current
65842
+ });
65843
+ return () => emit('close', {
65844
+ domNode: popupRef.current
65845
+ });
65846
+ }, []);
65820
65847
  return e$1(Popup, {
65821
65848
  container: container,
65822
65849
  className: "bio-properties-panel-feel-popup",
65850
+ emit: emit,
65823
65851
  position: position,
65824
65852
  title: title,
65825
65853
  onClose: onClose
@@ -65833,8 +65861,10 @@
65833
65861
  onPostDeactivate: handleSetReturnFocus,
65834
65862
  height: FEEL_POPUP_HEIGHT,
65835
65863
  width: FEEL_POPUP_WIDTH,
65864
+ ref: popupRef,
65836
65865
  children: [e$1(Popup.Title, {
65837
65866
  title: title,
65867
+ emit: emit,
65838
65868
  draggable: true
65839
65869
  }), e$1(Popup.Body, {
65840
65870
  children: e$1("div", {
@@ -65884,6 +65914,23 @@
65884
65914
  function autoCompletionOpen(element) {
65885
65915
  return element.closest('.cm-editor').querySelector('.cm-tooltip-autocomplete');
65886
65916
  }
65917
+
65918
+ /**
65919
+ * This hook behaves like useEffect, but does not trigger on the first render.
65920
+ *
65921
+ * @param {Function} effect
65922
+ * @param {Array} deps
65923
+ */
65924
+ function useUpdateEffect(effect, deps) {
65925
+ const isMounted = s$1(false);
65926
+ y(() => {
65927
+ if (isMounted.current) {
65928
+ return effect();
65929
+ } else {
65930
+ isMounted.current = true;
65931
+ }
65932
+ }, deps);
65933
+ }
65887
65934
  function ToggleSwitch(props) {
65888
65935
  const {
65889
65936
  id,
@@ -66779,7 +66826,7 @@
66779
66826
 
66780
66827
  // todo(pinussilvestrus): make this configurable in the future
66781
66828
  function getPopupTitle(element, label) {
66782
- let popupTitle;
66829
+ let popupTitle = '';
66783
66830
  if (element && element.type) {
66784
66831
  popupTitle = `${element.type} / `;
66785
66832
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmn-io/form-js-playground",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "A form-js playground",
5
5
  "files": [
6
6
  "dist"
@@ -44,7 +44,7 @@
44
44
  "url": "https://github.com/bpmn-io"
45
45
  },
46
46
  "dependencies": {
47
- "@bpmn-io/form-js-editor": "^1.3.0",
47
+ "@bpmn-io/form-js-editor": "^1.3.1",
48
48
  "@bpmn-io/form-js-viewer": "^1.3.0",
49
49
  "@codemirror/autocomplete": "^6.3.4",
50
50
  "@codemirror/commands": "^6.1.2",
@@ -70,5 +70,5 @@
70
70
  "rollup-plugin-css-only": "^4.0.0",
71
71
  "style-loader": "^3.3.0"
72
72
  },
73
- "gitHead": "f7cc5395b19de74eb7d9183af38dc462170a6179"
73
+ "gitHead": "0c629e002118aaabaa538415e3c922e7f5d3ae4c"
74
74
  }