react-resizable-panels 1.0.0-rc.2 → 1.0.0-rc.3
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/dist/react-resizable-panels.browser.cjs.js +26 -10
- package/dist/react-resizable-panels.browser.development.cjs.js +26 -10
- package/dist/react-resizable-panels.browser.development.esm.js +26 -10
- package/dist/react-resizable-panels.browser.esm.js +26 -10
- package/dist/react-resizable-panels.cjs.d.ts +1 -88
- package/dist/react-resizable-panels.cjs.d.ts.map +1 -1
- package/dist/react-resizable-panels.cjs.js +1741 -1488
- package/dist/react-resizable-panels.development.cjs.js +26 -10
- package/dist/react-resizable-panels.development.esm.js +26 -10
- package/dist/react-resizable-panels.development.node.cjs.js +26 -10
- package/dist/react-resizable-panels.development.node.esm.js +26 -10
- package/dist/react-resizable-panels.esm.js +1716 -1483
- package/dist/react-resizable-panels.node.cjs.js +26 -10
- package/dist/react-resizable-panels.node.esm.js +26 -10
- package/package.json +1 -1
- package/src/NewPanelGroup.ts +149 -0
- package/dist/react-resizable-panels.cjs.js.map +0 -1
- package/dist/react-resizable-panels.esm.js.map +0 -1
|
@@ -1332,7 +1332,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1332
1332
|
// Store size before collapse;
|
|
1333
1333
|
// This is the size that gets restored if the expand() API is used.
|
|
1334
1334
|
panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
|
|
1335
|
-
const isLastPanel = panelDataArray
|
|
1335
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1336
1336
|
const delta = isLastPanel ? panelSize - collapsedSize : collapsedSize - panelSize;
|
|
1337
1337
|
const nextLayout = adjustLayoutByDelta({
|
|
1338
1338
|
delta,
|
|
@@ -1374,7 +1374,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1374
1374
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1375
1375
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
1376
1376
|
const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
|
|
1377
|
-
const isLastPanel = panelDataArray
|
|
1377
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1378
1378
|
const delta = isLastPanel ? panelSize - baseSize : baseSize - panelSize;
|
|
1379
1379
|
const nextLayout = adjustLayoutByDelta({
|
|
1380
1380
|
delta,
|
|
@@ -1413,7 +1413,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1413
1413
|
const {
|
|
1414
1414
|
panelDataArray
|
|
1415
1415
|
} = eagerValuesRef.current;
|
|
1416
|
-
const panelIndex = panelDataArray
|
|
1416
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1417
1417
|
return computePanelFlexBoxStyle({
|
|
1418
1418
|
dragState,
|
|
1419
1419
|
layout,
|
|
@@ -1461,6 +1461,19 @@ function PanelGroupWithForwardedRef({
|
|
|
1461
1461
|
layout: prevLayout,
|
|
1462
1462
|
panelDataArray
|
|
1463
1463
|
} = eagerValuesRef.current;
|
|
1464
|
+
|
|
1465
|
+
// HACK
|
|
1466
|
+
// This appears to be triggered by some React Suspense+Offscreen+StrictMode bug;
|
|
1467
|
+
// see app.replay.io/recording/17b6e11d-4500-4173-b23d-61dfd141fed1
|
|
1468
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
1469
|
+
if (index >= 0) {
|
|
1470
|
+
if (panelData.idIsFromProps) {
|
|
1471
|
+
console.warn(`Panel with id "${panelData.id}" registered twice`);
|
|
1472
|
+
} else {
|
|
1473
|
+
console.warn(`Panel registered twice`);
|
|
1474
|
+
}
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1464
1477
|
panelDataArray.push(panelData);
|
|
1465
1478
|
panelDataArray.sort((panelA, panelB) => {
|
|
1466
1479
|
const orderA = panelA.order;
|
|
@@ -1602,7 +1615,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1602
1615
|
pivotIndices
|
|
1603
1616
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1604
1617
|
assert(panelSize != null);
|
|
1605
|
-
const isLastPanel = panelDataArray
|
|
1618
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1606
1619
|
const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
|
|
1607
1620
|
const nextLayout = adjustLayoutByDelta({
|
|
1608
1621
|
delta,
|
|
@@ -1653,7 +1666,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1653
1666
|
layout: prevLayout,
|
|
1654
1667
|
panelDataArray
|
|
1655
1668
|
} = eagerValuesRef.current;
|
|
1656
|
-
const index = panelDataArray
|
|
1669
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
1657
1670
|
if (index >= 0) {
|
|
1658
1671
|
panelDataArray.splice(index, 1);
|
|
1659
1672
|
unregisterPanelRef.current.pendingPanelIds.add(panelData.id);
|
|
@@ -1669,7 +1682,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1669
1682
|
const {
|
|
1670
1683
|
pendingPanelIds
|
|
1671
1684
|
} = unregisterPanelRef.current;
|
|
1672
|
-
const
|
|
1685
|
+
const panelIdToLastNotifiedSizeMap = panelIdToLastNotifiedSizeMapRef.current;
|
|
1673
1686
|
|
|
1674
1687
|
// TRICKY
|
|
1675
1688
|
// Strict effects mode
|
|
@@ -1680,15 +1693,15 @@ function PanelGroupWithForwardedRef({
|
|
|
1680
1693
|
id
|
|
1681
1694
|
}) => id === panelId) != null) {
|
|
1682
1695
|
unmountDueToStrictMode = true;
|
|
1683
|
-
|
|
1696
|
+
} else {
|
|
1684
1697
|
// TRICKY
|
|
1685
1698
|
// When a panel is removed from the group, we should delete the most recent prev-size entry for it.
|
|
1686
1699
|
// If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
|
|
1687
1700
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
1688
|
-
delete
|
|
1701
|
+
delete panelIdToLastNotifiedSizeMap[panelId];
|
|
1689
1702
|
}
|
|
1690
1703
|
});
|
|
1691
|
-
if (
|
|
1704
|
+
if (unmountDueToStrictMode) {
|
|
1692
1705
|
return;
|
|
1693
1706
|
}
|
|
1694
1707
|
if (panelDataArray.length === 0) {
|
|
@@ -1761,9 +1774,12 @@ const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwar
|
|
|
1761
1774
|
}));
|
|
1762
1775
|
PanelGroupWithForwardedRef.displayName = "PanelGroup";
|
|
1763
1776
|
PanelGroup.displayName = "forwardRef(PanelGroup)";
|
|
1777
|
+
function findPanelDataIndex(panelDataArray, panelData) {
|
|
1778
|
+
return panelDataArray.findIndex(prevPanelData => prevPanelData === panelData || prevPanelData.id === panelData.id);
|
|
1779
|
+
}
|
|
1764
1780
|
function panelDataHelper(panelDataArray, panelData, layout) {
|
|
1765
1781
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1766
|
-
const panelIndex = panelDataArray
|
|
1782
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1767
1783
|
const panelConstraints = panelConstraintsArray[panelIndex];
|
|
1768
1784
|
const isLastPanel = panelIndex === panelDataArray.length - 1;
|
|
1769
1785
|
const pivotIndices = isLastPanel ? [panelIndex - 1, panelIndex] : [panelIndex, panelIndex + 1];
|
|
@@ -1308,7 +1308,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1308
1308
|
// Store size before collapse;
|
|
1309
1309
|
// This is the size that gets restored if the expand() API is used.
|
|
1310
1310
|
panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
|
|
1311
|
-
const isLastPanel = panelDataArray
|
|
1311
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1312
1312
|
const delta = isLastPanel ? panelSize - collapsedSize : collapsedSize - panelSize;
|
|
1313
1313
|
const nextLayout = adjustLayoutByDelta({
|
|
1314
1314
|
delta,
|
|
@@ -1350,7 +1350,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1350
1350
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1351
1351
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
1352
1352
|
const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
|
|
1353
|
-
const isLastPanel = panelDataArray
|
|
1353
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1354
1354
|
const delta = isLastPanel ? panelSize - baseSize : baseSize - panelSize;
|
|
1355
1355
|
const nextLayout = adjustLayoutByDelta({
|
|
1356
1356
|
delta,
|
|
@@ -1389,7 +1389,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1389
1389
|
const {
|
|
1390
1390
|
panelDataArray
|
|
1391
1391
|
} = eagerValuesRef.current;
|
|
1392
|
-
const panelIndex = panelDataArray
|
|
1392
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1393
1393
|
return computePanelFlexBoxStyle({
|
|
1394
1394
|
dragState,
|
|
1395
1395
|
layout,
|
|
@@ -1437,6 +1437,19 @@ function PanelGroupWithForwardedRef({
|
|
|
1437
1437
|
layout: prevLayout,
|
|
1438
1438
|
panelDataArray
|
|
1439
1439
|
} = eagerValuesRef.current;
|
|
1440
|
+
|
|
1441
|
+
// HACK
|
|
1442
|
+
// This appears to be triggered by some React Suspense+Offscreen+StrictMode bug;
|
|
1443
|
+
// see app.replay.io/recording/17b6e11d-4500-4173-b23d-61dfd141fed1
|
|
1444
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
1445
|
+
if (index >= 0) {
|
|
1446
|
+
if (panelData.idIsFromProps) {
|
|
1447
|
+
console.warn(`Panel with id "${panelData.id}" registered twice`);
|
|
1448
|
+
} else {
|
|
1449
|
+
console.warn(`Panel registered twice`);
|
|
1450
|
+
}
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1440
1453
|
panelDataArray.push(panelData);
|
|
1441
1454
|
panelDataArray.sort((panelA, panelB) => {
|
|
1442
1455
|
const orderA = panelA.order;
|
|
@@ -1578,7 +1591,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1578
1591
|
pivotIndices
|
|
1579
1592
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1580
1593
|
assert(panelSize != null);
|
|
1581
|
-
const isLastPanel = panelDataArray
|
|
1594
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1582
1595
|
const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
|
|
1583
1596
|
const nextLayout = adjustLayoutByDelta({
|
|
1584
1597
|
delta,
|
|
@@ -1629,7 +1642,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1629
1642
|
layout: prevLayout,
|
|
1630
1643
|
panelDataArray
|
|
1631
1644
|
} = eagerValuesRef.current;
|
|
1632
|
-
const index = panelDataArray
|
|
1645
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
1633
1646
|
if (index >= 0) {
|
|
1634
1647
|
panelDataArray.splice(index, 1);
|
|
1635
1648
|
unregisterPanelRef.current.pendingPanelIds.add(panelData.id);
|
|
@@ -1645,7 +1658,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1645
1658
|
const {
|
|
1646
1659
|
pendingPanelIds
|
|
1647
1660
|
} = unregisterPanelRef.current;
|
|
1648
|
-
const
|
|
1661
|
+
const panelIdToLastNotifiedSizeMap = panelIdToLastNotifiedSizeMapRef.current;
|
|
1649
1662
|
|
|
1650
1663
|
// TRICKY
|
|
1651
1664
|
// Strict effects mode
|
|
@@ -1656,15 +1669,15 @@ function PanelGroupWithForwardedRef({
|
|
|
1656
1669
|
id
|
|
1657
1670
|
}) => id === panelId) != null) {
|
|
1658
1671
|
unmountDueToStrictMode = true;
|
|
1659
|
-
|
|
1672
|
+
} else {
|
|
1660
1673
|
// TRICKY
|
|
1661
1674
|
// When a panel is removed from the group, we should delete the most recent prev-size entry for it.
|
|
1662
1675
|
// If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
|
|
1663
1676
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
1664
|
-
delete
|
|
1677
|
+
delete panelIdToLastNotifiedSizeMap[panelId];
|
|
1665
1678
|
}
|
|
1666
1679
|
});
|
|
1667
|
-
if (
|
|
1680
|
+
if (unmountDueToStrictMode) {
|
|
1668
1681
|
return;
|
|
1669
1682
|
}
|
|
1670
1683
|
if (panelDataArray.length === 0) {
|
|
@@ -1737,9 +1750,12 @@ const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwar
|
|
|
1737
1750
|
}));
|
|
1738
1751
|
PanelGroupWithForwardedRef.displayName = "PanelGroup";
|
|
1739
1752
|
PanelGroup.displayName = "forwardRef(PanelGroup)";
|
|
1753
|
+
function findPanelDataIndex(panelDataArray, panelData) {
|
|
1754
|
+
return panelDataArray.findIndex(prevPanelData => prevPanelData === panelData || prevPanelData.id === panelData.id);
|
|
1755
|
+
}
|
|
1740
1756
|
function panelDataHelper(panelDataArray, panelData, layout) {
|
|
1741
1757
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1742
|
-
const panelIndex = panelDataArray
|
|
1758
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1743
1759
|
const panelConstraints = panelConstraintsArray[panelIndex];
|
|
1744
1760
|
const isLastPanel = panelIndex === panelDataArray.length - 1;
|
|
1745
1761
|
const pivotIndices = isLastPanel ? [panelIndex - 1, panelIndex] : [panelIndex, panelIndex + 1];
|
|
@@ -1216,7 +1216,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1216
1216
|
// Store size before collapse;
|
|
1217
1217
|
// This is the size that gets restored if the expand() API is used.
|
|
1218
1218
|
panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
|
|
1219
|
-
const isLastPanel = panelDataArray
|
|
1219
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1220
1220
|
const delta = isLastPanel ? panelSize - collapsedSize : collapsedSize - panelSize;
|
|
1221
1221
|
const nextLayout = adjustLayoutByDelta({
|
|
1222
1222
|
delta,
|
|
@@ -1258,7 +1258,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1258
1258
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1259
1259
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
1260
1260
|
const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
|
|
1261
|
-
const isLastPanel = panelDataArray
|
|
1261
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1262
1262
|
const delta = isLastPanel ? panelSize - baseSize : baseSize - panelSize;
|
|
1263
1263
|
const nextLayout = adjustLayoutByDelta({
|
|
1264
1264
|
delta,
|
|
@@ -1297,7 +1297,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1297
1297
|
const {
|
|
1298
1298
|
panelDataArray
|
|
1299
1299
|
} = eagerValuesRef.current;
|
|
1300
|
-
const panelIndex = panelDataArray
|
|
1300
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1301
1301
|
return computePanelFlexBoxStyle({
|
|
1302
1302
|
dragState,
|
|
1303
1303
|
layout,
|
|
@@ -1345,6 +1345,19 @@ function PanelGroupWithForwardedRef({
|
|
|
1345
1345
|
layout: prevLayout,
|
|
1346
1346
|
panelDataArray
|
|
1347
1347
|
} = eagerValuesRef.current;
|
|
1348
|
+
|
|
1349
|
+
// HACK
|
|
1350
|
+
// This appears to be triggered by some React Suspense+Offscreen+StrictMode bug;
|
|
1351
|
+
// see app.replay.io/recording/17b6e11d-4500-4173-b23d-61dfd141fed1
|
|
1352
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
1353
|
+
if (index >= 0) {
|
|
1354
|
+
if (panelData.idIsFromProps) {
|
|
1355
|
+
console.warn(`Panel with id "${panelData.id}" registered twice`);
|
|
1356
|
+
} else {
|
|
1357
|
+
console.warn(`Panel registered twice`);
|
|
1358
|
+
}
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1348
1361
|
panelDataArray.push(panelData);
|
|
1349
1362
|
panelDataArray.sort((panelA, panelB) => {
|
|
1350
1363
|
const orderA = panelA.order;
|
|
@@ -1486,7 +1499,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1486
1499
|
pivotIndices
|
|
1487
1500
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1488
1501
|
assert(panelSize != null);
|
|
1489
|
-
const isLastPanel = panelDataArray
|
|
1502
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1490
1503
|
const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
|
|
1491
1504
|
const nextLayout = adjustLayoutByDelta({
|
|
1492
1505
|
delta,
|
|
@@ -1537,7 +1550,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1537
1550
|
layout: prevLayout,
|
|
1538
1551
|
panelDataArray
|
|
1539
1552
|
} = eagerValuesRef.current;
|
|
1540
|
-
const index = panelDataArray
|
|
1553
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
1541
1554
|
if (index >= 0) {
|
|
1542
1555
|
panelDataArray.splice(index, 1);
|
|
1543
1556
|
unregisterPanelRef.current.pendingPanelIds.add(panelData.id);
|
|
@@ -1553,7 +1566,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1553
1566
|
const {
|
|
1554
1567
|
pendingPanelIds
|
|
1555
1568
|
} = unregisterPanelRef.current;
|
|
1556
|
-
const
|
|
1569
|
+
const panelIdToLastNotifiedSizeMap = panelIdToLastNotifiedSizeMapRef.current;
|
|
1557
1570
|
|
|
1558
1571
|
// TRICKY
|
|
1559
1572
|
// Strict effects mode
|
|
@@ -1564,15 +1577,15 @@ function PanelGroupWithForwardedRef({
|
|
|
1564
1577
|
id
|
|
1565
1578
|
}) => id === panelId) != null) {
|
|
1566
1579
|
unmountDueToStrictMode = true;
|
|
1567
|
-
|
|
1580
|
+
} else {
|
|
1568
1581
|
// TRICKY
|
|
1569
1582
|
// When a panel is removed from the group, we should delete the most recent prev-size entry for it.
|
|
1570
1583
|
// If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
|
|
1571
1584
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
1572
|
-
delete
|
|
1585
|
+
delete panelIdToLastNotifiedSizeMap[panelId];
|
|
1573
1586
|
}
|
|
1574
1587
|
});
|
|
1575
|
-
if (
|
|
1588
|
+
if (unmountDueToStrictMode) {
|
|
1576
1589
|
return;
|
|
1577
1590
|
}
|
|
1578
1591
|
if (panelDataArray.length === 0) {
|
|
@@ -1645,9 +1658,12 @@ const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwar
|
|
|
1645
1658
|
}));
|
|
1646
1659
|
PanelGroupWithForwardedRef.displayName = "PanelGroup";
|
|
1647
1660
|
PanelGroup.displayName = "forwardRef(PanelGroup)";
|
|
1661
|
+
function findPanelDataIndex(panelDataArray, panelData) {
|
|
1662
|
+
return panelDataArray.findIndex(prevPanelData => prevPanelData === panelData || prevPanelData.id === panelData.id);
|
|
1663
|
+
}
|
|
1648
1664
|
function panelDataHelper(panelDataArray, panelData, layout) {
|
|
1649
1665
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1650
|
-
const panelIndex = panelDataArray
|
|
1666
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1651
1667
|
const panelConstraints = panelConstraintsArray[panelIndex];
|
|
1652
1668
|
const isLastPanel = panelIndex === panelDataArray.length - 1;
|
|
1653
1669
|
const pivotIndices = isLastPanel ? [panelIndex - 1, panelIndex] : [panelIndex, panelIndex + 1];
|
|
@@ -1192,7 +1192,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1192
1192
|
// Store size before collapse;
|
|
1193
1193
|
// This is the size that gets restored if the expand() API is used.
|
|
1194
1194
|
panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
|
|
1195
|
-
const isLastPanel = panelDataArray
|
|
1195
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1196
1196
|
const delta = isLastPanel ? panelSize - collapsedSize : collapsedSize - panelSize;
|
|
1197
1197
|
const nextLayout = adjustLayoutByDelta({
|
|
1198
1198
|
delta,
|
|
@@ -1234,7 +1234,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1234
1234
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1235
1235
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
1236
1236
|
const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
|
|
1237
|
-
const isLastPanel = panelDataArray
|
|
1237
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1238
1238
|
const delta = isLastPanel ? panelSize - baseSize : baseSize - panelSize;
|
|
1239
1239
|
const nextLayout = adjustLayoutByDelta({
|
|
1240
1240
|
delta,
|
|
@@ -1273,7 +1273,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1273
1273
|
const {
|
|
1274
1274
|
panelDataArray
|
|
1275
1275
|
} = eagerValuesRef.current;
|
|
1276
|
-
const panelIndex = panelDataArray
|
|
1276
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1277
1277
|
return computePanelFlexBoxStyle({
|
|
1278
1278
|
dragState,
|
|
1279
1279
|
layout,
|
|
@@ -1321,6 +1321,19 @@ function PanelGroupWithForwardedRef({
|
|
|
1321
1321
|
layout: prevLayout,
|
|
1322
1322
|
panelDataArray
|
|
1323
1323
|
} = eagerValuesRef.current;
|
|
1324
|
+
|
|
1325
|
+
// HACK
|
|
1326
|
+
// This appears to be triggered by some React Suspense+Offscreen+StrictMode bug;
|
|
1327
|
+
// see app.replay.io/recording/17b6e11d-4500-4173-b23d-61dfd141fed1
|
|
1328
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
1329
|
+
if (index >= 0) {
|
|
1330
|
+
if (panelData.idIsFromProps) {
|
|
1331
|
+
console.warn(`Panel with id "${panelData.id}" registered twice`);
|
|
1332
|
+
} else {
|
|
1333
|
+
console.warn(`Panel registered twice`);
|
|
1334
|
+
}
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1324
1337
|
panelDataArray.push(panelData);
|
|
1325
1338
|
panelDataArray.sort((panelA, panelB) => {
|
|
1326
1339
|
const orderA = panelA.order;
|
|
@@ -1462,7 +1475,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1462
1475
|
pivotIndices
|
|
1463
1476
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1464
1477
|
assert(panelSize != null);
|
|
1465
|
-
const isLastPanel = panelDataArray
|
|
1478
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1466
1479
|
const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
|
|
1467
1480
|
const nextLayout = adjustLayoutByDelta({
|
|
1468
1481
|
delta,
|
|
@@ -1513,7 +1526,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1513
1526
|
layout: prevLayout,
|
|
1514
1527
|
panelDataArray
|
|
1515
1528
|
} = eagerValuesRef.current;
|
|
1516
|
-
const index = panelDataArray
|
|
1529
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
1517
1530
|
if (index >= 0) {
|
|
1518
1531
|
panelDataArray.splice(index, 1);
|
|
1519
1532
|
unregisterPanelRef.current.pendingPanelIds.add(panelData.id);
|
|
@@ -1529,7 +1542,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1529
1542
|
const {
|
|
1530
1543
|
pendingPanelIds
|
|
1531
1544
|
} = unregisterPanelRef.current;
|
|
1532
|
-
const
|
|
1545
|
+
const panelIdToLastNotifiedSizeMap = panelIdToLastNotifiedSizeMapRef.current;
|
|
1533
1546
|
|
|
1534
1547
|
// TRICKY
|
|
1535
1548
|
// Strict effects mode
|
|
@@ -1540,15 +1553,15 @@ function PanelGroupWithForwardedRef({
|
|
|
1540
1553
|
id
|
|
1541
1554
|
}) => id === panelId) != null) {
|
|
1542
1555
|
unmountDueToStrictMode = true;
|
|
1543
|
-
|
|
1556
|
+
} else {
|
|
1544
1557
|
// TRICKY
|
|
1545
1558
|
// When a panel is removed from the group, we should delete the most recent prev-size entry for it.
|
|
1546
1559
|
// If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
|
|
1547
1560
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
1548
|
-
delete
|
|
1561
|
+
delete panelIdToLastNotifiedSizeMap[panelId];
|
|
1549
1562
|
}
|
|
1550
1563
|
});
|
|
1551
|
-
if (
|
|
1564
|
+
if (unmountDueToStrictMode) {
|
|
1552
1565
|
return;
|
|
1553
1566
|
}
|
|
1554
1567
|
if (panelDataArray.length === 0) {
|
|
@@ -1621,9 +1634,12 @@ const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwar
|
|
|
1621
1634
|
}));
|
|
1622
1635
|
PanelGroupWithForwardedRef.displayName = "PanelGroup";
|
|
1623
1636
|
PanelGroup.displayName = "forwardRef(PanelGroup)";
|
|
1637
|
+
function findPanelDataIndex(panelDataArray, panelData) {
|
|
1638
|
+
return panelDataArray.findIndex(prevPanelData => prevPanelData === panelData || prevPanelData.id === panelData.id);
|
|
1639
|
+
}
|
|
1624
1640
|
function panelDataHelper(panelDataArray, panelData, layout) {
|
|
1625
1641
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1626
|
-
const panelIndex = panelDataArray
|
|
1642
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1627
1643
|
const panelConstraints = panelConstraintsArray[panelIndex];
|
|
1628
1644
|
const isLastPanel = panelIndex === panelDataArray.length - 1;
|
|
1629
1645
|
const pivotIndices = isLastPanel ? [panelIndex - 1, panelIndex] : [panelIndex, panelIndex + 1];
|