react-resizable-panels 2.0.12 → 2.0.14

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.14
4
+
5
+ - Better account for high-precision `collapsedSize` values (#325)
6
+
7
+ ## 2.0.13
8
+
9
+ - Fix potential cycle in stacking-order logic for an unmounted node (#317)
10
+
3
11
  ## 2.0.12
4
12
 
5
13
  - Improve resize for edge cases with collapsed panels; intermediate resize states should now fall back to the most recent valid layout rather than the initial layout (#311)
@@ -349,7 +349,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
349
349
 
350
350
  /** @param {HTMLElement} node */
351
351
  function is_flex_item(node) {
352
- const display = getComputedStyle(get_parent(node)).display;
352
+ var _get_parent;
353
+ // @ts-ignore
354
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
353
355
  return display === "flex" || display === "inline-flex";
354
356
  }
355
357
 
@@ -399,6 +401,7 @@ function get_ancestors(node) {
399
401
  const ancestors = [];
400
402
  while (node) {
401
403
  ancestors.push(node);
404
+ // @ts-ignore
402
405
  node = get_parent(node);
403
406
  }
404
407
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -406,9 +409,13 @@ function get_ancestors(node) {
406
409
 
407
410
  /** @param {HTMLElement} node */
408
411
  function get_parent(node) {
409
- var _node$parentNode;
410
- // @ts-ignore
411
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
412
+ const {
413
+ parentNode
414
+ } = node;
415
+ if (parentNode && parentNode instanceof ShadowRoot) {
416
+ return parentNode.host;
417
+ }
418
+ return parentNode;
412
419
  }
413
420
 
414
421
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -680,15 +687,15 @@ function assert(expectedCondition, message) {
680
687
  const PRECISION = 10;
681
688
 
682
689
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
683
- actual = parseFloat(actual.toFixed(fractionDigits));
684
- expected = parseFloat(expected.toFixed(fractionDigits));
685
- const delta = actual - expected;
686
- if (delta === 0) {
690
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
687
691
  return 0;
688
692
  } else {
689
- return delta > 0 ? 1 : -1;
693
+ return actual > expected ? 1 : -1;
690
694
  }
691
695
  }
696
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
697
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
698
+ }
692
699
 
693
700
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
694
701
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1695,7 +1702,7 @@ function PanelGroupWithForwardedRef({
1695
1702
  pivotIndices
1696
1703
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1697
1704
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1698
- if (panelSize !== collapsedSize) {
1705
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1699
1706
  // Store size before collapse;
1700
1707
  // This is the size that gets restored if the expand() API is used.
1701
1708
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1734,11 +1741,11 @@ function PanelGroupWithForwardedRef({
1734
1741
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1735
1742
  const {
1736
1743
  collapsedSize = 0,
1737
- panelSize,
1744
+ panelSize = 0,
1738
1745
  minSize = 0,
1739
1746
  pivotIndices
1740
1747
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1741
- if (panelSize === collapsedSize) {
1748
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1742
1749
  // Restore this panel to the size it was before it was collapsed, if possible.
1743
1750
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1744
1751
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1803,7 +1810,8 @@ function PanelGroupWithForwardedRef({
1803
1810
  collapsible,
1804
1811
  panelSize
1805
1812
  } = panelDataHelper(panelDataArray, panelData, layout);
1806
- return collapsible === true && panelSize === collapsedSize;
1813
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1814
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1807
1815
  }, []);
1808
1816
 
1809
1817
  // External APIs are safe to memoize via committed values ref
@@ -1818,7 +1826,7 @@ function PanelGroupWithForwardedRef({
1818
1826
  panelSize
1819
1827
  } = panelDataHelper(panelDataArray, panelData, layout);
1820
1828
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1821
- return !collapsible || panelSize > collapsedSize;
1829
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1822
1830
  }, []);
1823
1831
  const registerPanel = useCallback(panelData => {
1824
1832
  const {
@@ -2027,8 +2035,8 @@ function PanelGroupWithForwardedRef({
2027
2035
  // It's possible that the panels in this group have changed since the last render
2028
2036
  return;
2029
2037
  }
2030
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
2031
- if (prevCollapsedSize !== nextCollapsedSize) {
2038
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
2039
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
2032
2040
  resizePanel(panelData, nextCollapsedSize);
2033
2041
  }
2034
2042
  } else if (prevPanelSize < nextMinSize) {
@@ -355,7 +355,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
355
355
 
356
356
  /** @param {HTMLElement} node */
357
357
  function is_flex_item(node) {
358
- const display = getComputedStyle(get_parent(node)).display;
358
+ var _get_parent;
359
+ // @ts-ignore
360
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
359
361
  return display === "flex" || display === "inline-flex";
360
362
  }
361
363
 
@@ -405,6 +407,7 @@ function get_ancestors(node) {
405
407
  const ancestors = [];
406
408
  while (node) {
407
409
  ancestors.push(node);
410
+ // @ts-ignore
408
411
  node = get_parent(node);
409
412
  }
410
413
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -412,9 +415,13 @@ function get_ancestors(node) {
412
415
 
413
416
  /** @param {HTMLElement} node */
414
417
  function get_parent(node) {
415
- var _node$parentNode;
416
- // @ts-ignore
417
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
418
+ const {
419
+ parentNode
420
+ } = node;
421
+ if (parentNode && parentNode instanceof ShadowRoot) {
422
+ return parentNode.host;
423
+ }
424
+ return parentNode;
418
425
  }
419
426
 
420
427
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -686,15 +693,15 @@ function assert(expectedCondition, message) {
686
693
  const PRECISION = 10;
687
694
 
688
695
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
689
- actual = parseFloat(actual.toFixed(fractionDigits));
690
- expected = parseFloat(expected.toFixed(fractionDigits));
691
- const delta = actual - expected;
692
- if (delta === 0) {
696
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
693
697
  return 0;
694
698
  } else {
695
- return delta > 0 ? 1 : -1;
699
+ return actual > expected ? 1 : -1;
696
700
  }
697
701
  }
702
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
703
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
704
+ }
698
705
 
699
706
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
700
707
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1801,7 +1808,7 @@ function PanelGroupWithForwardedRef({
1801
1808
  pivotIndices
1802
1809
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1803
1810
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1804
- if (panelSize !== collapsedSize) {
1811
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1805
1812
  // Store size before collapse;
1806
1813
  // This is the size that gets restored if the expand() API is used.
1807
1814
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1840,11 +1847,11 @@ function PanelGroupWithForwardedRef({
1840
1847
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1841
1848
  const {
1842
1849
  collapsedSize = 0,
1843
- panelSize,
1850
+ panelSize = 0,
1844
1851
  minSize = 0,
1845
1852
  pivotIndices
1846
1853
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1847
- if (panelSize === collapsedSize) {
1854
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1848
1855
  // Restore this panel to the size it was before it was collapsed, if possible.
1849
1856
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1850
1857
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1909,7 +1916,8 @@ function PanelGroupWithForwardedRef({
1909
1916
  collapsible,
1910
1917
  panelSize
1911
1918
  } = panelDataHelper(panelDataArray, panelData, layout);
1912
- return collapsible === true && panelSize === collapsedSize;
1919
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1920
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1913
1921
  }, []);
1914
1922
 
1915
1923
  // External APIs are safe to memoize via committed values ref
@@ -1924,7 +1932,7 @@ function PanelGroupWithForwardedRef({
1924
1932
  panelSize
1925
1933
  } = panelDataHelper(panelDataArray, panelData, layout);
1926
1934
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1927
- return !collapsible || panelSize > collapsedSize;
1935
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1928
1936
  }, []);
1929
1937
  const registerPanel = useCallback(panelData => {
1930
1938
  const {
@@ -2133,8 +2141,8 @@ function PanelGroupWithForwardedRef({
2133
2141
  // It's possible that the panels in this group have changed since the last render
2134
2142
  return;
2135
2143
  }
2136
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
2137
- if (prevCollapsedSize !== nextCollapsedSize) {
2144
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
2145
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
2138
2146
  resizePanel(panelData, nextCollapsedSize);
2139
2147
  }
2140
2148
  } else if (prevPanelSize < nextMinSize) {
@@ -331,7 +331,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
331
331
 
332
332
  /** @param {HTMLElement} node */
333
333
  function is_flex_item(node) {
334
- const display = getComputedStyle(get_parent(node)).display;
334
+ var _get_parent;
335
+ // @ts-ignore
336
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
335
337
  return display === "flex" || display === "inline-flex";
336
338
  }
337
339
 
@@ -381,6 +383,7 @@ function get_ancestors(node) {
381
383
  const ancestors = [];
382
384
  while (node) {
383
385
  ancestors.push(node);
386
+ // @ts-ignore
384
387
  node = get_parent(node);
385
388
  }
386
389
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -388,9 +391,13 @@ function get_ancestors(node) {
388
391
 
389
392
  /** @param {HTMLElement} node */
390
393
  function get_parent(node) {
391
- var _node$parentNode;
392
- // @ts-ignore
393
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
394
+ const {
395
+ parentNode
396
+ } = node;
397
+ if (parentNode && parentNode instanceof ShadowRoot) {
398
+ return parentNode.host;
399
+ }
400
+ return parentNode;
394
401
  }
395
402
 
396
403
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -662,15 +669,15 @@ function assert(expectedCondition, message) {
662
669
  const PRECISION = 10;
663
670
 
664
671
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
665
- actual = parseFloat(actual.toFixed(fractionDigits));
666
- expected = parseFloat(expected.toFixed(fractionDigits));
667
- const delta = actual - expected;
668
- if (delta === 0) {
672
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
669
673
  return 0;
670
674
  } else {
671
- return delta > 0 ? 1 : -1;
675
+ return actual > expected ? 1 : -1;
672
676
  }
673
677
  }
678
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
679
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
680
+ }
674
681
 
675
682
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
676
683
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1777,7 +1784,7 @@ function PanelGroupWithForwardedRef({
1777
1784
  pivotIndices
1778
1785
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1779
1786
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1780
- if (panelSize !== collapsedSize) {
1787
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1781
1788
  // Store size before collapse;
1782
1789
  // This is the size that gets restored if the expand() API is used.
1783
1790
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1816,11 +1823,11 @@ function PanelGroupWithForwardedRef({
1816
1823
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1817
1824
  const {
1818
1825
  collapsedSize = 0,
1819
- panelSize,
1826
+ panelSize = 0,
1820
1827
  minSize = 0,
1821
1828
  pivotIndices
1822
1829
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1823
- if (panelSize === collapsedSize) {
1830
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1824
1831
  // Restore this panel to the size it was before it was collapsed, if possible.
1825
1832
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1826
1833
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1885,7 +1892,8 @@ function PanelGroupWithForwardedRef({
1885
1892
  collapsible,
1886
1893
  panelSize
1887
1894
  } = panelDataHelper(panelDataArray, panelData, layout);
1888
- return collapsible === true && panelSize === collapsedSize;
1895
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1896
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1889
1897
  }, []);
1890
1898
 
1891
1899
  // External APIs are safe to memoize via committed values ref
@@ -1900,7 +1908,7 @@ function PanelGroupWithForwardedRef({
1900
1908
  panelSize
1901
1909
  } = panelDataHelper(panelDataArray, panelData, layout);
1902
1910
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1903
- return !collapsible || panelSize > collapsedSize;
1911
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1904
1912
  }, []);
1905
1913
  const registerPanel = useCallback(panelData => {
1906
1914
  const {
@@ -2109,8 +2117,8 @@ function PanelGroupWithForwardedRef({
2109
2117
  // It's possible that the panels in this group have changed since the last render
2110
2118
  return;
2111
2119
  }
2112
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
2113
- if (prevCollapsedSize !== nextCollapsedSize) {
2120
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
2121
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
2114
2122
  resizePanel(panelData, nextCollapsedSize);
2115
2123
  }
2116
2124
  } else if (prevPanelSize < nextMinSize) {
@@ -325,7 +325,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
325
325
 
326
326
  /** @param {HTMLElement} node */
327
327
  function is_flex_item(node) {
328
- const display = getComputedStyle(get_parent(node)).display;
328
+ var _get_parent;
329
+ // @ts-ignore
330
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
329
331
  return display === "flex" || display === "inline-flex";
330
332
  }
331
333
 
@@ -375,6 +377,7 @@ function get_ancestors(node) {
375
377
  const ancestors = [];
376
378
  while (node) {
377
379
  ancestors.push(node);
380
+ // @ts-ignore
378
381
  node = get_parent(node);
379
382
  }
380
383
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -382,9 +385,13 @@ function get_ancestors(node) {
382
385
 
383
386
  /** @param {HTMLElement} node */
384
387
  function get_parent(node) {
385
- var _node$parentNode;
386
- // @ts-ignore
387
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
388
+ const {
389
+ parentNode
390
+ } = node;
391
+ if (parentNode && parentNode instanceof ShadowRoot) {
392
+ return parentNode.host;
393
+ }
394
+ return parentNode;
388
395
  }
389
396
 
390
397
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -656,15 +663,15 @@ function assert(expectedCondition, message) {
656
663
  const PRECISION = 10;
657
664
 
658
665
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
659
- actual = parseFloat(actual.toFixed(fractionDigits));
660
- expected = parseFloat(expected.toFixed(fractionDigits));
661
- const delta = actual - expected;
662
- if (delta === 0) {
666
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
663
667
  return 0;
664
668
  } else {
665
- return delta > 0 ? 1 : -1;
669
+ return actual > expected ? 1 : -1;
666
670
  }
667
671
  }
672
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
673
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
674
+ }
668
675
 
669
676
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
670
677
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1671,7 +1678,7 @@ function PanelGroupWithForwardedRef({
1671
1678
  pivotIndices
1672
1679
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1673
1680
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1674
- if (panelSize !== collapsedSize) {
1681
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1675
1682
  // Store size before collapse;
1676
1683
  // This is the size that gets restored if the expand() API is used.
1677
1684
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1710,11 +1717,11 @@ function PanelGroupWithForwardedRef({
1710
1717
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1711
1718
  const {
1712
1719
  collapsedSize = 0,
1713
- panelSize,
1720
+ panelSize = 0,
1714
1721
  minSize = 0,
1715
1722
  pivotIndices
1716
1723
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1717
- if (panelSize === collapsedSize) {
1724
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1718
1725
  // Restore this panel to the size it was before it was collapsed, if possible.
1719
1726
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1720
1727
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1779,7 +1786,8 @@ function PanelGroupWithForwardedRef({
1779
1786
  collapsible,
1780
1787
  panelSize
1781
1788
  } = panelDataHelper(panelDataArray, panelData, layout);
1782
- return collapsible === true && panelSize === collapsedSize;
1789
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1790
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1783
1791
  }, []);
1784
1792
 
1785
1793
  // External APIs are safe to memoize via committed values ref
@@ -1794,7 +1802,7 @@ function PanelGroupWithForwardedRef({
1794
1802
  panelSize
1795
1803
  } = panelDataHelper(panelDataArray, panelData, layout);
1796
1804
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1797
- return !collapsible || panelSize > collapsedSize;
1805
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1798
1806
  }, []);
1799
1807
  const registerPanel = useCallback(panelData => {
1800
1808
  const {
@@ -2003,8 +2011,8 @@ function PanelGroupWithForwardedRef({
2003
2011
  // It's possible that the panels in this group have changed since the last render
2004
2012
  return;
2005
2013
  }
2006
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
2007
- if (prevCollapsedSize !== nextCollapsedSize) {
2014
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
2015
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
2008
2016
  resizePanel(panelData, nextCollapsedSize);
2009
2017
  }
2010
2018
  } else if (prevPanelSize < nextMinSize) {
@@ -351,7 +351,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
351
351
 
352
352
  /** @param {HTMLElement} node */
353
353
  function is_flex_item(node) {
354
- const display = getComputedStyle(get_parent(node)).display;
354
+ var _get_parent;
355
+ // @ts-ignore
356
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
355
357
  return display === "flex" || display === "inline-flex";
356
358
  }
357
359
 
@@ -401,6 +403,7 @@ function get_ancestors(node) {
401
403
  const ancestors = [];
402
404
  while (node) {
403
405
  ancestors.push(node);
406
+ // @ts-ignore
404
407
  node = get_parent(node);
405
408
  }
406
409
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -408,9 +411,13 @@ function get_ancestors(node) {
408
411
 
409
412
  /** @param {HTMLElement} node */
410
413
  function get_parent(node) {
411
- var _node$parentNode;
412
- // @ts-ignore
413
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
414
+ const {
415
+ parentNode
416
+ } = node;
417
+ if (parentNode && parentNode instanceof ShadowRoot) {
418
+ return parentNode.host;
419
+ }
420
+ return parentNode;
414
421
  }
415
422
 
416
423
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -682,15 +689,15 @@ function assert(expectedCondition, message) {
682
689
  const PRECISION = 10;
683
690
 
684
691
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
685
- actual = parseFloat(actual.toFixed(fractionDigits));
686
- expected = parseFloat(expected.toFixed(fractionDigits));
687
- const delta = actual - expected;
688
- if (delta === 0) {
692
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
689
693
  return 0;
690
694
  } else {
691
- return delta > 0 ? 1 : -1;
695
+ return actual > expected ? 1 : -1;
692
696
  }
693
697
  }
698
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
699
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
700
+ }
694
701
 
695
702
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
696
703
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1697,7 +1704,7 @@ function PanelGroupWithForwardedRef({
1697
1704
  pivotIndices
1698
1705
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1699
1706
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1700
- if (panelSize !== collapsedSize) {
1707
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1701
1708
  // Store size before collapse;
1702
1709
  // This is the size that gets restored if the expand() API is used.
1703
1710
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1736,11 +1743,11 @@ function PanelGroupWithForwardedRef({
1736
1743
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1737
1744
  const {
1738
1745
  collapsedSize = 0,
1739
- panelSize,
1746
+ panelSize = 0,
1740
1747
  minSize = 0,
1741
1748
  pivotIndices
1742
1749
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1743
- if (panelSize === collapsedSize) {
1750
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1744
1751
  // Restore this panel to the size it was before it was collapsed, if possible.
1745
1752
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1746
1753
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1805,7 +1812,8 @@ function PanelGroupWithForwardedRef({
1805
1812
  collapsible,
1806
1813
  panelSize
1807
1814
  } = panelDataHelper(panelDataArray, panelData, layout);
1808
- return collapsible === true && panelSize === collapsedSize;
1815
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1816
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1809
1817
  }, []);
1810
1818
 
1811
1819
  // External APIs are safe to memoize via committed values ref
@@ -1820,7 +1828,7 @@ function PanelGroupWithForwardedRef({
1820
1828
  panelSize
1821
1829
  } = panelDataHelper(panelDataArray, panelData, layout);
1822
1830
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1823
- return !collapsible || panelSize > collapsedSize;
1831
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1824
1832
  }, []);
1825
1833
  const registerPanel = useCallback(panelData => {
1826
1834
  const {
@@ -2029,8 +2037,8 @@ function PanelGroupWithForwardedRef({
2029
2037
  // It's possible that the panels in this group have changed since the last render
2030
2038
  return;
2031
2039
  }
2032
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
2033
- if (prevCollapsedSize !== nextCollapsedSize) {
2040
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
2041
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
2034
2042
  resizePanel(panelData, nextCollapsedSize);
2035
2043
  }
2036
2044
  } else if (prevPanelSize < nextMinSize) {
@@ -362,7 +362,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
362
362
 
363
363
  /** @param {HTMLElement} node */
364
364
  function is_flex_item(node) {
365
- const display = getComputedStyle(get_parent(node)).display;
365
+ var _get_parent;
366
+ // @ts-ignore
367
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
366
368
  return display === "flex" || display === "inline-flex";
367
369
  }
368
370
 
@@ -412,6 +414,7 @@ function get_ancestors(node) {
412
414
  const ancestors = [];
413
415
  while (node) {
414
416
  ancestors.push(node);
417
+ // @ts-ignore
415
418
  node = get_parent(node);
416
419
  }
417
420
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -419,9 +422,13 @@ function get_ancestors(node) {
419
422
 
420
423
  /** @param {HTMLElement} node */
421
424
  function get_parent(node) {
422
- var _node$parentNode;
423
- // @ts-ignore
424
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
425
+ const {
426
+ parentNode
427
+ } = node;
428
+ if (parentNode && parentNode instanceof ShadowRoot) {
429
+ return parentNode.host;
430
+ }
431
+ return parentNode;
425
432
  }
426
433
 
427
434
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -693,15 +700,15 @@ function assert(expectedCondition, message) {
693
700
  const PRECISION = 10;
694
701
 
695
702
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
696
- actual = parseFloat(actual.toFixed(fractionDigits));
697
- expected = parseFloat(expected.toFixed(fractionDigits));
698
- const delta = actual - expected;
699
- if (delta === 0) {
703
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
700
704
  return 0;
701
705
  } else {
702
- return delta > 0 ? 1 : -1;
706
+ return actual > expected ? 1 : -1;
703
707
  }
704
708
  }
709
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
710
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
711
+ }
705
712
 
706
713
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
707
714
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1808,7 +1815,7 @@ function PanelGroupWithForwardedRef({
1808
1815
  pivotIndices
1809
1816
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1810
1817
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1811
- if (panelSize !== collapsedSize) {
1818
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1812
1819
  // Store size before collapse;
1813
1820
  // This is the size that gets restored if the expand() API is used.
1814
1821
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1847,11 +1854,11 @@ function PanelGroupWithForwardedRef({
1847
1854
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1848
1855
  const {
1849
1856
  collapsedSize = 0,
1850
- panelSize,
1857
+ panelSize = 0,
1851
1858
  minSize = 0,
1852
1859
  pivotIndices
1853
1860
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1854
- if (panelSize === collapsedSize) {
1861
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1855
1862
  // Restore this panel to the size it was before it was collapsed, if possible.
1856
1863
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1857
1864
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1916,7 +1923,8 @@ function PanelGroupWithForwardedRef({
1916
1923
  collapsible,
1917
1924
  panelSize
1918
1925
  } = panelDataHelper(panelDataArray, panelData, layout);
1919
- return collapsible === true && panelSize === collapsedSize;
1926
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1927
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1920
1928
  }, []);
1921
1929
 
1922
1930
  // External APIs are safe to memoize via committed values ref
@@ -1931,7 +1939,7 @@ function PanelGroupWithForwardedRef({
1931
1939
  panelSize
1932
1940
  } = panelDataHelper(panelDataArray, panelData, layout);
1933
1941
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1934
- return !collapsible || panelSize > collapsedSize;
1942
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1935
1943
  }, []);
1936
1944
  const registerPanel = useCallback(panelData => {
1937
1945
  const {
@@ -2140,8 +2148,8 @@ function PanelGroupWithForwardedRef({
2140
2148
  // It's possible that the panels in this group have changed since the last render
2141
2149
  return;
2142
2150
  }
2143
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
2144
- if (prevCollapsedSize !== nextCollapsedSize) {
2151
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
2152
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
2145
2153
  resizePanel(panelData, nextCollapsedSize);
2146
2154
  }
2147
2155
  } else if (prevPanelSize < nextMinSize) {