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
|
@@ -211,8 +211,6 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
211
211
|
PanelWithForwardedRef.displayName = "Panel";
|
|
212
212
|
Panel.displayName = "forwardRef(Panel)";
|
|
213
213
|
|
|
214
|
-
const PRECISION = 10;
|
|
215
|
-
|
|
216
214
|
function convertPixelsToPercentage(pixels, groupSizePixels) {
|
|
217
215
|
return pixels / groupSizePixels * 100;
|
|
218
216
|
}
|
|
@@ -290,6 +288,8 @@ function computePercentagePanelConstraints(panelConstraintsArray, panelIndex, gr
|
|
|
290
288
|
};
|
|
291
289
|
}
|
|
292
290
|
|
|
291
|
+
const PRECISION = 10;
|
|
292
|
+
|
|
293
293
|
function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
|
|
294
294
|
actual = parseFloat(actual.toFixed(fractionDigits));
|
|
295
295
|
expected = parseFloat(expected.toFixed(fractionDigits));
|
|
@@ -773,15 +773,10 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
773
773
|
}, [groupId, layout, panelDataArray]);
|
|
774
774
|
useEffect(() => {
|
|
775
775
|
const {
|
|
776
|
-
direction,
|
|
777
776
|
panelDataArray
|
|
778
777
|
} = committedValuesRef.current;
|
|
779
778
|
const groupElement = getPanelGroupElement(groupId);
|
|
780
779
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
781
|
-
const {
|
|
782
|
-
height,
|
|
783
|
-
width
|
|
784
|
-
} = groupElement.getBoundingClientRect();
|
|
785
780
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
786
781
|
const cleanupFunctions = handles.map(handle => {
|
|
787
782
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
@@ -801,21 +796,19 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
801
796
|
if (index >= 0) {
|
|
802
797
|
const panelData = panelDataArray[index];
|
|
803
798
|
const size = layout[index];
|
|
804
|
-
if (size != null) {
|
|
805
|
-
var _getPercentageSizeFro;
|
|
799
|
+
if (size != null && panelData.constraints.collapsible) {
|
|
800
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
806
801
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
807
|
-
const
|
|
802
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
803
|
+
sizePercentage: panelData.constraints.collapsedSizePercentage,
|
|
804
|
+
sizePixels: panelData.constraints.collapsedSizePixels
|
|
805
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
806
|
+
const minSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
808
807
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
809
808
|
sizePixels: panelData.constraints.minSizePixels
|
|
810
|
-
}, groupSizePixels)) !== null &&
|
|
811
|
-
let delta = 0;
|
|
812
|
-
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
813
|
-
delta = direction === "horizontal" ? width : height;
|
|
814
|
-
} else {
|
|
815
|
-
delta = -(direction === "horizontal" ? width : height);
|
|
816
|
-
}
|
|
809
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 0;
|
|
817
810
|
const nextLayout = adjustLayoutByDelta({
|
|
818
|
-
delta,
|
|
811
|
+
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
819
812
|
groupSizePixels,
|
|
820
813
|
layout,
|
|
821
814
|
panelConstraints: panelDataArray.map(panelData => panelData.constraints),
|
|
@@ -1371,6 +1364,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1371
1364
|
const panelIdToLastNotifiedMixedSizesMapRef = useRef({});
|
|
1372
1365
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1373
1366
|
const prevDeltaRef = useRef(0);
|
|
1367
|
+
const [imperativeApiQueue, setImperativeApiQueue] = useState([]);
|
|
1374
1368
|
const committedValuesRef = useRef({
|
|
1375
1369
|
direction,
|
|
1376
1370
|
dragState,
|
|
@@ -1479,8 +1473,12 @@ function PanelGroupWithForwardedRef({
|
|
|
1479
1473
|
}
|
|
1480
1474
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1481
1475
|
if (groupSizePixels <= 0) {
|
|
1482
|
-
|
|
1483
|
-
|
|
1476
|
+
if (shouldMonitorPixelBasedConstraints(panelDataArray.map(({
|
|
1477
|
+
constraints
|
|
1478
|
+
}) => constraints))) {
|
|
1479
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1484
1482
|
}
|
|
1485
1483
|
if (unsafeLayout == null) {
|
|
1486
1484
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
@@ -1600,6 +1598,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1600
1598
|
onLayout,
|
|
1601
1599
|
panelDataArray
|
|
1602
1600
|
} = committedValuesRef.current;
|
|
1601
|
+
|
|
1602
|
+
// See issues/211
|
|
1603
|
+
if (panelDataArray.find(({
|
|
1604
|
+
id
|
|
1605
|
+
}) => id === panelData.id) == null) {
|
|
1606
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1607
|
+
panelData,
|
|
1608
|
+
type: "collapse"
|
|
1609
|
+
}]);
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1603
1612
|
if (panelData.constraints.collapsible) {
|
|
1604
1613
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1605
1614
|
const {
|
|
@@ -1643,6 +1652,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1643
1652
|
onLayout,
|
|
1644
1653
|
panelDataArray
|
|
1645
1654
|
} = committedValuesRef.current;
|
|
1655
|
+
|
|
1656
|
+
// See issues/211
|
|
1657
|
+
if (panelDataArray.find(({
|
|
1658
|
+
id
|
|
1659
|
+
}) => id === panelData.id) == null) {
|
|
1660
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1661
|
+
panelData,
|
|
1662
|
+
type: "expand"
|
|
1663
|
+
}]);
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1646
1666
|
if (panelData.constraints.collapsible) {
|
|
1647
1667
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1648
1668
|
const {
|
|
@@ -1838,6 +1858,18 @@ function PanelGroupWithForwardedRef({
|
|
|
1838
1858
|
onLayout,
|
|
1839
1859
|
panelDataArray
|
|
1840
1860
|
} = committedValuesRef.current;
|
|
1861
|
+
|
|
1862
|
+
// See issues/211
|
|
1863
|
+
if (panelDataArray.find(({
|
|
1864
|
+
id
|
|
1865
|
+
}) => id === panelData.id) == null) {
|
|
1866
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1867
|
+
panelData,
|
|
1868
|
+
mixedSizes,
|
|
1869
|
+
type: "resize"
|
|
1870
|
+
}]);
|
|
1871
|
+
return;
|
|
1872
|
+
}
|
|
1841
1873
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1842
1874
|
const {
|
|
1843
1875
|
groupSizePixels,
|
|
@@ -1895,6 +1927,31 @@ function PanelGroupWithForwardedRef({
|
|
|
1895
1927
|
return panelDataArray;
|
|
1896
1928
|
});
|
|
1897
1929
|
}, []);
|
|
1930
|
+
|
|
1931
|
+
// Handle imperative API calls that were made before panels were registered
|
|
1932
|
+
useIsomorphicLayoutEffect(() => {
|
|
1933
|
+
const queue = imperativeApiQueue;
|
|
1934
|
+
while (queue.length > 0) {
|
|
1935
|
+
const current = queue.shift();
|
|
1936
|
+
switch (current.type) {
|
|
1937
|
+
case "collapse":
|
|
1938
|
+
{
|
|
1939
|
+
collapsePanel(current.panelData);
|
|
1940
|
+
break;
|
|
1941
|
+
}
|
|
1942
|
+
case "expand":
|
|
1943
|
+
{
|
|
1944
|
+
expandPanel(current.panelData);
|
|
1945
|
+
break;
|
|
1946
|
+
}
|
|
1947
|
+
case "resize":
|
|
1948
|
+
{
|
|
1949
|
+
resizePanel(current.panelData, current.mixedSizes);
|
|
1950
|
+
break;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
}, [collapsePanel, expandPanel, imperativeApiQueue, layout, panelDataArray, resizePanel]);
|
|
1898
1955
|
const context = useMemo(() => ({
|
|
1899
1956
|
collapsePanel,
|
|
1900
1957
|
direction,
|
|
@@ -187,8 +187,6 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
187
187
|
PanelWithForwardedRef.displayName = "Panel";
|
|
188
188
|
Panel.displayName = "forwardRef(Panel)";
|
|
189
189
|
|
|
190
|
-
const PRECISION = 10;
|
|
191
|
-
|
|
192
190
|
function convertPixelsToPercentage(pixels, groupSizePixels) {
|
|
193
191
|
return pixels / groupSizePixels * 100;
|
|
194
192
|
}
|
|
@@ -266,6 +264,8 @@ function computePercentagePanelConstraints(panelConstraintsArray, panelIndex, gr
|
|
|
266
264
|
};
|
|
267
265
|
}
|
|
268
266
|
|
|
267
|
+
const PRECISION = 10;
|
|
268
|
+
|
|
269
269
|
function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
|
|
270
270
|
actual = parseFloat(actual.toFixed(fractionDigits));
|
|
271
271
|
expected = parseFloat(expected.toFixed(fractionDigits));
|
|
@@ -749,15 +749,10 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
749
749
|
}, [groupId, layout, panelDataArray]);
|
|
750
750
|
useEffect(() => {
|
|
751
751
|
const {
|
|
752
|
-
direction,
|
|
753
752
|
panelDataArray
|
|
754
753
|
} = committedValuesRef.current;
|
|
755
754
|
const groupElement = getPanelGroupElement(groupId);
|
|
756
755
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
757
|
-
const {
|
|
758
|
-
height,
|
|
759
|
-
width
|
|
760
|
-
} = groupElement.getBoundingClientRect();
|
|
761
756
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
762
757
|
const cleanupFunctions = handles.map(handle => {
|
|
763
758
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
@@ -777,21 +772,19 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
777
772
|
if (index >= 0) {
|
|
778
773
|
const panelData = panelDataArray[index];
|
|
779
774
|
const size = layout[index];
|
|
780
|
-
if (size != null) {
|
|
781
|
-
var _getPercentageSizeFro;
|
|
775
|
+
if (size != null && panelData.constraints.collapsible) {
|
|
776
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
782
777
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
783
|
-
const
|
|
778
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
779
|
+
sizePercentage: panelData.constraints.collapsedSizePercentage,
|
|
780
|
+
sizePixels: panelData.constraints.collapsedSizePixels
|
|
781
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
782
|
+
const minSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
784
783
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
785
784
|
sizePixels: panelData.constraints.minSizePixels
|
|
786
|
-
}, groupSizePixels)) !== null &&
|
|
787
|
-
let delta = 0;
|
|
788
|
-
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
789
|
-
delta = direction === "horizontal" ? width : height;
|
|
790
|
-
} else {
|
|
791
|
-
delta = -(direction === "horizontal" ? width : height);
|
|
792
|
-
}
|
|
785
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 0;
|
|
793
786
|
const nextLayout = adjustLayoutByDelta({
|
|
794
|
-
delta,
|
|
787
|
+
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
795
788
|
groupSizePixels,
|
|
796
789
|
layout,
|
|
797
790
|
panelConstraints: panelDataArray.map(panelData => panelData.constraints),
|
|
@@ -1347,6 +1340,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1347
1340
|
const panelIdToLastNotifiedMixedSizesMapRef = useRef({});
|
|
1348
1341
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1349
1342
|
const prevDeltaRef = useRef(0);
|
|
1343
|
+
const [imperativeApiQueue, setImperativeApiQueue] = useState([]);
|
|
1350
1344
|
const committedValuesRef = useRef({
|
|
1351
1345
|
direction,
|
|
1352
1346
|
dragState,
|
|
@@ -1455,8 +1449,12 @@ function PanelGroupWithForwardedRef({
|
|
|
1455
1449
|
}
|
|
1456
1450
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1457
1451
|
if (groupSizePixels <= 0) {
|
|
1458
|
-
|
|
1459
|
-
|
|
1452
|
+
if (shouldMonitorPixelBasedConstraints(panelDataArray.map(({
|
|
1453
|
+
constraints
|
|
1454
|
+
}) => constraints))) {
|
|
1455
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1460
1458
|
}
|
|
1461
1459
|
if (unsafeLayout == null) {
|
|
1462
1460
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
@@ -1576,6 +1574,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1576
1574
|
onLayout,
|
|
1577
1575
|
panelDataArray
|
|
1578
1576
|
} = committedValuesRef.current;
|
|
1577
|
+
|
|
1578
|
+
// See issues/211
|
|
1579
|
+
if (panelDataArray.find(({
|
|
1580
|
+
id
|
|
1581
|
+
}) => id === panelData.id) == null) {
|
|
1582
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1583
|
+
panelData,
|
|
1584
|
+
type: "collapse"
|
|
1585
|
+
}]);
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1579
1588
|
if (panelData.constraints.collapsible) {
|
|
1580
1589
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1581
1590
|
const {
|
|
@@ -1619,6 +1628,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1619
1628
|
onLayout,
|
|
1620
1629
|
panelDataArray
|
|
1621
1630
|
} = committedValuesRef.current;
|
|
1631
|
+
|
|
1632
|
+
// See issues/211
|
|
1633
|
+
if (panelDataArray.find(({
|
|
1634
|
+
id
|
|
1635
|
+
}) => id === panelData.id) == null) {
|
|
1636
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1637
|
+
panelData,
|
|
1638
|
+
type: "expand"
|
|
1639
|
+
}]);
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1622
1642
|
if (panelData.constraints.collapsible) {
|
|
1623
1643
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1624
1644
|
const {
|
|
@@ -1814,6 +1834,18 @@ function PanelGroupWithForwardedRef({
|
|
|
1814
1834
|
onLayout,
|
|
1815
1835
|
panelDataArray
|
|
1816
1836
|
} = committedValuesRef.current;
|
|
1837
|
+
|
|
1838
|
+
// See issues/211
|
|
1839
|
+
if (panelDataArray.find(({
|
|
1840
|
+
id
|
|
1841
|
+
}) => id === panelData.id) == null) {
|
|
1842
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1843
|
+
panelData,
|
|
1844
|
+
mixedSizes,
|
|
1845
|
+
type: "resize"
|
|
1846
|
+
}]);
|
|
1847
|
+
return;
|
|
1848
|
+
}
|
|
1817
1849
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1818
1850
|
const {
|
|
1819
1851
|
groupSizePixels,
|
|
@@ -1871,6 +1903,31 @@ function PanelGroupWithForwardedRef({
|
|
|
1871
1903
|
return panelDataArray;
|
|
1872
1904
|
});
|
|
1873
1905
|
}, []);
|
|
1906
|
+
|
|
1907
|
+
// Handle imperative API calls that were made before panels were registered
|
|
1908
|
+
useIsomorphicLayoutEffect(() => {
|
|
1909
|
+
const queue = imperativeApiQueue;
|
|
1910
|
+
while (queue.length > 0) {
|
|
1911
|
+
const current = queue.shift();
|
|
1912
|
+
switch (current.type) {
|
|
1913
|
+
case "collapse":
|
|
1914
|
+
{
|
|
1915
|
+
collapsePanel(current.panelData);
|
|
1916
|
+
break;
|
|
1917
|
+
}
|
|
1918
|
+
case "expand":
|
|
1919
|
+
{
|
|
1920
|
+
expandPanel(current.panelData);
|
|
1921
|
+
break;
|
|
1922
|
+
}
|
|
1923
|
+
case "resize":
|
|
1924
|
+
{
|
|
1925
|
+
resizePanel(current.panelData, current.mixedSizes);
|
|
1926
|
+
break;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
}, [collapsePanel, expandPanel, imperativeApiQueue, layout, panelDataArray, resizePanel]);
|
|
1874
1931
|
const context = useMemo(() => ({
|
|
1875
1932
|
collapsePanel,
|
|
1876
1933
|
direction,
|
|
@@ -179,8 +179,6 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
179
179
|
PanelWithForwardedRef.displayName = "Panel";
|
|
180
180
|
Panel.displayName = "forwardRef(Panel)";
|
|
181
181
|
|
|
182
|
-
const PRECISION = 10;
|
|
183
|
-
|
|
184
182
|
function convertPixelsToPercentage(pixels, groupSizePixels) {
|
|
185
183
|
return pixels / groupSizePixels * 100;
|
|
186
184
|
}
|
|
@@ -258,6 +256,8 @@ function computePercentagePanelConstraints(panelConstraintsArray, panelIndex, gr
|
|
|
258
256
|
};
|
|
259
257
|
}
|
|
260
258
|
|
|
259
|
+
const PRECISION = 10;
|
|
260
|
+
|
|
261
261
|
function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
|
|
262
262
|
actual = parseFloat(actual.toFixed(fractionDigits));
|
|
263
263
|
expected = parseFloat(expected.toFixed(fractionDigits));
|
|
@@ -651,15 +651,10 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
651
651
|
});
|
|
652
652
|
useEffect(() => {
|
|
653
653
|
const {
|
|
654
|
-
direction,
|
|
655
654
|
panelDataArray
|
|
656
655
|
} = committedValuesRef.current;
|
|
657
656
|
const groupElement = getPanelGroupElement(groupId);
|
|
658
657
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
659
|
-
const {
|
|
660
|
-
height,
|
|
661
|
-
width
|
|
662
|
-
} = groupElement.getBoundingClientRect();
|
|
663
658
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
664
659
|
const cleanupFunctions = handles.map(handle => {
|
|
665
660
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
@@ -679,21 +674,19 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
679
674
|
if (index >= 0) {
|
|
680
675
|
const panelData = panelDataArray[index];
|
|
681
676
|
const size = layout[index];
|
|
682
|
-
if (size != null) {
|
|
683
|
-
var _getPercentageSizeFro;
|
|
677
|
+
if (size != null && panelData.constraints.collapsible) {
|
|
678
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
684
679
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
685
|
-
const
|
|
680
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
681
|
+
sizePercentage: panelData.constraints.collapsedSizePercentage,
|
|
682
|
+
sizePixels: panelData.constraints.collapsedSizePixels
|
|
683
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
684
|
+
const minSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
686
685
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
687
686
|
sizePixels: panelData.constraints.minSizePixels
|
|
688
|
-
}, groupSizePixels)) !== null &&
|
|
689
|
-
let delta = 0;
|
|
690
|
-
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
691
|
-
delta = direction === "horizontal" ? width : height;
|
|
692
|
-
} else {
|
|
693
|
-
delta = -(direction === "horizontal" ? width : height);
|
|
694
|
-
}
|
|
687
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 0;
|
|
695
688
|
const nextLayout = adjustLayoutByDelta({
|
|
696
|
-
delta,
|
|
689
|
+
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
697
690
|
groupSizePixels,
|
|
698
691
|
layout,
|
|
699
692
|
panelConstraints: panelDataArray.map(panelData => panelData.constraints),
|
|
@@ -1196,6 +1189,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1196
1189
|
const panelIdToLastNotifiedMixedSizesMapRef = useRef({});
|
|
1197
1190
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1198
1191
|
const prevDeltaRef = useRef(0);
|
|
1192
|
+
const [imperativeApiQueue, setImperativeApiQueue] = useState([]);
|
|
1199
1193
|
const committedValuesRef = useRef({
|
|
1200
1194
|
direction,
|
|
1201
1195
|
dragState,
|
|
@@ -1327,6 +1321,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1327
1321
|
onLayout,
|
|
1328
1322
|
panelDataArray
|
|
1329
1323
|
} = committedValuesRef.current;
|
|
1324
|
+
|
|
1325
|
+
// See issues/211
|
|
1326
|
+
if (panelDataArray.find(({
|
|
1327
|
+
id
|
|
1328
|
+
}) => id === panelData.id) == null) {
|
|
1329
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1330
|
+
panelData,
|
|
1331
|
+
type: "collapse"
|
|
1332
|
+
}]);
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1330
1335
|
if (panelData.constraints.collapsible) {
|
|
1331
1336
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1332
1337
|
const {
|
|
@@ -1370,6 +1375,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1370
1375
|
onLayout,
|
|
1371
1376
|
panelDataArray
|
|
1372
1377
|
} = committedValuesRef.current;
|
|
1378
|
+
|
|
1379
|
+
// See issues/211
|
|
1380
|
+
if (panelDataArray.find(({
|
|
1381
|
+
id
|
|
1382
|
+
}) => id === panelData.id) == null) {
|
|
1383
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1384
|
+
panelData,
|
|
1385
|
+
type: "expand"
|
|
1386
|
+
}]);
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1373
1389
|
if (panelData.constraints.collapsible) {
|
|
1374
1390
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1375
1391
|
const {
|
|
@@ -1565,6 +1581,18 @@ function PanelGroupWithForwardedRef({
|
|
|
1565
1581
|
onLayout,
|
|
1566
1582
|
panelDataArray
|
|
1567
1583
|
} = committedValuesRef.current;
|
|
1584
|
+
|
|
1585
|
+
// See issues/211
|
|
1586
|
+
if (panelDataArray.find(({
|
|
1587
|
+
id
|
|
1588
|
+
}) => id === panelData.id) == null) {
|
|
1589
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1590
|
+
panelData,
|
|
1591
|
+
mixedSizes,
|
|
1592
|
+
type: "resize"
|
|
1593
|
+
}]);
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1568
1596
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1569
1597
|
const {
|
|
1570
1598
|
groupSizePixels,
|
|
@@ -155,8 +155,6 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
155
155
|
PanelWithForwardedRef.displayName = "Panel";
|
|
156
156
|
Panel.displayName = "forwardRef(Panel)";
|
|
157
157
|
|
|
158
|
-
const PRECISION = 10;
|
|
159
|
-
|
|
160
158
|
function convertPixelsToPercentage(pixels, groupSizePixels) {
|
|
161
159
|
return pixels / groupSizePixels * 100;
|
|
162
160
|
}
|
|
@@ -234,6 +232,8 @@ function computePercentagePanelConstraints(panelConstraintsArray, panelIndex, gr
|
|
|
234
232
|
};
|
|
235
233
|
}
|
|
236
234
|
|
|
235
|
+
const PRECISION = 10;
|
|
236
|
+
|
|
237
237
|
function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
|
|
238
238
|
actual = parseFloat(actual.toFixed(fractionDigits));
|
|
239
239
|
expected = parseFloat(expected.toFixed(fractionDigits));
|
|
@@ -627,15 +627,10 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
627
627
|
});
|
|
628
628
|
useEffect(() => {
|
|
629
629
|
const {
|
|
630
|
-
direction,
|
|
631
630
|
panelDataArray
|
|
632
631
|
} = committedValuesRef.current;
|
|
633
632
|
const groupElement = getPanelGroupElement(groupId);
|
|
634
633
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
635
|
-
const {
|
|
636
|
-
height,
|
|
637
|
-
width
|
|
638
|
-
} = groupElement.getBoundingClientRect();
|
|
639
634
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
640
635
|
const cleanupFunctions = handles.map(handle => {
|
|
641
636
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
@@ -655,21 +650,19 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
655
650
|
if (index >= 0) {
|
|
656
651
|
const panelData = panelDataArray[index];
|
|
657
652
|
const size = layout[index];
|
|
658
|
-
if (size != null) {
|
|
659
|
-
var _getPercentageSizeFro;
|
|
653
|
+
if (size != null && panelData.constraints.collapsible) {
|
|
654
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
660
655
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
661
|
-
const
|
|
656
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
657
|
+
sizePercentage: panelData.constraints.collapsedSizePercentage,
|
|
658
|
+
sizePixels: panelData.constraints.collapsedSizePixels
|
|
659
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
660
|
+
const minSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
662
661
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
663
662
|
sizePixels: panelData.constraints.minSizePixels
|
|
664
|
-
}, groupSizePixels)) !== null &&
|
|
665
|
-
let delta = 0;
|
|
666
|
-
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
667
|
-
delta = direction === "horizontal" ? width : height;
|
|
668
|
-
} else {
|
|
669
|
-
delta = -(direction === "horizontal" ? width : height);
|
|
670
|
-
}
|
|
663
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 0;
|
|
671
664
|
const nextLayout = adjustLayoutByDelta({
|
|
672
|
-
delta,
|
|
665
|
+
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
673
666
|
groupSizePixels,
|
|
674
667
|
layout,
|
|
675
668
|
panelConstraints: panelDataArray.map(panelData => panelData.constraints),
|
|
@@ -1172,6 +1165,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1172
1165
|
const panelIdToLastNotifiedMixedSizesMapRef = useRef({});
|
|
1173
1166
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1174
1167
|
const prevDeltaRef = useRef(0);
|
|
1168
|
+
const [imperativeApiQueue, setImperativeApiQueue] = useState([]);
|
|
1175
1169
|
const committedValuesRef = useRef({
|
|
1176
1170
|
direction,
|
|
1177
1171
|
dragState,
|
|
@@ -1303,6 +1297,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1303
1297
|
onLayout,
|
|
1304
1298
|
panelDataArray
|
|
1305
1299
|
} = committedValuesRef.current;
|
|
1300
|
+
|
|
1301
|
+
// See issues/211
|
|
1302
|
+
if (panelDataArray.find(({
|
|
1303
|
+
id
|
|
1304
|
+
}) => id === panelData.id) == null) {
|
|
1305
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1306
|
+
panelData,
|
|
1307
|
+
type: "collapse"
|
|
1308
|
+
}]);
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1306
1311
|
if (panelData.constraints.collapsible) {
|
|
1307
1312
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1308
1313
|
const {
|
|
@@ -1346,6 +1351,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1346
1351
|
onLayout,
|
|
1347
1352
|
panelDataArray
|
|
1348
1353
|
} = committedValuesRef.current;
|
|
1354
|
+
|
|
1355
|
+
// See issues/211
|
|
1356
|
+
if (panelDataArray.find(({
|
|
1357
|
+
id
|
|
1358
|
+
}) => id === panelData.id) == null) {
|
|
1359
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1360
|
+
panelData,
|
|
1361
|
+
type: "expand"
|
|
1362
|
+
}]);
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1349
1365
|
if (panelData.constraints.collapsible) {
|
|
1350
1366
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1351
1367
|
const {
|
|
@@ -1541,6 +1557,18 @@ function PanelGroupWithForwardedRef({
|
|
|
1541
1557
|
onLayout,
|
|
1542
1558
|
panelDataArray
|
|
1543
1559
|
} = committedValuesRef.current;
|
|
1560
|
+
|
|
1561
|
+
// See issues/211
|
|
1562
|
+
if (panelDataArray.find(({
|
|
1563
|
+
id
|
|
1564
|
+
}) => id === panelData.id) == null) {
|
|
1565
|
+
setImperativeApiQueue(prev => [...prev, {
|
|
1566
|
+
panelData,
|
|
1567
|
+
mixedSizes,
|
|
1568
|
+
type: "resize"
|
|
1569
|
+
}]);
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1544
1572
|
const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
|
|
1545
1573
|
const {
|
|
1546
1574
|
groupSizePixels,
|