@bpmn-io/properties-panel 1.8.2 → 2.0.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.
@@ -113,7 +113,9 @@
113
113
  --font-family: sans-serif;
114
114
  --font-family-monospace: monospace;
115
115
 
116
- display: none;
116
+ display: flex;
117
+ flex-direction: column;
118
+ flex: 1;
117
119
  position: relative;
118
120
  height: 100%;
119
121
  width: 100%;
@@ -135,12 +137,6 @@
135
137
  font-family: var(--font-family);
136
138
  }
137
139
 
138
- .bio-properties-panel.open {
139
- display: flex;
140
- flex-direction: column;
141
- flex: 1;
142
- }
143
-
144
140
  /**
145
141
  * Placeholder (empty, multi select, ...)
146
142
  */
package/dist/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { useContext, useRef, useEffect, useMemo, useCallback, useState, useLayoutEffect } from '../preact/hooks';
2
2
  import { isFunction, isArray, get, assign, set, sortBy, find, isNumber, debounce } from 'min-dash';
3
- import classnames from 'classnames';
4
3
  import { forwardRef } from '../preact/compat';
5
4
  import { jsx, jsxs } from '../preact/jsx-runtime';
5
+ import classnames from 'classnames';
6
6
  import { query } from 'min-dom';
7
7
  import { createContext, createElement } from '../preact';
8
8
  import { FeelersEditor } from 'feelers';
@@ -383,6 +383,18 @@ function useShowEntryEvent(id) {
383
383
  * @param {setSticky} setSticky
384
384
  */
385
385
  function useStickyIntersectionObserver(ref, scrollContainerSelector, setSticky) {
386
+ const [scrollContainer, setScrollContainer] = useState(query(scrollContainerSelector));
387
+ const updateScrollContainer = useCallback(() => {
388
+ const newScrollContainer = query(scrollContainerSelector);
389
+ if (newScrollContainer !== scrollContainer) {
390
+ setScrollContainer(newScrollContainer);
391
+ }
392
+ }, [scrollContainerSelector, scrollContainer]);
393
+ useEffect(() => {
394
+ updateScrollContainer();
395
+ }, [updateScrollContainer]);
396
+ useEvent('propertiesPanel.attach', updateScrollContainer);
397
+ useEvent('propertiesPanel.detach', updateScrollContainer);
386
398
  useEffect(() => {
387
399
  const Observer = IntersectionObserver;
388
400
 
@@ -390,42 +402,36 @@ function useStickyIntersectionObserver(ref, scrollContainerSelector, setSticky)
390
402
  if (!Observer) {
391
403
  return;
392
404
  }
393
- let observer;
394
- if (ref.current) {
395
- const scrollContainer = query(scrollContainerSelector);
396
405
 
397
- // TODO(@barmac): test this
398
- if (!scrollContainer) {
406
+ // TODO(@barmac): test this
407
+ if (!ref.current || !scrollContainer) {
408
+ return;
409
+ }
410
+ const observer = new Observer(entries => {
411
+ // scroll container is unmounted, do not update sticky state
412
+ if (scrollContainer.scrollHeight === 0) {
399
413
  return;
400
414
  }
401
- observer = new Observer(entries => {
402
- // The ScrollContainer is unmounted, do not update sticky state
403
- if (scrollContainer.scrollHeight === 0) {
404
- return;
415
+ entries.forEach(entry => {
416
+ if (entry.intersectionRatio < 1) {
417
+ setSticky(true);
418
+ } else if (entry.intersectionRatio === 1) {
419
+ setSticky(false);
405
420
  }
406
- entries.forEach(entry => {
407
- if (entry.intersectionRatio < 1) {
408
- setSticky(true);
409
- } else if (entry.intersectionRatio === 1) {
410
- setSticky(false);
411
- }
412
- });
413
- }, {
414
- root: scrollContainer,
415
- rootMargin: '0px 0px 999999% 0px',
416
- // Use bottom margin to avoid stickyness when scrolling out to bottom
417
- threshold: [1]
418
421
  });
419
- observer.observe(ref.current);
420
- }
422
+ }, {
423
+ root: scrollContainer,
424
+ rootMargin: '0px 0px 999999% 0px',
425
+ // Use bottom margin to avoid stickyness when scrolling out to bottom
426
+ threshold: [1]
427
+ });
428
+ observer.observe(ref.current);
421
429
 
422
430
  // Unobserve if unmounted
423
431
  return () => {
424
- if (ref.current && observer) {
425
- observer.unobserve(ref.current);
426
- }
432
+ observer.unobserve(ref.current);
427
433
  };
428
- }, [ref.current, scrollContainerSelector, setSticky]);
434
+ }, [ref.current, scrollContainer, setSticky]);
429
435
  }
430
436
 
431
437
  /**
@@ -560,9 +566,7 @@ function Placeholder(props) {
560
566
  });
561
567
  }
562
568
 
563
- const DEFAULT_LAYOUT = {
564
- open: true
565
- };
569
+ const DEFAULT_LAYOUT = {};
566
570
  const DEFAULT_DESCRIPTION = {};
567
571
 
568
572
  /**
@@ -726,7 +730,7 @@ function PropertiesPanel(props) {
726
730
  children: jsx(EventContext.Provider, {
727
731
  value: eventContext,
728
732
  children: jsxs("div", {
729
- class: classnames('bio-properties-panel', layout.open ? 'open' : ''),
733
+ class: "bio-properties-panel",
730
734
  children: [jsx(Header, {
731
735
  element: element,
732
736
  headerProvider: headerProvider