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.
@@ -1220,7 +1220,7 @@ function PanelGroupWithForwardedRef({
1220
1220
  // Store size before collapse;
1221
1221
  // This is the size that gets restored if the expand() API is used.
1222
1222
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
1223
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1223
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1224
1224
  const delta = isLastPanel ? panelSize - collapsedSize : collapsedSize - panelSize;
1225
1225
  const nextLayout = adjustLayoutByDelta({
1226
1226
  delta,
@@ -1262,7 +1262,7 @@ function PanelGroupWithForwardedRef({
1262
1262
  // Restore this panel to the size it was before it was collapsed, if possible.
1263
1263
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1264
1264
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
1265
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1265
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1266
1266
  const delta = isLastPanel ? panelSize - baseSize : baseSize - panelSize;
1267
1267
  const nextLayout = adjustLayoutByDelta({
1268
1268
  delta,
@@ -1301,7 +1301,7 @@ function PanelGroupWithForwardedRef({
1301
1301
  const {
1302
1302
  panelDataArray
1303
1303
  } = eagerValuesRef.current;
1304
- const panelIndex = panelDataArray.indexOf(panelData);
1304
+ const panelIndex = findPanelDataIndex(panelDataArray, panelData);
1305
1305
  return computePanelFlexBoxStyle({
1306
1306
  dragState,
1307
1307
  layout,
@@ -1349,6 +1349,19 @@ function PanelGroupWithForwardedRef({
1349
1349
  layout: prevLayout,
1350
1350
  panelDataArray
1351
1351
  } = eagerValuesRef.current;
1352
+
1353
+ // HACK
1354
+ // This appears to be triggered by some React Suspense+Offscreen+StrictMode bug;
1355
+ // see app.replay.io/recording/17b6e11d-4500-4173-b23d-61dfd141fed1
1356
+ const index = findPanelDataIndex(panelDataArray, panelData);
1357
+ if (index >= 0) {
1358
+ if (panelData.idIsFromProps) {
1359
+ console.warn(`Panel with id "${panelData.id}" registered twice`);
1360
+ } else {
1361
+ console.warn(`Panel registered twice`);
1362
+ }
1363
+ return;
1364
+ }
1352
1365
  panelDataArray.push(panelData);
1353
1366
  panelDataArray.sort((panelA, panelB) => {
1354
1367
  const orderA = panelA.order;
@@ -1490,7 +1503,7 @@ function PanelGroupWithForwardedRef({
1490
1503
  pivotIndices
1491
1504
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1492
1505
  assert(panelSize != null);
1493
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1506
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1494
1507
  const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
1495
1508
  const nextLayout = adjustLayoutByDelta({
1496
1509
  delta,
@@ -1541,7 +1554,7 @@ function PanelGroupWithForwardedRef({
1541
1554
  layout: prevLayout,
1542
1555
  panelDataArray
1543
1556
  } = eagerValuesRef.current;
1544
- const index = panelDataArray.indexOf(panelData);
1557
+ const index = findPanelDataIndex(panelDataArray, panelData);
1545
1558
  if (index >= 0) {
1546
1559
  panelDataArray.splice(index, 1);
1547
1560
  unregisterPanelRef.current.pendingPanelIds.add(panelData.id);
@@ -1557,7 +1570,7 @@ function PanelGroupWithForwardedRef({
1557
1570
  const {
1558
1571
  pendingPanelIds
1559
1572
  } = unregisterPanelRef.current;
1560
- const map = panelIdToLastNotifiedSizeMapRef.current;
1573
+ const panelIdToLastNotifiedSizeMap = panelIdToLastNotifiedSizeMapRef.current;
1561
1574
 
1562
1575
  // TRICKY
1563
1576
  // Strict effects mode
@@ -1568,15 +1581,15 @@ function PanelGroupWithForwardedRef({
1568
1581
  id
1569
1582
  }) => id === panelId) != null) {
1570
1583
  unmountDueToStrictMode = true;
1571
-
1584
+ } else {
1572
1585
  // TRICKY
1573
1586
  // When a panel is removed from the group, we should delete the most recent prev-size entry for it.
1574
1587
  // If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
1575
1588
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1576
- delete map[panelData.id];
1589
+ delete panelIdToLastNotifiedSizeMap[panelId];
1577
1590
  }
1578
1591
  });
1579
- if (!unmountDueToStrictMode) {
1592
+ if (unmountDueToStrictMode) {
1580
1593
  return;
1581
1594
  }
1582
1595
  if (panelDataArray.length === 0) {
@@ -1649,9 +1662,12 @@ const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwar
1649
1662
  }));
1650
1663
  PanelGroupWithForwardedRef.displayName = "PanelGroup";
1651
1664
  PanelGroup.displayName = "forwardRef(PanelGroup)";
1665
+ function findPanelDataIndex(panelDataArray, panelData) {
1666
+ return panelDataArray.findIndex(prevPanelData => prevPanelData === panelData || prevPanelData.id === panelData.id);
1667
+ }
1652
1668
  function panelDataHelper(panelDataArray, panelData, layout) {
1653
1669
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1654
- const panelIndex = panelDataArray.indexOf(panelData);
1670
+ const panelIndex = findPanelDataIndex(panelDataArray, panelData);
1655
1671
  const panelConstraints = panelConstraintsArray[panelIndex];
1656
1672
  const isLastPanel = panelIndex === panelDataArray.length - 1;
1657
1673
  const pivotIndices = isLastPanel ? [panelIndex - 1, panelIndex] : [panelIndex, panelIndex + 1];
@@ -1325,7 +1325,7 @@ function PanelGroupWithForwardedRef({
1325
1325
  // Store size before collapse;
1326
1326
  // This is the size that gets restored if the expand() API is used.
1327
1327
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
1328
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1328
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1329
1329
  const delta = isLastPanel ? panelSize - collapsedSize : collapsedSize - panelSize;
1330
1330
  const nextLayout = adjustLayoutByDelta({
1331
1331
  delta,
@@ -1367,7 +1367,7 @@ function PanelGroupWithForwardedRef({
1367
1367
  // Restore this panel to the size it was before it was collapsed, if possible.
1368
1368
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1369
1369
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
1370
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1370
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1371
1371
  const delta = isLastPanel ? panelSize - baseSize : baseSize - panelSize;
1372
1372
  const nextLayout = adjustLayoutByDelta({
1373
1373
  delta,
@@ -1406,7 +1406,7 @@ function PanelGroupWithForwardedRef({
1406
1406
  const {
1407
1407
  panelDataArray
1408
1408
  } = eagerValuesRef.current;
1409
- const panelIndex = panelDataArray.indexOf(panelData);
1409
+ const panelIndex = findPanelDataIndex(panelDataArray, panelData);
1410
1410
  return computePanelFlexBoxStyle({
1411
1411
  dragState,
1412
1412
  layout,
@@ -1454,6 +1454,19 @@ function PanelGroupWithForwardedRef({
1454
1454
  layout: prevLayout,
1455
1455
  panelDataArray
1456
1456
  } = eagerValuesRef.current;
1457
+
1458
+ // HACK
1459
+ // This appears to be triggered by some React Suspense+Offscreen+StrictMode bug;
1460
+ // see app.replay.io/recording/17b6e11d-4500-4173-b23d-61dfd141fed1
1461
+ const index = findPanelDataIndex(panelDataArray, panelData);
1462
+ if (index >= 0) {
1463
+ if (panelData.idIsFromProps) {
1464
+ console.warn(`Panel with id "${panelData.id}" registered twice`);
1465
+ } else {
1466
+ console.warn(`Panel registered twice`);
1467
+ }
1468
+ return;
1469
+ }
1457
1470
  panelDataArray.push(panelData);
1458
1471
  panelDataArray.sort((panelA, panelB) => {
1459
1472
  const orderA = panelA.order;
@@ -1595,7 +1608,7 @@ function PanelGroupWithForwardedRef({
1595
1608
  pivotIndices
1596
1609
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1597
1610
  assert(panelSize != null);
1598
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1611
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1599
1612
  const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
1600
1613
  const nextLayout = adjustLayoutByDelta({
1601
1614
  delta,
@@ -1646,7 +1659,7 @@ function PanelGroupWithForwardedRef({
1646
1659
  layout: prevLayout,
1647
1660
  panelDataArray
1648
1661
  } = eagerValuesRef.current;
1649
- const index = panelDataArray.indexOf(panelData);
1662
+ const index = findPanelDataIndex(panelDataArray, panelData);
1650
1663
  if (index >= 0) {
1651
1664
  panelDataArray.splice(index, 1);
1652
1665
  unregisterPanelRef.current.pendingPanelIds.add(panelData.id);
@@ -1662,7 +1675,7 @@ function PanelGroupWithForwardedRef({
1662
1675
  const {
1663
1676
  pendingPanelIds
1664
1677
  } = unregisterPanelRef.current;
1665
- const map = panelIdToLastNotifiedSizeMapRef.current;
1678
+ const panelIdToLastNotifiedSizeMap = panelIdToLastNotifiedSizeMapRef.current;
1666
1679
 
1667
1680
  // TRICKY
1668
1681
  // Strict effects mode
@@ -1673,15 +1686,15 @@ function PanelGroupWithForwardedRef({
1673
1686
  id
1674
1687
  }) => id === panelId) != null) {
1675
1688
  unmountDueToStrictMode = true;
1676
-
1689
+ } else {
1677
1690
  // TRICKY
1678
1691
  // When a panel is removed from the group, we should delete the most recent prev-size entry for it.
1679
1692
  // If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
1680
1693
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1681
- delete map[panelData.id];
1694
+ delete panelIdToLastNotifiedSizeMap[panelId];
1682
1695
  }
1683
1696
  });
1684
- if (!unmountDueToStrictMode) {
1697
+ if (unmountDueToStrictMode) {
1685
1698
  return;
1686
1699
  }
1687
1700
  if (panelDataArray.length === 0) {
@@ -1754,9 +1767,12 @@ const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwar
1754
1767
  }));
1755
1768
  PanelGroupWithForwardedRef.displayName = "PanelGroup";
1756
1769
  PanelGroup.displayName = "forwardRef(PanelGroup)";
1770
+ function findPanelDataIndex(panelDataArray, panelData) {
1771
+ return panelDataArray.findIndex(prevPanelData => prevPanelData === panelData || prevPanelData.id === panelData.id);
1772
+ }
1757
1773
  function panelDataHelper(panelDataArray, panelData, layout) {
1758
1774
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1759
- const panelIndex = panelDataArray.indexOf(panelData);
1775
+ const panelIndex = findPanelDataIndex(panelDataArray, panelData);
1760
1776
  const panelConstraints = panelConstraintsArray[panelIndex];
1761
1777
  const isLastPanel = panelIndex === panelDataArray.length - 1;
1762
1778
  const pivotIndices = isLastPanel ? [panelIndex - 1, panelIndex] : [panelIndex, panelIndex + 1];
@@ -1301,7 +1301,7 @@ function PanelGroupWithForwardedRef({
1301
1301
  // Store size before collapse;
1302
1302
  // This is the size that gets restored if the expand() API is used.
1303
1303
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
1304
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1304
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1305
1305
  const delta = isLastPanel ? panelSize - collapsedSize : collapsedSize - panelSize;
1306
1306
  const nextLayout = adjustLayoutByDelta({
1307
1307
  delta,
@@ -1343,7 +1343,7 @@ function PanelGroupWithForwardedRef({
1343
1343
  // Restore this panel to the size it was before it was collapsed, if possible.
1344
1344
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1345
1345
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
1346
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1346
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1347
1347
  const delta = isLastPanel ? panelSize - baseSize : baseSize - panelSize;
1348
1348
  const nextLayout = adjustLayoutByDelta({
1349
1349
  delta,
@@ -1382,7 +1382,7 @@ function PanelGroupWithForwardedRef({
1382
1382
  const {
1383
1383
  panelDataArray
1384
1384
  } = eagerValuesRef.current;
1385
- const panelIndex = panelDataArray.indexOf(panelData);
1385
+ const panelIndex = findPanelDataIndex(panelDataArray, panelData);
1386
1386
  return computePanelFlexBoxStyle({
1387
1387
  dragState,
1388
1388
  layout,
@@ -1430,6 +1430,19 @@ function PanelGroupWithForwardedRef({
1430
1430
  layout: prevLayout,
1431
1431
  panelDataArray
1432
1432
  } = eagerValuesRef.current;
1433
+
1434
+ // HACK
1435
+ // This appears to be triggered by some React Suspense+Offscreen+StrictMode bug;
1436
+ // see app.replay.io/recording/17b6e11d-4500-4173-b23d-61dfd141fed1
1437
+ const index = findPanelDataIndex(panelDataArray, panelData);
1438
+ if (index >= 0) {
1439
+ if (panelData.idIsFromProps) {
1440
+ console.warn(`Panel with id "${panelData.id}" registered twice`);
1441
+ } else {
1442
+ console.warn(`Panel registered twice`);
1443
+ }
1444
+ return;
1445
+ }
1433
1446
  panelDataArray.push(panelData);
1434
1447
  panelDataArray.sort((panelA, panelB) => {
1435
1448
  const orderA = panelA.order;
@@ -1571,7 +1584,7 @@ function PanelGroupWithForwardedRef({
1571
1584
  pivotIndices
1572
1585
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1573
1586
  assert(panelSize != null);
1574
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1587
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1575
1588
  const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
1576
1589
  const nextLayout = adjustLayoutByDelta({
1577
1590
  delta,
@@ -1622,7 +1635,7 @@ function PanelGroupWithForwardedRef({
1622
1635
  layout: prevLayout,
1623
1636
  panelDataArray
1624
1637
  } = eagerValuesRef.current;
1625
- const index = panelDataArray.indexOf(panelData);
1638
+ const index = findPanelDataIndex(panelDataArray, panelData);
1626
1639
  if (index >= 0) {
1627
1640
  panelDataArray.splice(index, 1);
1628
1641
  unregisterPanelRef.current.pendingPanelIds.add(panelData.id);
@@ -1638,7 +1651,7 @@ function PanelGroupWithForwardedRef({
1638
1651
  const {
1639
1652
  pendingPanelIds
1640
1653
  } = unregisterPanelRef.current;
1641
- const map = panelIdToLastNotifiedSizeMapRef.current;
1654
+ const panelIdToLastNotifiedSizeMap = panelIdToLastNotifiedSizeMapRef.current;
1642
1655
 
1643
1656
  // TRICKY
1644
1657
  // Strict effects mode
@@ -1649,15 +1662,15 @@ function PanelGroupWithForwardedRef({
1649
1662
  id
1650
1663
  }) => id === panelId) != null) {
1651
1664
  unmountDueToStrictMode = true;
1652
-
1665
+ } else {
1653
1666
  // TRICKY
1654
1667
  // When a panel is removed from the group, we should delete the most recent prev-size entry for it.
1655
1668
  // If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
1656
1669
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1657
- delete map[panelData.id];
1670
+ delete panelIdToLastNotifiedSizeMap[panelId];
1658
1671
  }
1659
1672
  });
1660
- if (!unmountDueToStrictMode) {
1673
+ if (unmountDueToStrictMode) {
1661
1674
  return;
1662
1675
  }
1663
1676
  if (panelDataArray.length === 0) {
@@ -1730,9 +1743,12 @@ const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwar
1730
1743
  }));
1731
1744
  PanelGroupWithForwardedRef.displayName = "PanelGroup";
1732
1745
  PanelGroup.displayName = "forwardRef(PanelGroup)";
1746
+ function findPanelDataIndex(panelDataArray, panelData) {
1747
+ return panelDataArray.findIndex(prevPanelData => prevPanelData === panelData || prevPanelData.id === panelData.id);
1748
+ }
1733
1749
  function panelDataHelper(panelDataArray, panelData, layout) {
1734
1750
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1735
- const panelIndex = panelDataArray.indexOf(panelData);
1751
+ const panelIndex = findPanelDataIndex(panelDataArray, panelData);
1736
1752
  const panelConstraints = panelConstraintsArray[panelIndex];
1737
1753
  const isLastPanel = panelIndex === panelDataArray.length - 1;
1738
1754
  const pivotIndices = isLastPanel ? [panelIndex - 1, panelIndex] : [panelIndex, panelIndex + 1];
@@ -1196,7 +1196,7 @@ function PanelGroupWithForwardedRef({
1196
1196
  // Store size before collapse;
1197
1197
  // This is the size that gets restored if the expand() API is used.
1198
1198
  panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
1199
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1199
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1200
1200
  const delta = isLastPanel ? panelSize - collapsedSize : collapsedSize - panelSize;
1201
1201
  const nextLayout = adjustLayoutByDelta({
1202
1202
  delta,
@@ -1238,7 +1238,7 @@ function PanelGroupWithForwardedRef({
1238
1238
  // Restore this panel to the size it was before it was collapsed, if possible.
1239
1239
  const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1240
1240
  const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
1241
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1241
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1242
1242
  const delta = isLastPanel ? panelSize - baseSize : baseSize - panelSize;
1243
1243
  const nextLayout = adjustLayoutByDelta({
1244
1244
  delta,
@@ -1277,7 +1277,7 @@ function PanelGroupWithForwardedRef({
1277
1277
  const {
1278
1278
  panelDataArray
1279
1279
  } = eagerValuesRef.current;
1280
- const panelIndex = panelDataArray.indexOf(panelData);
1280
+ const panelIndex = findPanelDataIndex(panelDataArray, panelData);
1281
1281
  return computePanelFlexBoxStyle({
1282
1282
  dragState,
1283
1283
  layout,
@@ -1325,6 +1325,19 @@ function PanelGroupWithForwardedRef({
1325
1325
  layout: prevLayout,
1326
1326
  panelDataArray
1327
1327
  } = eagerValuesRef.current;
1328
+
1329
+ // HACK
1330
+ // This appears to be triggered by some React Suspense+Offscreen+StrictMode bug;
1331
+ // see app.replay.io/recording/17b6e11d-4500-4173-b23d-61dfd141fed1
1332
+ const index = findPanelDataIndex(panelDataArray, panelData);
1333
+ if (index >= 0) {
1334
+ if (panelData.idIsFromProps) {
1335
+ console.warn(`Panel with id "${panelData.id}" registered twice`);
1336
+ } else {
1337
+ console.warn(`Panel registered twice`);
1338
+ }
1339
+ return;
1340
+ }
1328
1341
  panelDataArray.push(panelData);
1329
1342
  panelDataArray.sort((panelA, panelB) => {
1330
1343
  const orderA = panelA.order;
@@ -1466,7 +1479,7 @@ function PanelGroupWithForwardedRef({
1466
1479
  pivotIndices
1467
1480
  } = panelDataHelper(panelDataArray, panelData, prevLayout);
1468
1481
  assert(panelSize != null);
1469
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1482
+ const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1470
1483
  const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
1471
1484
  const nextLayout = adjustLayoutByDelta({
1472
1485
  delta,
@@ -1517,7 +1530,7 @@ function PanelGroupWithForwardedRef({
1517
1530
  layout: prevLayout,
1518
1531
  panelDataArray
1519
1532
  } = eagerValuesRef.current;
1520
- const index = panelDataArray.indexOf(panelData);
1533
+ const index = findPanelDataIndex(panelDataArray, panelData);
1521
1534
  if (index >= 0) {
1522
1535
  panelDataArray.splice(index, 1);
1523
1536
  unregisterPanelRef.current.pendingPanelIds.add(panelData.id);
@@ -1533,7 +1546,7 @@ function PanelGroupWithForwardedRef({
1533
1546
  const {
1534
1547
  pendingPanelIds
1535
1548
  } = unregisterPanelRef.current;
1536
- const map = panelIdToLastNotifiedSizeMapRef.current;
1549
+ const panelIdToLastNotifiedSizeMap = panelIdToLastNotifiedSizeMapRef.current;
1537
1550
 
1538
1551
  // TRICKY
1539
1552
  // Strict effects mode
@@ -1544,15 +1557,15 @@ function PanelGroupWithForwardedRef({
1544
1557
  id
1545
1558
  }) => id === panelId) != null) {
1546
1559
  unmountDueToStrictMode = true;
1547
-
1560
+ } else {
1548
1561
  // TRICKY
1549
1562
  // When a panel is removed from the group, we should delete the most recent prev-size entry for it.
1550
1563
  // If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
1551
1564
  // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1552
- delete map[panelData.id];
1565
+ delete panelIdToLastNotifiedSizeMap[panelId];
1553
1566
  }
1554
1567
  });
1555
- if (!unmountDueToStrictMode) {
1568
+ if (unmountDueToStrictMode) {
1556
1569
  return;
1557
1570
  }
1558
1571
  if (panelDataArray.length === 0) {
@@ -1625,9 +1638,12 @@ const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwar
1625
1638
  }));
1626
1639
  PanelGroupWithForwardedRef.displayName = "PanelGroup";
1627
1640
  PanelGroup.displayName = "forwardRef(PanelGroup)";
1641
+ function findPanelDataIndex(panelDataArray, panelData) {
1642
+ return panelDataArray.findIndex(prevPanelData => prevPanelData === panelData || prevPanelData.id === panelData.id);
1643
+ }
1628
1644
  function panelDataHelper(panelDataArray, panelData, layout) {
1629
1645
  const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1630
- const panelIndex = panelDataArray.indexOf(panelData);
1646
+ const panelIndex = findPanelDataIndex(panelDataArray, panelData);
1631
1647
  const panelConstraints = panelConstraintsArray[panelIndex];
1632
1648
  const isLastPanel = panelIndex === panelDataArray.length - 1;
1633
1649
  const pivotIndices = isLastPanel ? [panelIndex - 1, panelIndex] : [panelIndex, panelIndex + 1];
@@ -1,89 +1,2 @@
1
- import { CSSProperties, ElementType, HTMLAttributes, PropsWithChildren } from "react";
2
- export type PanelOnCollapse = () => void;
3
- export type PanelOnExpand = () => void;
4
- export type PanelOnResize = (size: number, prevSize: number | undefined) => void;
5
- export type ImperativePanelHandle = {
6
- collapse: () => void;
7
- expand: () => void;
8
- getId(): string;
9
- getSize(): number;
10
- isCollapsed: () => boolean;
11
- isExpanded: () => boolean;
12
- resize: (size: number) => void;
13
- };
14
- export type PanelProps = Omit<HTMLAttributes<ElementType>, "id" | "onResize"> & PropsWithChildren<{
15
- className?: string;
16
- collapsedSize?: number | undefined;
17
- collapsible?: boolean | undefined;
18
- defaultSize?: number | undefined;
19
- id?: string;
20
- maxSize?: number | undefined;
21
- minSize?: number | undefined;
22
- onCollapse?: PanelOnCollapse;
23
- onExpand?: PanelOnExpand;
24
- onResize?: PanelOnResize;
25
- order?: number;
26
- style?: object;
27
- tagName?: ElementType;
28
- }>;
29
- export declare namespace PanelWithForwardedRef {
30
- var displayName: string;
31
- }
32
- export const Panel: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<ElementType>, "id" | "onResize"> & {
33
- className?: string | undefined;
34
- collapsedSize?: number | undefined;
35
- collapsible?: boolean | undefined;
36
- defaultSize?: number | undefined;
37
- id?: string | undefined;
38
- maxSize?: number | undefined;
39
- minSize?: number | undefined;
40
- onCollapse?: PanelOnCollapse | undefined;
41
- onExpand?: PanelOnExpand | undefined;
42
- onResize?: PanelOnResize | undefined;
43
- order?: number | undefined;
44
- style?: object | undefined;
45
- tagName?: ElementType | undefined;
46
- } & {
47
- children?: import("react").ReactNode;
48
- } & import("react").RefAttributes<ImperativePanelHandle>>;
49
- type Direction = "horizontal" | "vertical";
50
- export function assert(expectedCondition: any, message?: string): asserts expectedCondition;
51
- export type ImperativePanelGroupHandle = {
52
- getId: () => string;
53
- getLayout: () => number[];
54
- setLayout: (layout: number[]) => void;
55
- };
56
- export type PanelGroupStorage = {
57
- getItem(name: string): string | null;
58
- setItem(name: string, value: string): void;
59
- };
60
- export type PanelGroupOnLayout = (layout: number[]) => void;
61
- export type PanelGroupProps = Omit<HTMLAttributes<ElementType>, "id"> & PropsWithChildren<{
62
- autoSaveId?: string | null;
63
- className?: string;
64
- direction: Direction;
65
- id?: string | null;
66
- keyboardResizeBy?: number | null;
67
- onLayout?: PanelGroupOnLayout | null;
68
- storage?: PanelGroupStorage;
69
- style?: CSSProperties;
70
- tagName?: ElementType;
71
- }>;
72
- export const PanelGroup: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<ElementType>, "id"> & {
73
- autoSaveId?: string | null | undefined;
74
- className?: string | undefined;
75
- direction: Direction;
76
- id?: string | null | undefined;
77
- keyboardResizeBy?: number | null | undefined;
78
- onLayout?: PanelGroupOnLayout | null | undefined;
79
- storage?: PanelGroupStorage | undefined;
80
- style?: CSSProperties | undefined;
81
- tagName?: ElementType | undefined;
82
- } & {
83
- children?: import("react").ReactNode;
84
- } & import("react").RefAttributes<ImperativePanelGroupHandle>>;
85
- export declare namespace PanelResizeHandle {
86
- var displayName: string;
87
- }
88
-
1
+ export * from "./declarations/src/index";
89
2
  //# sourceMappingURL=react-resizable-panels.cjs.d.ts.map
@@ -1 +1 @@
1
- {"mappings":"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","sources":["packages/react-resizable-panels/src/src/vendor/react.ts","packages/react-resizable-panels/src/src/PanelGroupContext.ts","packages/react-resizable-panels/src/src/hooks/useIsomorphicEffect.ts","packages/react-resizable-panels/src/src/hooks/useUniqueId.ts","packages/react-resizable-panels/src/src/Panel.ts","packages/react-resizable-panels/src/src/types.ts","packages/react-resizable-panels/src/src/utils/assert.ts","packages/react-resizable-panels/src/src/constants.ts","packages/react-resizable-panels/src/src/utils/numbers/fuzzyCompareNumbers.ts","packages/react-resizable-panels/src/src/utils/numbers/fuzzyNumbersEqual.ts","packages/react-resizable-panels/src/src/utils/resizePanel.ts","packages/react-resizable-panels/src/src/utils/adjustLayoutByDelta.ts","packages/react-resizable-panels/src/src/utils/calculateAriaValues.ts","packages/react-resizable-panels/src/src/utils/dom/getResizeHandleElementsForGroup.ts","packages/react-resizable-panels/src/src/utils/dom/getResizeHandleElementIndex.ts","packages/react-resizable-panels/src/src/utils/determinePivotIndices.ts","packages/react-resizable-panels/src/src/utils/dom/getPanelGroupElement.ts","packages/react-resizable-panels/src/src/utils/dom/getResizeHandleElement.ts","packages/react-resizable-panels/src/src/utils/dom/getResizeHandlePanelIds.ts","packages/react-resizable-panels/src/src/hooks/useWindowSplitterPanelGroupBehavior.ts","packages/react-resizable-panels/src/src/utils/arrays.ts","packages/react-resizable-panels/src/src/utils/events.ts","packages/react-resizable-panels/src/src/utils/getResizeEventCursorPosition.ts","packages/react-resizable-panels/src/src/utils/calculateDragOffsetPercentage.ts","packages/react-resizable-panels/src/src/utils/calculateDeltaPercentage.ts","packages/react-resizable-panels/src/src/utils/calculateUnsafeDefaultLayout.ts","packages/react-resizable-panels/src/src/utils/callPanelCallbacks.ts","packages/react-resizable-panels/src/src/utils/compareLayouts.ts","packages/react-resizable-panels/src/src/utils/computePanelFlexBoxStyle.ts","packages/react-resizable-panels/src/src/utils/cursor.ts","packages/react-resizable-panels/src/src/utils/debounce.ts","packages/react-resizable-panels/src/src/utils/dom/getPanelElementsForGroup.ts","packages/react-resizable-panels/src/src/utils/initializeDefaultStorage.ts","packages/react-resizable-panels/src/src/utils/serialization.ts","packages/react-resizable-panels/src/src/utils/validatePanelConstraints.ts","packages/react-resizable-panels/src/src/utils/validatePanelGroupLayout.ts","packages/react-resizable-panels/src/src/PanelGroup.ts","packages/react-resizable-panels/src/src/hooks/useWindowSplitterBehavior.ts","packages/react-resizable-panels/src/src/PanelResizeHandle.ts","packages/react-resizable-panels/src/src/index.ts","packages/react-resizable-panels/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"import { Panel } from \"./Panel\";\nimport { PanelGroup } from \"./PanelGroup\";\nimport { PanelResizeHandle } from \"./PanelResizeHandle\";\nimport { assert } from \"./utils/assert\";\n\nimport type {\n ImperativePanelHandle,\n PanelOnCollapse,\n PanelOnExpand,\n PanelOnResize,\n PanelProps,\n} from \"./Panel\";\nimport type {\n ImperativePanelGroupHandle,\n PanelGroupOnLayout,\n PanelGroupProps,\n PanelGroupStorage,\n} from \"./PanelGroup\";\nimport type {\n PanelResizeHandleOnDragging,\n PanelResizeHandleProps,\n} from \"./PanelResizeHandle\";\n\nexport {\n // TypeScript types\n ImperativePanelGroupHandle,\n ImperativePanelHandle,\n PanelGroupOnLayout,\n PanelGroupProps,\n PanelGroupStorage,\n PanelOnCollapse,\n PanelOnExpand,\n PanelOnResize,\n PanelProps,\n PanelResizeHandleOnDragging,\n PanelResizeHandleProps,\n\n // Utiltiy methods\n assert,\n\n // React components\n Panel,\n PanelGroup,\n PanelResizeHandle,\n};\n"],"names":[],"version":3,"file":"react-resizable-panels.cjs.d.ts.map","sourceRoot":"../../../"}
1
+ {"version":3,"file":"react-resizable-panels.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}