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.
@@ -338,7 +338,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
338
338
 
339
339
  /** @param {HTMLElement} node */
340
340
  function is_flex_item(node) {
341
- const display = getComputedStyle(get_parent(node)).display;
341
+ var _get_parent;
342
+ // @ts-ignore
343
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
342
344
  return display === "flex" || display === "inline-flex";
343
345
  }
344
346
 
@@ -388,6 +390,7 @@ function get_ancestors(node) {
388
390
  const ancestors = [];
389
391
  while (node) {
390
392
  ancestors.push(node);
393
+ // @ts-ignore
391
394
  node = get_parent(node);
392
395
  }
393
396
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -395,9 +398,13 @@ function get_ancestors(node) {
395
398
 
396
399
  /** @param {HTMLElement} node */
397
400
  function get_parent(node) {
398
- var _node$parentNode;
399
- // @ts-ignore
400
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
401
+ const {
402
+ parentNode
403
+ } = node;
404
+ if (parentNode && parentNode instanceof ShadowRoot) {
405
+ return parentNode.host;
406
+ }
407
+ return parentNode;
401
408
  }
402
409
 
403
410
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -669,15 +676,15 @@ function assert(expectedCondition, message) {
669
676
  const PRECISION = 10;
670
677
 
671
678
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
672
- actual = parseFloat(actual.toFixed(fractionDigits));
673
- expected = parseFloat(expected.toFixed(fractionDigits));
674
- const delta = actual - expected;
675
- if (delta === 0) {
679
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
676
680
  return 0;
677
681
  } else {
678
- return delta > 0 ? 1 : -1;
682
+ return actual > expected ? 1 : -1;
679
683
  }
680
684
  }
685
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
686
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
687
+ }
681
688
 
682
689
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
683
690
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1784,7 +1791,7 @@ function PanelGroupWithForwardedRef({
1784
1791
  pivotIndices
1785
1792
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1786
1793
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1787
- if (panelSize !== collapsedSize) {
1794
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1788
1795
  // Store size before collapse;
1789
1796
  // This is the size that gets restored if the expand() API is used.
1790
1797
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1823,11 +1830,11 @@ function PanelGroupWithForwardedRef({
1823
1830
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1824
1831
  const {
1825
1832
  collapsedSize = 0,
1826
- panelSize,
1833
+ panelSize = 0,
1827
1834
  minSize = 0,
1828
1835
  pivotIndices
1829
1836
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1830
- if (panelSize === collapsedSize) {
1837
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1831
1838
  // Restore this panel to the size it was before it was collapsed, if possible.
1832
1839
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1833
1840
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1892,7 +1899,8 @@ function PanelGroupWithForwardedRef({
1892
1899
  collapsible,
1893
1900
  panelSize
1894
1901
  } = panelDataHelper(panelDataArray, panelData, layout);
1895
- return collapsible === true && panelSize === collapsedSize;
1902
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1903
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1896
1904
  }, []);
1897
1905
 
1898
1906
  // External APIs are safe to memoize via committed values ref
@@ -1907,7 +1915,7 @@ function PanelGroupWithForwardedRef({
1907
1915
  panelSize
1908
1916
  } = panelDataHelper(panelDataArray, panelData, layout);
1909
1917
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1910
- return !collapsible || panelSize > collapsedSize;
1918
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1911
1919
  }, []);
1912
1920
  const registerPanel = useCallback(panelData => {
1913
1921
  const {
@@ -2116,8 +2124,8 @@ function PanelGroupWithForwardedRef({
2116
2124
  // It's possible that the panels in this group have changed since the last render
2117
2125
  return;
2118
2126
  }
2119
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
2120
- if (prevCollapsedSize !== nextCollapsedSize) {
2127
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
2128
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
2121
2129
  resizePanel(panelData, nextCollapsedSize);
2122
2130
  }
2123
2131
  } else if (prevPanelSize < nextMinSize) {
@@ -324,7 +324,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
324
324
 
325
325
  /** @param {HTMLElement} node */
326
326
  function is_flex_item(node) {
327
- const display = getComputedStyle(get_parent(node)).display;
327
+ var _get_parent;
328
+ // @ts-ignore
329
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
328
330
  return display === "flex" || display === "inline-flex";
329
331
  }
330
332
 
@@ -374,6 +376,7 @@ function get_ancestors(node) {
374
376
  const ancestors = [];
375
377
  while (node) {
376
378
  ancestors.push(node);
379
+ // @ts-ignore
377
380
  node = get_parent(node);
378
381
  }
379
382
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -381,9 +384,13 @@ function get_ancestors(node) {
381
384
 
382
385
  /** @param {HTMLElement} node */
383
386
  function get_parent(node) {
384
- var _node$parentNode;
385
- // @ts-ignore
386
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
387
+ const {
388
+ parentNode
389
+ } = node;
390
+ if (parentNode && parentNode instanceof ShadowRoot) {
391
+ return parentNode.host;
392
+ }
393
+ return parentNode;
387
394
  }
388
395
 
389
396
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -655,15 +662,15 @@ function assert(expectedCondition, message) {
655
662
  const PRECISION = 10;
656
663
 
657
664
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
658
- actual = parseFloat(actual.toFixed(fractionDigits));
659
- expected = parseFloat(expected.toFixed(fractionDigits));
660
- const delta = actual - expected;
661
- if (delta === 0) {
665
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
662
666
  return 0;
663
667
  } else {
664
- return delta > 0 ? 1 : -1;
668
+ return actual > expected ? 1 : -1;
665
669
  }
666
670
  }
671
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
672
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
673
+ }
667
674
 
668
675
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
669
676
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1632,7 +1639,7 @@ function PanelGroupWithForwardedRef({
1632
1639
  pivotIndices
1633
1640
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1634
1641
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1635
- if (panelSize !== collapsedSize) {
1642
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1636
1643
  // Store size before collapse;
1637
1644
  // This is the size that gets restored if the expand() API is used.
1638
1645
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1671,11 +1678,11 @@ function PanelGroupWithForwardedRef({
1671
1678
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1672
1679
  const {
1673
1680
  collapsedSize = 0,
1674
- panelSize,
1681
+ panelSize = 0,
1675
1682
  minSize = 0,
1676
1683
  pivotIndices
1677
1684
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1678
- if (panelSize === collapsedSize) {
1685
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1679
1686
  // Restore this panel to the size it was before it was collapsed, if possible.
1680
1687
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1681
1688
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1740,7 +1747,8 @@ function PanelGroupWithForwardedRef({
1740
1747
  collapsible,
1741
1748
  panelSize
1742
1749
  } = panelDataHelper(panelDataArray, panelData, layout);
1743
- return collapsible === true && panelSize === collapsedSize;
1750
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1751
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1744
1752
  }, []);
1745
1753
 
1746
1754
  // External APIs are safe to memoize via committed values ref
@@ -1755,7 +1763,7 @@ function PanelGroupWithForwardedRef({
1755
1763
  panelSize
1756
1764
  } = panelDataHelper(panelDataArray, panelData, layout);
1757
1765
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1758
- return !collapsible || panelSize > collapsedSize;
1766
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1759
1767
  }, []);
1760
1768
  const registerPanel = useCallback(panelData => {
1761
1769
  const {
@@ -1908,8 +1916,8 @@ function PanelGroupWithForwardedRef({
1908
1916
  // It's possible that the panels in this group have changed since the last render
1909
1917
  return;
1910
1918
  }
1911
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
1912
- if (prevCollapsedSize !== nextCollapsedSize) {
1919
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
1920
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
1913
1921
  resizePanel(panelData, nextCollapsedSize);
1914
1922
  }
1915
1923
  } else if (prevPanelSize < nextMinSize) {
@@ -300,7 +300,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
300
300
 
301
301
  /** @param {HTMLElement} node */
302
302
  function is_flex_item(node) {
303
- const display = getComputedStyle(get_parent(node)).display;
303
+ var _get_parent;
304
+ // @ts-ignore
305
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
304
306
  return display === "flex" || display === "inline-flex";
305
307
  }
306
308
 
@@ -350,6 +352,7 @@ function get_ancestors(node) {
350
352
  const ancestors = [];
351
353
  while (node) {
352
354
  ancestors.push(node);
355
+ // @ts-ignore
353
356
  node = get_parent(node);
354
357
  }
355
358
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -357,9 +360,13 @@ function get_ancestors(node) {
357
360
 
358
361
  /** @param {HTMLElement} node */
359
362
  function get_parent(node) {
360
- var _node$parentNode;
361
- // @ts-ignore
362
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
363
+ const {
364
+ parentNode
365
+ } = node;
366
+ if (parentNode && parentNode instanceof ShadowRoot) {
367
+ return parentNode.host;
368
+ }
369
+ return parentNode;
363
370
  }
364
371
 
365
372
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -631,15 +638,15 @@ function assert(expectedCondition, message) {
631
638
  const PRECISION = 10;
632
639
 
633
640
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
634
- actual = parseFloat(actual.toFixed(fractionDigits));
635
- expected = parseFloat(expected.toFixed(fractionDigits));
636
- const delta = actual - expected;
637
- if (delta === 0) {
641
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
638
642
  return 0;
639
643
  } else {
640
- return delta > 0 ? 1 : -1;
644
+ return actual > expected ? 1 : -1;
641
645
  }
642
646
  }
647
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
648
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
649
+ }
643
650
 
644
651
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
645
652
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1608,7 +1615,7 @@ function PanelGroupWithForwardedRef({
1608
1615
  pivotIndices
1609
1616
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1610
1617
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1611
- if (panelSize !== collapsedSize) {
1618
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1612
1619
  // Store size before collapse;
1613
1620
  // This is the size that gets restored if the expand() API is used.
1614
1621
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1647,11 +1654,11 @@ function PanelGroupWithForwardedRef({
1647
1654
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1648
1655
  const {
1649
1656
  collapsedSize = 0,
1650
- panelSize,
1657
+ panelSize = 0,
1651
1658
  minSize = 0,
1652
1659
  pivotIndices
1653
1660
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1654
- if (panelSize === collapsedSize) {
1661
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1655
1662
  // Restore this panel to the size it was before it was collapsed, if possible.
1656
1663
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1657
1664
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1716,7 +1723,8 @@ function PanelGroupWithForwardedRef({
1716
1723
  collapsible,
1717
1724
  panelSize
1718
1725
  } = panelDataHelper(panelDataArray, panelData, layout);
1719
- return collapsible === true && panelSize === collapsedSize;
1726
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1727
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1720
1728
  }, []);
1721
1729
 
1722
1730
  // External APIs are safe to memoize via committed values ref
@@ -1731,7 +1739,7 @@ function PanelGroupWithForwardedRef({
1731
1739
  panelSize
1732
1740
  } = panelDataHelper(panelDataArray, panelData, layout);
1733
1741
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1734
- return !collapsible || panelSize > collapsedSize;
1742
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1735
1743
  }, []);
1736
1744
  const registerPanel = useCallback(panelData => {
1737
1745
  const {
@@ -1884,8 +1892,8 @@ function PanelGroupWithForwardedRef({
1884
1892
  // It's possible that the panels in this group have changed since the last render
1885
1893
  return;
1886
1894
  }
1887
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
1888
- if (prevCollapsedSize !== nextCollapsedSize) {
1895
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
1896
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
1889
1897
  resizePanel(panelData, nextCollapsedSize);
1890
1898
  }
1891
1899
  } else if (prevPanelSize < nextMinSize) {
@@ -327,7 +327,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
327
327
 
328
328
  /** @param {HTMLElement} node */
329
329
  function is_flex_item(node) {
330
- const display = getComputedStyle(get_parent(node)).display;
330
+ var _get_parent;
331
+ // @ts-ignore
332
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
331
333
  return display === "flex" || display === "inline-flex";
332
334
  }
333
335
 
@@ -377,6 +379,7 @@ function get_ancestors(node) {
377
379
  const ancestors = [];
378
380
  while (node) {
379
381
  ancestors.push(node);
382
+ // @ts-ignore
380
383
  node = get_parent(node);
381
384
  }
382
385
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -384,9 +387,13 @@ function get_ancestors(node) {
384
387
 
385
388
  /** @param {HTMLElement} node */
386
389
  function get_parent(node) {
387
- var _node$parentNode;
388
- // @ts-ignore
389
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
390
+ const {
391
+ parentNode
392
+ } = node;
393
+ if (parentNode && parentNode instanceof ShadowRoot) {
394
+ return parentNode.host;
395
+ }
396
+ return parentNode;
390
397
  }
391
398
 
392
399
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -658,15 +665,15 @@ function assert(expectedCondition, message) {
658
665
  const PRECISION = 10;
659
666
 
660
667
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
661
- actual = parseFloat(actual.toFixed(fractionDigits));
662
- expected = parseFloat(expected.toFixed(fractionDigits));
663
- const delta = actual - expected;
664
- if (delta === 0) {
668
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
665
669
  return 0;
666
670
  } else {
667
- return delta > 0 ? 1 : -1;
671
+ return actual > expected ? 1 : -1;
668
672
  }
669
673
  }
674
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
675
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
676
+ }
670
677
 
671
678
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
672
679
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1673,7 +1680,7 @@ function PanelGroupWithForwardedRef({
1673
1680
  pivotIndices
1674
1681
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1675
1682
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1676
- if (panelSize !== collapsedSize) {
1683
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1677
1684
  // Store size before collapse;
1678
1685
  // This is the size that gets restored if the expand() API is used.
1679
1686
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1712,11 +1719,11 @@ function PanelGroupWithForwardedRef({
1712
1719
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1713
1720
  const {
1714
1721
  collapsedSize = 0,
1715
- panelSize,
1722
+ panelSize = 0,
1716
1723
  minSize = 0,
1717
1724
  pivotIndices
1718
1725
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1719
- if (panelSize === collapsedSize) {
1726
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1720
1727
  // Restore this panel to the size it was before it was collapsed, if possible.
1721
1728
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1722
1729
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1781,7 +1788,8 @@ function PanelGroupWithForwardedRef({
1781
1788
  collapsible,
1782
1789
  panelSize
1783
1790
  } = panelDataHelper(panelDataArray, panelData, layout);
1784
- return collapsible === true && panelSize === collapsedSize;
1791
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1792
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1785
1793
  }, []);
1786
1794
 
1787
1795
  // External APIs are safe to memoize via committed values ref
@@ -1796,7 +1804,7 @@ function PanelGroupWithForwardedRef({
1796
1804
  panelSize
1797
1805
  } = panelDataHelper(panelDataArray, panelData, layout);
1798
1806
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1799
- return !collapsible || panelSize > collapsedSize;
1807
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1800
1808
  }, []);
1801
1809
  const registerPanel = useCallback(panelData => {
1802
1810
  const {
@@ -2005,8 +2013,8 @@ function PanelGroupWithForwardedRef({
2005
2013
  // It's possible that the panels in this group have changed since the last render
2006
2014
  return;
2007
2015
  }
2008
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
2009
- if (prevCollapsedSize !== nextCollapsedSize) {
2016
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
2017
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
2010
2018
  resizePanel(panelData, nextCollapsedSize);
2011
2019
  }
2012
2020
  } else if (prevPanelSize < nextMinSize) {
@@ -313,7 +313,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
313
313
 
314
314
  /** @param {HTMLElement} node */
315
315
  function is_flex_item(node) {
316
- const display = getComputedStyle(get_parent(node)).display;
316
+ var _get_parent;
317
+ // @ts-ignore
318
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
317
319
  return display === "flex" || display === "inline-flex";
318
320
  }
319
321
 
@@ -363,6 +365,7 @@ function get_ancestors(node) {
363
365
  const ancestors = [];
364
366
  while (node) {
365
367
  ancestors.push(node);
368
+ // @ts-ignore
366
369
  node = get_parent(node);
367
370
  }
368
371
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -370,9 +373,13 @@ function get_ancestors(node) {
370
373
 
371
374
  /** @param {HTMLElement} node */
372
375
  function get_parent(node) {
373
- var _node$parentNode;
374
- // @ts-ignore
375
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
376
+ const {
377
+ parentNode
378
+ } = node;
379
+ if (parentNode && parentNode instanceof ShadowRoot) {
380
+ return parentNode.host;
381
+ }
382
+ return parentNode;
376
383
  }
377
384
 
378
385
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -644,15 +651,15 @@ function assert(expectedCondition, message) {
644
651
  const PRECISION = 10;
645
652
 
646
653
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
647
- actual = parseFloat(actual.toFixed(fractionDigits));
648
- expected = parseFloat(expected.toFixed(fractionDigits));
649
- const delta = actual - expected;
650
- if (delta === 0) {
654
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
651
655
  return 0;
652
656
  } else {
653
- return delta > 0 ? 1 : -1;
657
+ return actual > expected ? 1 : -1;
654
658
  }
655
659
  }
660
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
661
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
662
+ }
656
663
 
657
664
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
658
665
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1531,7 +1538,7 @@ function PanelGroupWithForwardedRef({
1531
1538
  pivotIndices
1532
1539
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1533
1540
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1534
- if (panelSize !== collapsedSize) {
1541
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1535
1542
  // Store size before collapse;
1536
1543
  // This is the size that gets restored if the expand() API is used.
1537
1544
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1570,11 +1577,11 @@ function PanelGroupWithForwardedRef({
1570
1577
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1571
1578
  const {
1572
1579
  collapsedSize = 0,
1573
- panelSize,
1580
+ panelSize = 0,
1574
1581
  minSize = 0,
1575
1582
  pivotIndices
1576
1583
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1577
- if (panelSize === collapsedSize) {
1584
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1578
1585
  // Restore this panel to the size it was before it was collapsed, if possible.
1579
1586
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1580
1587
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1639,7 +1646,8 @@ function PanelGroupWithForwardedRef({
1639
1646
  collapsible,
1640
1647
  panelSize
1641
1648
  } = panelDataHelper(panelDataArray, panelData, layout);
1642
- return collapsible === true && panelSize === collapsedSize;
1649
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1650
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1643
1651
  }, []);
1644
1652
 
1645
1653
  // External APIs are safe to memoize via committed values ref
@@ -1654,7 +1662,7 @@ function PanelGroupWithForwardedRef({
1654
1662
  panelSize
1655
1663
  } = panelDataHelper(panelDataArray, panelData, layout);
1656
1664
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1657
- return !collapsible || panelSize > collapsedSize;
1665
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1658
1666
  }, []);
1659
1667
  const registerPanel = useCallback(panelData => {
1660
1668
  const {
@@ -1807,8 +1815,8 @@ function PanelGroupWithForwardedRef({
1807
1815
  // It's possible that the panels in this group have changed since the last render
1808
1816
  return;
1809
1817
  }
1810
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
1811
- if (prevCollapsedSize !== nextCollapsedSize) {
1818
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
1819
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
1812
1820
  resizePanel(panelData, nextCollapsedSize);
1813
1821
  }
1814
1822
  } else if (prevPanelSize < nextMinSize) {
@@ -289,7 +289,9 @@ const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMo
289
289
 
290
290
  /** @param {HTMLElement} node */
291
291
  function is_flex_item(node) {
292
- const display = getComputedStyle(get_parent(node)).display;
292
+ var _get_parent;
293
+ // @ts-ignore
294
+ const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== void 0 ? _get_parent : node).display;
293
295
  return display === "flex" || display === "inline-flex";
294
296
  }
295
297
 
@@ -339,6 +341,7 @@ function get_ancestors(node) {
339
341
  const ancestors = [];
340
342
  while (node) {
341
343
  ancestors.push(node);
344
+ // @ts-ignore
342
345
  node = get_parent(node);
343
346
  }
344
347
  return ancestors; // [ node, ... <body>, <html>, document ]
@@ -346,9 +349,13 @@ function get_ancestors(node) {
346
349
 
347
350
  /** @param {HTMLElement} node */
348
351
  function get_parent(node) {
349
- var _node$parentNode;
350
- // @ts-ignore
351
- return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
352
+ const {
353
+ parentNode
354
+ } = node;
355
+ if (parentNode && parentNode instanceof ShadowRoot) {
356
+ return parentNode.host;
357
+ }
358
+ return parentNode;
352
359
  }
353
360
 
354
361
  const EXCEEDED_HORIZONTAL_MIN = 0b0001;
@@ -620,15 +627,15 @@ function assert(expectedCondition, message) {
620
627
  const PRECISION = 10;
621
628
 
622
629
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
623
- actual = parseFloat(actual.toFixed(fractionDigits));
624
- expected = parseFloat(expected.toFixed(fractionDigits));
625
- const delta = actual - expected;
626
- if (delta === 0) {
630
+ if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
627
631
  return 0;
628
632
  } else {
629
- return delta > 0 ? 1 : -1;
633
+ return actual > expected ? 1 : -1;
630
634
  }
631
635
  }
636
+ function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
637
+ return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
638
+ }
632
639
 
633
640
  function fuzzyNumbersEqual(actual, expected, fractionDigits) {
634
641
  return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
@@ -1507,7 +1514,7 @@ function PanelGroupWithForwardedRef({
1507
1514
  pivotIndices
1508
1515
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1509
1516
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1510
- if (panelSize !== collapsedSize) {
1517
+ if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1511
1518
  // Store size before collapse;
1512
1519
  // This is the size that gets restored if the expand() API is used.
1513
1520
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
@@ -1546,11 +1553,11 @@ function PanelGroupWithForwardedRef({
1546
1553
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1547
1554
  const {
1548
1555
  collapsedSize = 0,
1549
- panelSize,
1556
+ panelSize = 0,
1550
1557
  minSize = 0,
1551
1558
  pivotIndices
1552
1559
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1553
- if (panelSize === collapsedSize) {
1560
+ if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
1554
1561
  // Restore this panel to the size it was before it was collapsed, if possible.
1555
1562
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1556
1563
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
@@ -1615,7 +1622,8 @@ function PanelGroupWithForwardedRef({
1615
1622
  collapsible,
1616
1623
  panelSize
1617
1624
  } = panelDataHelper(panelDataArray, panelData, layout);
1618
- return collapsible === true && panelSize === collapsedSize;
1625
+ assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1626
+ return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
1619
1627
  }, []);
1620
1628
 
1621
1629
  // External APIs are safe to memoize via committed values ref
@@ -1630,7 +1638,7 @@ function PanelGroupWithForwardedRef({
1630
1638
  panelSize
1631
1639
  } = panelDataHelper(panelDataArray, panelData, layout);
1632
1640
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1633
- return !collapsible || panelSize > collapsedSize;
1641
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1634
1642
  }, []);
1635
1643
  const registerPanel = useCallback(panelData => {
1636
1644
  const {
@@ -1783,8 +1791,8 @@ function PanelGroupWithForwardedRef({
1783
1791
  // It's possible that the panels in this group have changed since the last render
1784
1792
  return;
1785
1793
  }
1786
- if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
1787
- if (prevCollapsedSize !== nextCollapsedSize) {
1794
+ if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
1795
+ if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
1788
1796
  resizePanel(panelData, nextCollapsedSize);
1789
1797
  }
1790
1798
  } else if (prevPanelSize < nextMinSize) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable-panels",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
4
4
  "description": "React components for resizable panel groups/layouts",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
6
6
  "license": "MIT",