react-resizable-panels 0.0.58 → 0.0.59
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 +6 -0
- package/dist/react-resizable-panels.browser.cjs.js +77 -20
- package/dist/react-resizable-panels.browser.development.cjs.js +77 -20
- package/dist/react-resizable-panels.browser.development.esm.js +77 -20
- package/dist/react-resizable-panels.browser.esm.js +77 -20
- package/dist/react-resizable-panels.cjs.js +77 -20
- package/dist/react-resizable-panels.cjs.js.map +1 -1
- package/dist/react-resizable-panels.development.cjs.js +77 -20
- package/dist/react-resizable-panels.development.esm.js +77 -20
- package/dist/react-resizable-panels.development.node.cjs.js +46 -18
- package/dist/react-resizable-panels.development.node.esm.js +46 -18
- package/dist/react-resizable-panels.esm.js +77 -20
- package/dist/react-resizable-panels.esm.js.map +1 -1
- package/dist/react-resizable-panels.node.cjs.js +46 -18
- package/dist/react-resizable-panels.node.esm.js +46 -18
- package/package.json +1 -1
- package/src/PanelGroup.ts +84 -2
- package/src/hooks/useWindowSplitterPanelGroupBehavior.ts +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.59
|
|
4
|
+
|
|
5
|
+
- Support imperative panel API usage on-mount.
|
|
6
|
+
- Made PanelGroup bailout condition smarter (don't bailout for empty groups unless pixel constraints are used).
|
|
7
|
+
- Improved window splitter compatibility by better handling "Enter" key.
|
|
8
|
+
|
|
3
9
|
## 0.0.58
|
|
4
10
|
|
|
5
11
|
- Change group layout to more thoroughly distribute resize delta to support more flexible group size configurations.
|
|
@@ -198,8 +198,6 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
198
198
|
PanelWithForwardedRef.displayName = "Panel";
|
|
199
199
|
Panel.displayName = "forwardRef(Panel)";
|
|
200
200
|
|
|
201
|
-
const PRECISION = 10;
|
|
202
|
-
|
|
203
201
|
function convertPixelsToPercentage(pixels, groupSizePixels) {
|
|
204
202
|
return pixels / groupSizePixels * 100;
|
|
205
203
|
}
|
|
@@ -277,6 +275,8 @@ function computePercentagePanelConstraints(panelConstraintsArray, panelIndex, gr
|
|
|
277
275
|
};
|
|
278
276
|
}
|
|
279
277
|
|
|
278
|
+
const PRECISION = 10;
|
|
279
|
+
|
|
280
280
|
function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
|
|
281
281
|
actual = parseFloat(actual.toFixed(fractionDigits));
|
|
282
282
|
expected = parseFloat(expected.toFixed(fractionDigits));
|
|
@@ -750,15 +750,10 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
750
750
|
}, [groupId, layout, panelDataArray]);
|
|
751
751
|
useEffect(() => {
|
|
752
752
|
const {
|
|
753
|
-
direction,
|
|
754
753
|
panelDataArray
|
|
755
754
|
} = committedValuesRef.current;
|
|
756
755
|
const groupElement = getPanelGroupElement(groupId);
|
|
757
756
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
758
|
-
const {
|
|
759
|
-
height,
|
|
760
|
-
width
|
|
761
|
-
} = groupElement.getBoundingClientRect();
|
|
762
757
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
763
758
|
const cleanupFunctions = handles.map(handle => {
|
|
764
759
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
@@ -778,21 +773,19 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
778
773
|
if (index >= 0) {
|
|
779
774
|
const panelData = panelDataArray[index];
|
|
780
775
|
const size = layout[index];
|
|
781
|
-
if (size != null) {
|
|
782
|
-
var _getPercentageSizeFro;
|
|
776
|
+
if (size != null && panelData.constraints.collapsible) {
|
|
777
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
783
778
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
784
|
-
const
|
|
779
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
780
|
+
sizePercentage: panelData.constraints.collapsedSizePercentage,
|
|
781
|
+
sizePixels: panelData.constraints.collapsedSizePixels
|
|
782
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
783
|
+
const minSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
785
784
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
786
785
|
sizePixels: panelData.constraints.minSizePixels
|
|
787
|
-
}, groupSizePixels)) !== null &&
|
|
788
|
-
let delta = 0;
|
|
789
|
-
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
790
|
-
delta = direction === "horizontal" ? width : height;
|
|
791
|
-
} else {
|
|
792
|
-
delta = -(direction === "horizontal" ? width : height);
|
|
793
|
-
}
|
|
786
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 0;
|
|
794
787
|
const nextLayout = adjustLayoutByDelta({
|
|
795
|
-
delta,
|
|
788
|
+
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
796
789
|
groupSizePixels,
|
|
797
790
|
layout,
|
|
798
791
|
panelConstraints: panelDataArray.map(panelData => panelData.constraints),
|
|
@@ -1271,6 +1264,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1271
1264
|
const panelIdToLastNotifiedMixedSizesMapRef = useRef({});
|
|
1272
1265
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1273
1266
|
const prevDeltaRef = useRef(0);
|
|
1267
|
+
const [imperativeApiQueue, setImperativeApiQueue] = useState([]);
|
|
1274
1268
|
const committedValuesRef = useRef({
|
|
1275
1269
|
direction,
|
|
1276
1270
|
dragState,
|
|
@@ -1379,8 +1373,12 @@ function PanelGroupWithForwardedRef({
|
|
|
1379
1373
|
}
|
|
1380
1374
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1381
1375
|
if (groupSizePixels <= 0) {
|
|
1382
|
-
|
|
1383
|
-
|
|
1376
|
+
if (shouldMonitorPixelBasedConstraints(panelDataArray.map(({
|
|
1377
|
+
constraints
|
|
1378
|
+
}) => constraints))) {
|
|
1379
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1384
1382
|
}
|
|
1385
1383
|
if (unsafeLayout == null) {
|
|
1386
1384
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
@@ -1458,6 +1456,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1458
1456
|
onLayout,
|
|
1459
1457
|
panelDataArray
|
|
1460
1458
|
} = committedValuesRef.current;
|
|
1459
|
+
|
|
1460
|
+
// See issues/211
|
|
1461
|
+
if (panelDataArray.find(({
|
|
1462
|
+
id
|
|
1463
|
+
}) => id === panelData.id) == null) {
|
|
1464
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1465
|
+
panelData,
|
|
1466
|
+
type: "collapse"
|
|
1467
|
+
}]);
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1461
1470
|
if (panelData.constraints.collapsible) {
|
|
1462
1471
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1463
1472
|
const {
|
|
@@ -1501,6 +1510,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1501
1510
|
onLayout,
|
|
1502
1511
|
panelDataArray
|
|
1503
1512
|
} = committedValuesRef.current;
|
|
1513
|
+
|
|
1514
|
+
// See issues/211
|
|
1515
|
+
if (panelDataArray.find(({
|
|
1516
|
+
id
|
|
1517
|
+
}) => id === panelData.id) == null) {
|
|
1518
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1519
|
+
panelData,
|
|
1520
|
+
type: "expand"
|
|
1521
|
+
}]);
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1504
1524
|
if (panelData.constraints.collapsible) {
|
|
1505
1525
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1506
1526
|
const {
|
|
@@ -1696,6 +1716,18 @@ function PanelGroupWithForwardedRef({
|
|
|
1696
1716
|
onLayout,
|
|
1697
1717
|
panelDataArray
|
|
1698
1718
|
} = committedValuesRef.current;
|
|
1719
|
+
|
|
1720
|
+
// See issues/211
|
|
1721
|
+
if (panelDataArray.find(({
|
|
1722
|
+
id
|
|
1723
|
+
}) => id === panelData.id) == null) {
|
|
1724
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1725
|
+
panelData,
|
|
1726
|
+
mixedSizes,
|
|
1727
|
+
type: "resize"
|
|
1728
|
+
}]);
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1699
1731
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1700
1732
|
const {
|
|
1701
1733
|
groupSizePixels,
|
|
@@ -1753,6 +1785,31 @@ function PanelGroupWithForwardedRef({
|
|
|
1753
1785
|
return panelDataArray;
|
|
1754
1786
|
});
|
|
1755
1787
|
}, []);
|
|
1788
|
+
|
|
1789
|
+
// Handle imperative API calls that were made before panels were registered
|
|
1790
|
+
useIsomorphicLayoutEffect(() => {
|
|
1791
|
+
const queue = imperativeApiQueue;
|
|
1792
|
+
while (queue.length > 0) {
|
|
1793
|
+
const current = queue.shift();
|
|
1794
|
+
switch (current.type) {
|
|
1795
|
+
case "collapse":
|
|
1796
|
+
{
|
|
1797
|
+
collapsePanel(current.panelData);
|
|
1798
|
+
break;
|
|
1799
|
+
}
|
|
1800
|
+
case "expand":
|
|
1801
|
+
{
|
|
1802
|
+
expandPanel(current.panelData);
|
|
1803
|
+
break;
|
|
1804
|
+
}
|
|
1805
|
+
case "resize":
|
|
1806
|
+
{
|
|
1807
|
+
resizePanel(current.panelData, current.mixedSizes);
|
|
1808
|
+
break;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
}, [collapsePanel, expandPanel, imperativeApiQueue, layout, panelDataArray, resizePanel]);
|
|
1756
1813
|
const context = useMemo(() => ({
|
|
1757
1814
|
collapsePanel,
|
|
1758
1815
|
direction,
|
|
@@ -204,8 +204,6 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
204
204
|
PanelWithForwardedRef.displayName = "Panel";
|
|
205
205
|
Panel.displayName = "forwardRef(Panel)";
|
|
206
206
|
|
|
207
|
-
const PRECISION = 10;
|
|
208
|
-
|
|
209
207
|
function convertPixelsToPercentage(pixels, groupSizePixels) {
|
|
210
208
|
return pixels / groupSizePixels * 100;
|
|
211
209
|
}
|
|
@@ -283,6 +281,8 @@ function computePercentagePanelConstraints(panelConstraintsArray, panelIndex, gr
|
|
|
283
281
|
};
|
|
284
282
|
}
|
|
285
283
|
|
|
284
|
+
const PRECISION = 10;
|
|
285
|
+
|
|
286
286
|
function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
|
|
287
287
|
actual = parseFloat(actual.toFixed(fractionDigits));
|
|
288
288
|
expected = parseFloat(expected.toFixed(fractionDigits));
|
|
@@ -766,15 +766,10 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
766
766
|
}, [groupId, layout, panelDataArray]);
|
|
767
767
|
useEffect(() => {
|
|
768
768
|
const {
|
|
769
|
-
direction,
|
|
770
769
|
panelDataArray
|
|
771
770
|
} = committedValuesRef.current;
|
|
772
771
|
const groupElement = getPanelGroupElement(groupId);
|
|
773
772
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
774
|
-
const {
|
|
775
|
-
height,
|
|
776
|
-
width
|
|
777
|
-
} = groupElement.getBoundingClientRect();
|
|
778
773
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
779
774
|
const cleanupFunctions = handles.map(handle => {
|
|
780
775
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
@@ -794,21 +789,19 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
794
789
|
if (index >= 0) {
|
|
795
790
|
const panelData = panelDataArray[index];
|
|
796
791
|
const size = layout[index];
|
|
797
|
-
if (size != null) {
|
|
798
|
-
var _getPercentageSizeFro;
|
|
792
|
+
if (size != null && panelData.constraints.collapsible) {
|
|
793
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
799
794
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
800
|
-
const
|
|
795
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
796
|
+
sizePercentage: panelData.constraints.collapsedSizePercentage,
|
|
797
|
+
sizePixels: panelData.constraints.collapsedSizePixels
|
|
798
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
799
|
+
const minSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
801
800
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
802
801
|
sizePixels: panelData.constraints.minSizePixels
|
|
803
|
-
}, groupSizePixels)) !== null &&
|
|
804
|
-
let delta = 0;
|
|
805
|
-
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
806
|
-
delta = direction === "horizontal" ? width : height;
|
|
807
|
-
} else {
|
|
808
|
-
delta = -(direction === "horizontal" ? width : height);
|
|
809
|
-
}
|
|
802
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 0;
|
|
810
803
|
const nextLayout = adjustLayoutByDelta({
|
|
811
|
-
delta,
|
|
804
|
+
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
812
805
|
groupSizePixels,
|
|
813
806
|
layout,
|
|
814
807
|
panelConstraints: panelDataArray.map(panelData => panelData.constraints),
|
|
@@ -1364,6 +1357,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1364
1357
|
const panelIdToLastNotifiedMixedSizesMapRef = useRef({});
|
|
1365
1358
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1366
1359
|
const prevDeltaRef = useRef(0);
|
|
1360
|
+
const [imperativeApiQueue, setImperativeApiQueue] = useState([]);
|
|
1367
1361
|
const committedValuesRef = useRef({
|
|
1368
1362
|
direction,
|
|
1369
1363
|
dragState,
|
|
@@ -1472,8 +1466,12 @@ function PanelGroupWithForwardedRef({
|
|
|
1472
1466
|
}
|
|
1473
1467
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1474
1468
|
if (groupSizePixels <= 0) {
|
|
1475
|
-
|
|
1476
|
-
|
|
1469
|
+
if (shouldMonitorPixelBasedConstraints(panelDataArray.map(({
|
|
1470
|
+
constraints
|
|
1471
|
+
}) => constraints))) {
|
|
1472
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1477
1475
|
}
|
|
1478
1476
|
if (unsafeLayout == null) {
|
|
1479
1477
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
@@ -1593,6 +1591,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1593
1591
|
onLayout,
|
|
1594
1592
|
panelDataArray
|
|
1595
1593
|
} = committedValuesRef.current;
|
|
1594
|
+
|
|
1595
|
+
// See issues/211
|
|
1596
|
+
if (panelDataArray.find(({
|
|
1597
|
+
id
|
|
1598
|
+
}) => id === panelData.id) == null) {
|
|
1599
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1600
|
+
panelData,
|
|
1601
|
+
type: "collapse"
|
|
1602
|
+
}]);
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1596
1605
|
if (panelData.constraints.collapsible) {
|
|
1597
1606
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1598
1607
|
const {
|
|
@@ -1636,6 +1645,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1636
1645
|
onLayout,
|
|
1637
1646
|
panelDataArray
|
|
1638
1647
|
} = committedValuesRef.current;
|
|
1648
|
+
|
|
1649
|
+
// See issues/211
|
|
1650
|
+
if (panelDataArray.find(({
|
|
1651
|
+
id
|
|
1652
|
+
}) => id === panelData.id) == null) {
|
|
1653
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1654
|
+
panelData,
|
|
1655
|
+
type: "expand"
|
|
1656
|
+
}]);
|
|
1657
|
+
return;
|
|
1658
|
+
}
|
|
1639
1659
|
if (panelData.constraints.collapsible) {
|
|
1640
1660
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1641
1661
|
const {
|
|
@@ -1831,6 +1851,18 @@ function PanelGroupWithForwardedRef({
|
|
|
1831
1851
|
onLayout,
|
|
1832
1852
|
panelDataArray
|
|
1833
1853
|
} = committedValuesRef.current;
|
|
1854
|
+
|
|
1855
|
+
// See issues/211
|
|
1856
|
+
if (panelDataArray.find(({
|
|
1857
|
+
id
|
|
1858
|
+
}) => id === panelData.id) == null) {
|
|
1859
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1860
|
+
panelData,
|
|
1861
|
+
mixedSizes,
|
|
1862
|
+
type: "resize"
|
|
1863
|
+
}]);
|
|
1864
|
+
return;
|
|
1865
|
+
}
|
|
1834
1866
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1835
1867
|
const {
|
|
1836
1868
|
groupSizePixels,
|
|
@@ -1888,6 +1920,31 @@ function PanelGroupWithForwardedRef({
|
|
|
1888
1920
|
return panelDataArray;
|
|
1889
1921
|
});
|
|
1890
1922
|
}, []);
|
|
1923
|
+
|
|
1924
|
+
// Handle imperative API calls that were made before panels were registered
|
|
1925
|
+
useIsomorphicLayoutEffect(() => {
|
|
1926
|
+
const queue = imperativeApiQueue;
|
|
1927
|
+
while (queue.length > 0) {
|
|
1928
|
+
const current = queue.shift();
|
|
1929
|
+
switch (current.type) {
|
|
1930
|
+
case "collapse":
|
|
1931
|
+
{
|
|
1932
|
+
collapsePanel(current.panelData);
|
|
1933
|
+
break;
|
|
1934
|
+
}
|
|
1935
|
+
case "expand":
|
|
1936
|
+
{
|
|
1937
|
+
expandPanel(current.panelData);
|
|
1938
|
+
break;
|
|
1939
|
+
}
|
|
1940
|
+
case "resize":
|
|
1941
|
+
{
|
|
1942
|
+
resizePanel(current.panelData, current.mixedSizes);
|
|
1943
|
+
break;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
}, [collapsePanel, expandPanel, imperativeApiQueue, layout, panelDataArray, resizePanel]);
|
|
1891
1948
|
const context = useMemo(() => ({
|
|
1892
1949
|
collapsePanel,
|
|
1893
1950
|
direction,
|
|
@@ -180,8 +180,6 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
180
180
|
PanelWithForwardedRef.displayName = "Panel";
|
|
181
181
|
Panel.displayName = "forwardRef(Panel)";
|
|
182
182
|
|
|
183
|
-
const PRECISION = 10;
|
|
184
|
-
|
|
185
183
|
function convertPixelsToPercentage(pixels, groupSizePixels) {
|
|
186
184
|
return pixels / groupSizePixels * 100;
|
|
187
185
|
}
|
|
@@ -259,6 +257,8 @@ function computePercentagePanelConstraints(panelConstraintsArray, panelIndex, gr
|
|
|
259
257
|
};
|
|
260
258
|
}
|
|
261
259
|
|
|
260
|
+
const PRECISION = 10;
|
|
261
|
+
|
|
262
262
|
function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
|
|
263
263
|
actual = parseFloat(actual.toFixed(fractionDigits));
|
|
264
264
|
expected = parseFloat(expected.toFixed(fractionDigits));
|
|
@@ -742,15 +742,10 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
742
742
|
}, [groupId, layout, panelDataArray]);
|
|
743
743
|
useEffect(() => {
|
|
744
744
|
const {
|
|
745
|
-
direction,
|
|
746
745
|
panelDataArray
|
|
747
746
|
} = committedValuesRef.current;
|
|
748
747
|
const groupElement = getPanelGroupElement(groupId);
|
|
749
748
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
750
|
-
const {
|
|
751
|
-
height,
|
|
752
|
-
width
|
|
753
|
-
} = groupElement.getBoundingClientRect();
|
|
754
749
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
755
750
|
const cleanupFunctions = handles.map(handle => {
|
|
756
751
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
@@ -770,21 +765,19 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
770
765
|
if (index >= 0) {
|
|
771
766
|
const panelData = panelDataArray[index];
|
|
772
767
|
const size = layout[index];
|
|
773
|
-
if (size != null) {
|
|
774
|
-
var _getPercentageSizeFro;
|
|
768
|
+
if (size != null && panelData.constraints.collapsible) {
|
|
769
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
775
770
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
776
|
-
const
|
|
771
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
772
|
+
sizePercentage: panelData.constraints.collapsedSizePercentage,
|
|
773
|
+
sizePixels: panelData.constraints.collapsedSizePixels
|
|
774
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
775
|
+
const minSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
777
776
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
778
777
|
sizePixels: panelData.constraints.minSizePixels
|
|
779
|
-
}, groupSizePixels)) !== null &&
|
|
780
|
-
let delta = 0;
|
|
781
|
-
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
782
|
-
delta = direction === "horizontal" ? width : height;
|
|
783
|
-
} else {
|
|
784
|
-
delta = -(direction === "horizontal" ? width : height);
|
|
785
|
-
}
|
|
778
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 0;
|
|
786
779
|
const nextLayout = adjustLayoutByDelta({
|
|
787
|
-
delta,
|
|
780
|
+
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
788
781
|
groupSizePixels,
|
|
789
782
|
layout,
|
|
790
783
|
panelConstraints: panelDataArray.map(panelData => panelData.constraints),
|
|
@@ -1340,6 +1333,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1340
1333
|
const panelIdToLastNotifiedMixedSizesMapRef = useRef({});
|
|
1341
1334
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1342
1335
|
const prevDeltaRef = useRef(0);
|
|
1336
|
+
const [imperativeApiQueue, setImperativeApiQueue] = useState([]);
|
|
1343
1337
|
const committedValuesRef = useRef({
|
|
1344
1338
|
direction,
|
|
1345
1339
|
dragState,
|
|
@@ -1448,8 +1442,12 @@ function PanelGroupWithForwardedRef({
|
|
|
1448
1442
|
}
|
|
1449
1443
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1450
1444
|
if (groupSizePixels <= 0) {
|
|
1451
|
-
|
|
1452
|
-
|
|
1445
|
+
if (shouldMonitorPixelBasedConstraints(panelDataArray.map(({
|
|
1446
|
+
constraints
|
|
1447
|
+
}) => constraints))) {
|
|
1448
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1449
|
+
return;
|
|
1450
|
+
}
|
|
1453
1451
|
}
|
|
1454
1452
|
if (unsafeLayout == null) {
|
|
1455
1453
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
@@ -1569,6 +1567,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1569
1567
|
onLayout,
|
|
1570
1568
|
panelDataArray
|
|
1571
1569
|
} = committedValuesRef.current;
|
|
1570
|
+
|
|
1571
|
+
// See issues/211
|
|
1572
|
+
if (panelDataArray.find(({
|
|
1573
|
+
id
|
|
1574
|
+
}) => id === panelData.id) == null) {
|
|
1575
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1576
|
+
panelData,
|
|
1577
|
+
type: "collapse"
|
|
1578
|
+
}]);
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1572
1581
|
if (panelData.constraints.collapsible) {
|
|
1573
1582
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1574
1583
|
const {
|
|
@@ -1612,6 +1621,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1612
1621
|
onLayout,
|
|
1613
1622
|
panelDataArray
|
|
1614
1623
|
} = committedValuesRef.current;
|
|
1624
|
+
|
|
1625
|
+
// See issues/211
|
|
1626
|
+
if (panelDataArray.find(({
|
|
1627
|
+
id
|
|
1628
|
+
}) => id === panelData.id) == null) {
|
|
1629
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1630
|
+
panelData,
|
|
1631
|
+
type: "expand"
|
|
1632
|
+
}]);
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1615
1635
|
if (panelData.constraints.collapsible) {
|
|
1616
1636
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1617
1637
|
const {
|
|
@@ -1807,6 +1827,18 @@ function PanelGroupWithForwardedRef({
|
|
|
1807
1827
|
onLayout,
|
|
1808
1828
|
panelDataArray
|
|
1809
1829
|
} = committedValuesRef.current;
|
|
1830
|
+
|
|
1831
|
+
// See issues/211
|
|
1832
|
+
if (panelDataArray.find(({
|
|
1833
|
+
id
|
|
1834
|
+
}) => id === panelData.id) == null) {
|
|
1835
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1836
|
+
panelData,
|
|
1837
|
+
mixedSizes,
|
|
1838
|
+
type: "resize"
|
|
1839
|
+
}]);
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1810
1842
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1811
1843
|
const {
|
|
1812
1844
|
groupSizePixels,
|
|
@@ -1864,6 +1896,31 @@ function PanelGroupWithForwardedRef({
|
|
|
1864
1896
|
return panelDataArray;
|
|
1865
1897
|
});
|
|
1866
1898
|
}, []);
|
|
1899
|
+
|
|
1900
|
+
// Handle imperative API calls that were made before panels were registered
|
|
1901
|
+
useIsomorphicLayoutEffect(() => {
|
|
1902
|
+
const queue = imperativeApiQueue;
|
|
1903
|
+
while (queue.length > 0) {
|
|
1904
|
+
const current = queue.shift();
|
|
1905
|
+
switch (current.type) {
|
|
1906
|
+
case "collapse":
|
|
1907
|
+
{
|
|
1908
|
+
collapsePanel(current.panelData);
|
|
1909
|
+
break;
|
|
1910
|
+
}
|
|
1911
|
+
case "expand":
|
|
1912
|
+
{
|
|
1913
|
+
expandPanel(current.panelData);
|
|
1914
|
+
break;
|
|
1915
|
+
}
|
|
1916
|
+
case "resize":
|
|
1917
|
+
{
|
|
1918
|
+
resizePanel(current.panelData, current.mixedSizes);
|
|
1919
|
+
break;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
}, [collapsePanel, expandPanel, imperativeApiQueue, layout, panelDataArray, resizePanel]);
|
|
1867
1924
|
const context = useMemo(() => ({
|
|
1868
1925
|
collapsePanel,
|
|
1869
1926
|
direction,
|