react-resizable-panels 1.0.0-rc.1 → 1.0.0-rc.2
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 +1 -1
- package/dist/react-resizable-panels.browser.development.cjs.js +1 -1
- package/dist/react-resizable-panels.browser.development.esm.js +1 -1
- package/dist/react-resizable-panels.browser.esm.js +1 -1
- package/dist/react-resizable-panels.cjs.d.ts +88 -1
- package/dist/react-resizable-panels.cjs.d.ts.map +1 -1
- package/dist/react-resizable-panels.cjs.js +1489 -1726
- package/dist/react-resizable-panels.cjs.js.map +1 -1
- package/dist/react-resizable-panels.development.cjs.js +1 -1
- package/dist/react-resizable-panels.development.esm.js +1 -1
- package/dist/react-resizable-panels.development.node.cjs.js +1 -1
- package/dist/react-resizable-panels.development.node.esm.js +1 -1
- package/dist/react-resizable-panels.esm.js +1484 -1701
- package/dist/react-resizable-panels.esm.js.map +1 -1
- package/dist/react-resizable-panels.node.cjs.js +1 -1
- package/dist/react-resizable-panels.node.esm.js +1 -1
- package/package.json +1 -1
- package/src/PanelGroup.ts +35 -11
|
@@ -1462,7 +1462,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1462
1462
|
pendingPanelIds.delete(panelId);
|
|
1463
1463
|
if (panelDataArray.find(({
|
|
1464
1464
|
id
|
|
1465
|
-
}) => id === panelId)
|
|
1465
|
+
}) => id === panelId) != null) {
|
|
1466
1466
|
unmountDueToStrictMode = true;
|
|
1467
1467
|
|
|
1468
1468
|
// TRICKY
|
|
@@ -1438,7 +1438,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1438
1438
|
pendingPanelIds.delete(panelId);
|
|
1439
1439
|
if (panelDataArray.find(({
|
|
1440
1440
|
id
|
|
1441
|
-
}) => id === panelId)
|
|
1441
|
+
}) => id === panelId) != null) {
|
|
1442
1442
|
unmountDueToStrictMode = true;
|
|
1443
1443
|
|
|
1444
1444
|
// TRICKY
|
package/package.json
CHANGED
package/src/PanelGroup.ts
CHANGED
|
@@ -313,7 +313,8 @@ function PanelGroupWithForwardedRef({
|
|
|
313
313
|
panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
|
|
314
314
|
|
|
315
315
|
const isLastPanel =
|
|
316
|
-
panelDataArray
|
|
316
|
+
findPanelDataIndex(panelDataArray, panelData) ===
|
|
317
|
+
panelDataArray.length - 1;
|
|
317
318
|
const delta = isLastPanel
|
|
318
319
|
? panelSize - collapsedSize
|
|
319
320
|
: collapsedSize - panelSize;
|
|
@@ -374,7 +375,8 @@ function PanelGroupWithForwardedRef({
|
|
|
374
375
|
: minSize;
|
|
375
376
|
|
|
376
377
|
const isLastPanel =
|
|
377
|
-
panelDataArray
|
|
378
|
+
findPanelDataIndex(panelDataArray, panelData) ===
|
|
379
|
+
panelDataArray.length - 1;
|
|
378
380
|
const delta = isLastPanel ? panelSize - baseSize : baseSize - panelSize;
|
|
379
381
|
|
|
380
382
|
const nextLayout = adjustLayoutByDelta({
|
|
@@ -420,7 +422,7 @@ function PanelGroupWithForwardedRef({
|
|
|
420
422
|
(panelData: PanelData) => {
|
|
421
423
|
const { panelDataArray } = eagerValuesRef.current;
|
|
422
424
|
|
|
423
|
-
const panelIndex = panelDataArray
|
|
425
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
424
426
|
|
|
425
427
|
return computePanelFlexBoxStyle({
|
|
426
428
|
dragState,
|
|
@@ -469,6 +471,19 @@ function PanelGroupWithForwardedRef({
|
|
|
469
471
|
} = committedValuesRef.current;
|
|
470
472
|
const { layout: prevLayout, panelDataArray } = eagerValuesRef.current;
|
|
471
473
|
|
|
474
|
+
// HACK
|
|
475
|
+
// This appears to be triggered by some React Suspense+Offscreen+StrictMode bug;
|
|
476
|
+
// see app.replay.io/recording/17b6e11d-4500-4173-b23d-61dfd141fed1
|
|
477
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
478
|
+
if (index >= 0) {
|
|
479
|
+
if (panelData.idIsFromProps) {
|
|
480
|
+
console.warn(`Panel with id "${panelData.id}" registered twice`);
|
|
481
|
+
} else {
|
|
482
|
+
console.warn(`Panel registered twice`);
|
|
483
|
+
}
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
|
|
472
487
|
panelDataArray.push(panelData);
|
|
473
488
|
panelDataArray.sort((panelA, panelB) => {
|
|
474
489
|
const orderA = panelA.order;
|
|
@@ -647,7 +662,8 @@ function PanelGroupWithForwardedRef({
|
|
|
647
662
|
assert(panelSize != null);
|
|
648
663
|
|
|
649
664
|
const isLastPanel =
|
|
650
|
-
panelDataArray
|
|
665
|
+
findPanelDataIndex(panelDataArray, panelData) ===
|
|
666
|
+
panelDataArray.length - 1;
|
|
651
667
|
const delta = isLastPanel
|
|
652
668
|
? panelSize - unsafePanelSize
|
|
653
669
|
: unsafePanelSize - panelSize;
|
|
@@ -718,7 +734,7 @@ function PanelGroupWithForwardedRef({
|
|
|
718
734
|
const { onLayout } = committedValuesRef.current;
|
|
719
735
|
const { layout: prevLayout, panelDataArray } = eagerValuesRef.current;
|
|
720
736
|
|
|
721
|
-
const index = panelDataArray
|
|
737
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
722
738
|
if (index >= 0) {
|
|
723
739
|
panelDataArray.splice(index, 1);
|
|
724
740
|
unregisterPanelRef.current.pendingPanelIds.add(panelData.id);
|
|
@@ -733,7 +749,8 @@ function PanelGroupWithForwardedRef({
|
|
|
733
749
|
// We can't check the DOM to detect this because Panel elements have not yet been removed.
|
|
734
750
|
unregisterPanelRef.current.timeout = setTimeout(() => {
|
|
735
751
|
const { pendingPanelIds } = unregisterPanelRef.current;
|
|
736
|
-
const
|
|
752
|
+
const panelIdToLastNotifiedSizeMap =
|
|
753
|
+
panelIdToLastNotifiedSizeMapRef.current;
|
|
737
754
|
|
|
738
755
|
// TRICKY
|
|
739
756
|
// Strict effects mode
|
|
@@ -741,18 +758,18 @@ function PanelGroupWithForwardedRef({
|
|
|
741
758
|
pendingPanelIds.forEach((panelId) => {
|
|
742
759
|
pendingPanelIds.delete(panelId);
|
|
743
760
|
|
|
744
|
-
if (panelDataArray.find(({ id }) => id === panelId)
|
|
761
|
+
if (panelDataArray.find(({ id }) => id === panelId) != null) {
|
|
745
762
|
unmountDueToStrictMode = true;
|
|
746
|
-
|
|
763
|
+
} else {
|
|
747
764
|
// TRICKY
|
|
748
765
|
// When a panel is removed from the group, we should delete the most recent prev-size entry for it.
|
|
749
766
|
// If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
|
|
750
767
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
751
|
-
delete
|
|
768
|
+
delete panelIdToLastNotifiedSizeMap[panelId];
|
|
752
769
|
}
|
|
753
770
|
});
|
|
754
771
|
|
|
755
|
-
if (
|
|
772
|
+
if (unmountDueToStrictMode) {
|
|
756
773
|
return;
|
|
757
774
|
}
|
|
758
775
|
|
|
@@ -868,6 +885,13 @@ export const PanelGroup = forwardRef<
|
|
|
868
885
|
PanelGroupWithForwardedRef.displayName = "PanelGroup";
|
|
869
886
|
PanelGroup.displayName = "forwardRef(PanelGroup)";
|
|
870
887
|
|
|
888
|
+
function findPanelDataIndex(panelDataArray: PanelData[], panelData: PanelData) {
|
|
889
|
+
return panelDataArray.findIndex(
|
|
890
|
+
(prevPanelData) =>
|
|
891
|
+
prevPanelData === panelData || prevPanelData.id === panelData.id
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
|
|
871
895
|
function panelDataHelper(
|
|
872
896
|
panelDataArray: PanelData[],
|
|
873
897
|
panelData: PanelData,
|
|
@@ -877,7 +901,7 @@ function panelDataHelper(
|
|
|
877
901
|
(panelData) => panelData.constraints
|
|
878
902
|
);
|
|
879
903
|
|
|
880
|
-
const panelIndex = panelDataArray
|
|
904
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
881
905
|
const panelConstraints = panelConstraintsArray[panelIndex];
|
|
882
906
|
|
|
883
907
|
const isLastPanel = panelIndex === panelDataArray.length - 1;
|