react-resizable-panels 2.0.18 → 2.0.19
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 +4 -0
- package/dist/declarations/src/Panel.d.ts +1 -1
- package/dist/react-resizable-panels.browser.cjs.js +5 -4
- package/dist/react-resizable-panels.browser.development.cjs.js +5 -4
- package/dist/react-resizable-panels.browser.development.esm.js +5 -4
- package/dist/react-resizable-panels.browser.esm.js +5 -4
- package/dist/react-resizable-panels.cjs.js +5 -4
- package/dist/react-resizable-panels.development.cjs.js +5 -4
- package/dist/react-resizable-panels.development.esm.js +5 -4
- package/dist/react-resizable-panels.development.node.cjs.js +5 -4
- package/dist/react-resizable-panels.development.node.esm.js +5 -4
- package/dist/react-resizable-panels.esm.js +5 -4
- package/dist/react-resizable-panels.node.cjs.js +5 -4
- package/dist/react-resizable-panels.node.esm.js +5 -4
- package/package.json +1 -1
- package/src/Panel.test.tsx +105 -0
- package/src/Panel.ts +3 -3
- package/src/PanelGroup.ts +54 -47
- package/src/PanelGroupContext.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -157,8 +157,8 @@ function PanelWithForwardedRef({
|
|
|
157
157
|
collapse: () => {
|
|
158
158
|
collapsePanel(panelDataRef.current);
|
|
159
159
|
},
|
|
160
|
-
expand:
|
|
161
|
-
expandPanel(panelDataRef.current);
|
|
160
|
+
expand: minSize => {
|
|
161
|
+
expandPanel(panelDataRef.current, minSize);
|
|
162
162
|
},
|
|
163
163
|
getId() {
|
|
164
164
|
return panelId;
|
|
@@ -1722,7 +1722,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1722
1722
|
}, []);
|
|
1723
1723
|
|
|
1724
1724
|
// External APIs are safe to memoize via committed values ref
|
|
1725
|
-
const expandPanel = useCallback(panelData => {
|
|
1725
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1726
1726
|
const {
|
|
1727
1727
|
onLayout
|
|
1728
1728
|
} = committedValuesRef.current;
|
|
@@ -1735,9 +1735,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1735
1735
|
const {
|
|
1736
1736
|
collapsedSize = 0,
|
|
1737
1737
|
panelSize = 0,
|
|
1738
|
-
minSize = 0,
|
|
1738
|
+
minSize: minSizeFromProps = 0,
|
|
1739
1739
|
pivotIndices
|
|
1740
1740
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1741
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1741
1742
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1742
1743
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1743
1744
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
@@ -163,8 +163,8 @@ function PanelWithForwardedRef({
|
|
|
163
163
|
collapse: () => {
|
|
164
164
|
collapsePanel(panelDataRef.current);
|
|
165
165
|
},
|
|
166
|
-
expand:
|
|
167
|
-
expandPanel(panelDataRef.current);
|
|
166
|
+
expand: minSize => {
|
|
167
|
+
expandPanel(panelDataRef.current, minSize);
|
|
168
168
|
},
|
|
169
169
|
getId() {
|
|
170
170
|
return panelId;
|
|
@@ -1828,7 +1828,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1828
1828
|
}, []);
|
|
1829
1829
|
|
|
1830
1830
|
// External APIs are safe to memoize via committed values ref
|
|
1831
|
-
const expandPanel = useCallback(panelData => {
|
|
1831
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1832
1832
|
const {
|
|
1833
1833
|
onLayout
|
|
1834
1834
|
} = committedValuesRef.current;
|
|
@@ -1841,9 +1841,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1841
1841
|
const {
|
|
1842
1842
|
collapsedSize = 0,
|
|
1843
1843
|
panelSize = 0,
|
|
1844
|
-
minSize = 0,
|
|
1844
|
+
minSize: minSizeFromProps = 0,
|
|
1845
1845
|
pivotIndices
|
|
1846
1846
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1847
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1847
1848
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1848
1849
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1849
1850
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
@@ -139,8 +139,8 @@ function PanelWithForwardedRef({
|
|
|
139
139
|
collapse: () => {
|
|
140
140
|
collapsePanel(panelDataRef.current);
|
|
141
141
|
},
|
|
142
|
-
expand:
|
|
143
|
-
expandPanel(panelDataRef.current);
|
|
142
|
+
expand: minSize => {
|
|
143
|
+
expandPanel(panelDataRef.current, minSize);
|
|
144
144
|
},
|
|
145
145
|
getId() {
|
|
146
146
|
return panelId;
|
|
@@ -1804,7 +1804,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1804
1804
|
}, []);
|
|
1805
1805
|
|
|
1806
1806
|
// External APIs are safe to memoize via committed values ref
|
|
1807
|
-
const expandPanel = useCallback(panelData => {
|
|
1807
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1808
1808
|
const {
|
|
1809
1809
|
onLayout
|
|
1810
1810
|
} = committedValuesRef.current;
|
|
@@ -1817,9 +1817,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1817
1817
|
const {
|
|
1818
1818
|
collapsedSize = 0,
|
|
1819
1819
|
panelSize = 0,
|
|
1820
|
-
minSize = 0,
|
|
1820
|
+
minSize: minSizeFromProps = 0,
|
|
1821
1821
|
pivotIndices
|
|
1822
1822
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1823
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1823
1824
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1824
1825
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1825
1826
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
@@ -133,8 +133,8 @@ function PanelWithForwardedRef({
|
|
|
133
133
|
collapse: () => {
|
|
134
134
|
collapsePanel(panelDataRef.current);
|
|
135
135
|
},
|
|
136
|
-
expand:
|
|
137
|
-
expandPanel(panelDataRef.current);
|
|
136
|
+
expand: minSize => {
|
|
137
|
+
expandPanel(panelDataRef.current, minSize);
|
|
138
138
|
},
|
|
139
139
|
getId() {
|
|
140
140
|
return panelId;
|
|
@@ -1698,7 +1698,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1698
1698
|
}, []);
|
|
1699
1699
|
|
|
1700
1700
|
// External APIs are safe to memoize via committed values ref
|
|
1701
|
-
const expandPanel = useCallback(panelData => {
|
|
1701
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1702
1702
|
const {
|
|
1703
1703
|
onLayout
|
|
1704
1704
|
} = committedValuesRef.current;
|
|
@@ -1711,9 +1711,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1711
1711
|
const {
|
|
1712
1712
|
collapsedSize = 0,
|
|
1713
1713
|
panelSize = 0,
|
|
1714
|
-
minSize = 0,
|
|
1714
|
+
minSize: minSizeFromProps = 0,
|
|
1715
1715
|
pivotIndices
|
|
1716
1716
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1717
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1717
1718
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1718
1719
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1719
1720
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
@@ -159,8 +159,8 @@ function PanelWithForwardedRef({
|
|
|
159
159
|
collapse: () => {
|
|
160
160
|
collapsePanel(panelDataRef.current);
|
|
161
161
|
},
|
|
162
|
-
expand:
|
|
163
|
-
expandPanel(panelDataRef.current);
|
|
162
|
+
expand: minSize => {
|
|
163
|
+
expandPanel(panelDataRef.current, minSize);
|
|
164
164
|
},
|
|
165
165
|
getId() {
|
|
166
166
|
return panelId;
|
|
@@ -1724,7 +1724,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1724
1724
|
}, []);
|
|
1725
1725
|
|
|
1726
1726
|
// External APIs are safe to memoize via committed values ref
|
|
1727
|
-
const expandPanel = useCallback(panelData => {
|
|
1727
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1728
1728
|
const {
|
|
1729
1729
|
onLayout
|
|
1730
1730
|
} = committedValuesRef.current;
|
|
@@ -1737,9 +1737,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1737
1737
|
const {
|
|
1738
1738
|
collapsedSize = 0,
|
|
1739
1739
|
panelSize = 0,
|
|
1740
|
-
minSize = 0,
|
|
1740
|
+
minSize: minSizeFromProps = 0,
|
|
1741
1741
|
pivotIndices
|
|
1742
1742
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1743
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1743
1744
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1744
1745
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1745
1746
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
@@ -170,8 +170,8 @@ function PanelWithForwardedRef({
|
|
|
170
170
|
collapse: () => {
|
|
171
171
|
collapsePanel(panelDataRef.current);
|
|
172
172
|
},
|
|
173
|
-
expand:
|
|
174
|
-
expandPanel(panelDataRef.current);
|
|
173
|
+
expand: minSize => {
|
|
174
|
+
expandPanel(panelDataRef.current, minSize);
|
|
175
175
|
},
|
|
176
176
|
getId() {
|
|
177
177
|
return panelId;
|
|
@@ -1835,7 +1835,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1835
1835
|
}, []);
|
|
1836
1836
|
|
|
1837
1837
|
// External APIs are safe to memoize via committed values ref
|
|
1838
|
-
const expandPanel = useCallback(panelData => {
|
|
1838
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1839
1839
|
const {
|
|
1840
1840
|
onLayout
|
|
1841
1841
|
} = committedValuesRef.current;
|
|
@@ -1848,9 +1848,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1848
1848
|
const {
|
|
1849
1849
|
collapsedSize = 0,
|
|
1850
1850
|
panelSize = 0,
|
|
1851
|
-
minSize = 0,
|
|
1851
|
+
minSize: minSizeFromProps = 0,
|
|
1852
1852
|
pivotIndices
|
|
1853
1853
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1854
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1854
1855
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1855
1856
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1856
1857
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
@@ -146,8 +146,8 @@ function PanelWithForwardedRef({
|
|
|
146
146
|
collapse: () => {
|
|
147
147
|
collapsePanel(panelDataRef.current);
|
|
148
148
|
},
|
|
149
|
-
expand:
|
|
150
|
-
expandPanel(panelDataRef.current);
|
|
149
|
+
expand: minSize => {
|
|
150
|
+
expandPanel(panelDataRef.current, minSize);
|
|
151
151
|
},
|
|
152
152
|
getId() {
|
|
153
153
|
return panelId;
|
|
@@ -1811,7 +1811,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1811
1811
|
}, []);
|
|
1812
1812
|
|
|
1813
1813
|
// External APIs are safe to memoize via committed values ref
|
|
1814
|
-
const expandPanel = useCallback(panelData => {
|
|
1814
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1815
1815
|
const {
|
|
1816
1816
|
onLayout
|
|
1817
1817
|
} = committedValuesRef.current;
|
|
@@ -1824,9 +1824,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1824
1824
|
const {
|
|
1825
1825
|
collapsedSize = 0,
|
|
1826
1826
|
panelSize = 0,
|
|
1827
|
-
minSize = 0,
|
|
1827
|
+
minSize: minSizeFromProps = 0,
|
|
1828
1828
|
pivotIndices
|
|
1829
1829
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1830
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1830
1831
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1831
1832
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1832
1833
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
@@ -132,8 +132,8 @@ function PanelWithForwardedRef({
|
|
|
132
132
|
collapse: () => {
|
|
133
133
|
collapsePanel(panelDataRef.current);
|
|
134
134
|
},
|
|
135
|
-
expand:
|
|
136
|
-
expandPanel(panelDataRef.current);
|
|
135
|
+
expand: minSize => {
|
|
136
|
+
expandPanel(panelDataRef.current, minSize);
|
|
137
137
|
},
|
|
138
138
|
getId() {
|
|
139
139
|
return panelId;
|
|
@@ -1659,7 +1659,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1659
1659
|
}, []);
|
|
1660
1660
|
|
|
1661
1661
|
// External APIs are safe to memoize via committed values ref
|
|
1662
|
-
const expandPanel = useCallback(panelData => {
|
|
1662
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1663
1663
|
const {
|
|
1664
1664
|
onLayout
|
|
1665
1665
|
} = committedValuesRef.current;
|
|
@@ -1672,9 +1672,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1672
1672
|
const {
|
|
1673
1673
|
collapsedSize = 0,
|
|
1674
1674
|
panelSize = 0,
|
|
1675
|
-
minSize = 0,
|
|
1675
|
+
minSize: minSizeFromProps = 0,
|
|
1676
1676
|
pivotIndices
|
|
1677
1677
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1678
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1678
1679
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1679
1680
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1680
1681
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
@@ -108,8 +108,8 @@ function PanelWithForwardedRef({
|
|
|
108
108
|
collapse: () => {
|
|
109
109
|
collapsePanel(panelDataRef.current);
|
|
110
110
|
},
|
|
111
|
-
expand:
|
|
112
|
-
expandPanel(panelDataRef.current);
|
|
111
|
+
expand: minSize => {
|
|
112
|
+
expandPanel(panelDataRef.current, minSize);
|
|
113
113
|
},
|
|
114
114
|
getId() {
|
|
115
115
|
return panelId;
|
|
@@ -1635,7 +1635,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1635
1635
|
}, []);
|
|
1636
1636
|
|
|
1637
1637
|
// External APIs are safe to memoize via committed values ref
|
|
1638
|
-
const expandPanel = useCallback(panelData => {
|
|
1638
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1639
1639
|
const {
|
|
1640
1640
|
onLayout
|
|
1641
1641
|
} = committedValuesRef.current;
|
|
@@ -1648,9 +1648,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1648
1648
|
const {
|
|
1649
1649
|
collapsedSize = 0,
|
|
1650
1650
|
panelSize = 0,
|
|
1651
|
-
minSize = 0,
|
|
1651
|
+
minSize: minSizeFromProps = 0,
|
|
1652
1652
|
pivotIndices
|
|
1653
1653
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1654
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1654
1655
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1655
1656
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1656
1657
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
@@ -135,8 +135,8 @@ function PanelWithForwardedRef({
|
|
|
135
135
|
collapse: () => {
|
|
136
136
|
collapsePanel(panelDataRef.current);
|
|
137
137
|
},
|
|
138
|
-
expand:
|
|
139
|
-
expandPanel(panelDataRef.current);
|
|
138
|
+
expand: minSize => {
|
|
139
|
+
expandPanel(panelDataRef.current, minSize);
|
|
140
140
|
},
|
|
141
141
|
getId() {
|
|
142
142
|
return panelId;
|
|
@@ -1700,7 +1700,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1700
1700
|
}, []);
|
|
1701
1701
|
|
|
1702
1702
|
// External APIs are safe to memoize via committed values ref
|
|
1703
|
-
const expandPanel = useCallback(panelData => {
|
|
1703
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1704
1704
|
const {
|
|
1705
1705
|
onLayout
|
|
1706
1706
|
} = committedValuesRef.current;
|
|
@@ -1713,9 +1713,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1713
1713
|
const {
|
|
1714
1714
|
collapsedSize = 0,
|
|
1715
1715
|
panelSize = 0,
|
|
1716
|
-
minSize = 0,
|
|
1716
|
+
minSize: minSizeFromProps = 0,
|
|
1717
1717
|
pivotIndices
|
|
1718
1718
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1719
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1719
1720
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1720
1721
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1721
1722
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
@@ -121,8 +121,8 @@ function PanelWithForwardedRef({
|
|
|
121
121
|
collapse: () => {
|
|
122
122
|
collapsePanel(panelDataRef.current);
|
|
123
123
|
},
|
|
124
|
-
expand:
|
|
125
|
-
expandPanel(panelDataRef.current);
|
|
124
|
+
expand: minSize => {
|
|
125
|
+
expandPanel(panelDataRef.current, minSize);
|
|
126
126
|
},
|
|
127
127
|
getId() {
|
|
128
128
|
return panelId;
|
|
@@ -1558,7 +1558,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1558
1558
|
}, []);
|
|
1559
1559
|
|
|
1560
1560
|
// External APIs are safe to memoize via committed values ref
|
|
1561
|
-
const expandPanel = useCallback(panelData => {
|
|
1561
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1562
1562
|
const {
|
|
1563
1563
|
onLayout
|
|
1564
1564
|
} = committedValuesRef.current;
|
|
@@ -1571,9 +1571,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1571
1571
|
const {
|
|
1572
1572
|
collapsedSize = 0,
|
|
1573
1573
|
panelSize = 0,
|
|
1574
|
-
minSize = 0,
|
|
1574
|
+
minSize: minSizeFromProps = 0,
|
|
1575
1575
|
pivotIndices
|
|
1576
1576
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1577
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1577
1578
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1578
1579
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1579
1580
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
@@ -97,8 +97,8 @@ function PanelWithForwardedRef({
|
|
|
97
97
|
collapse: () => {
|
|
98
98
|
collapsePanel(panelDataRef.current);
|
|
99
99
|
},
|
|
100
|
-
expand:
|
|
101
|
-
expandPanel(panelDataRef.current);
|
|
100
|
+
expand: minSize => {
|
|
101
|
+
expandPanel(panelDataRef.current, minSize);
|
|
102
102
|
},
|
|
103
103
|
getId() {
|
|
104
104
|
return panelId;
|
|
@@ -1534,7 +1534,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1534
1534
|
}, []);
|
|
1535
1535
|
|
|
1536
1536
|
// External APIs are safe to memoize via committed values ref
|
|
1537
|
-
const expandPanel = useCallback(panelData => {
|
|
1537
|
+
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1538
1538
|
const {
|
|
1539
1539
|
onLayout
|
|
1540
1540
|
} = committedValuesRef.current;
|
|
@@ -1547,9 +1547,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1547
1547
|
const {
|
|
1548
1548
|
collapsedSize = 0,
|
|
1549
1549
|
panelSize = 0,
|
|
1550
|
-
minSize = 0,
|
|
1550
|
+
minSize: minSizeFromProps = 0,
|
|
1551
1551
|
pivotIndices
|
|
1552
1552
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1553
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== void 0 ? minSizeOverride : minSizeFromProps;
|
|
1553
1554
|
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
1554
1555
|
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
1555
1556
|
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
package/package.json
CHANGED
package/src/Panel.test.tsx
CHANGED
|
@@ -193,6 +193,111 @@ describe("PanelGroup", () => {
|
|
|
193
193
|
expect(leftPanelRef.current?.isCollapsed()).toBe(false);
|
|
194
194
|
expect(leftPanelRef.current?.isExpanded()).toBe(true);
|
|
195
195
|
});
|
|
196
|
+
|
|
197
|
+
describe("when a panel is mounted in a collapsed state", () => {
|
|
198
|
+
beforeEach(() => {
|
|
199
|
+
act(() => {
|
|
200
|
+
root.unmount();
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("should expand to the panel's minSize", () => {
|
|
205
|
+
const panelRef = createRef<ImperativePanelHandle>();
|
|
206
|
+
|
|
207
|
+
root = createRoot(container);
|
|
208
|
+
|
|
209
|
+
function renderPanelGroup() {
|
|
210
|
+
act(() => {
|
|
211
|
+
root.render(
|
|
212
|
+
<PanelGroup direction="horizontal">
|
|
213
|
+
<Panel
|
|
214
|
+
collapsible
|
|
215
|
+
defaultSize={0}
|
|
216
|
+
minSize={5}
|
|
217
|
+
ref={panelRef}
|
|
218
|
+
/>
|
|
219
|
+
<PanelResizeHandle />
|
|
220
|
+
<Panel />
|
|
221
|
+
</PanelGroup>
|
|
222
|
+
);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Re-render and confirmed collapsed by default
|
|
227
|
+
renderPanelGroup();
|
|
228
|
+
act(() => {
|
|
229
|
+
panelRef.current?.collapse();
|
|
230
|
+
});
|
|
231
|
+
expect(panelRef.current?.getSize()).toEqual(0);
|
|
232
|
+
|
|
233
|
+
// Toggling a panel should expand to the minSize (since there's no previous size to restore to)
|
|
234
|
+
act(() => {
|
|
235
|
+
panelRef.current?.expand();
|
|
236
|
+
});
|
|
237
|
+
expect(panelRef.current?.getSize()).toEqual(5);
|
|
238
|
+
|
|
239
|
+
// Collapse again
|
|
240
|
+
act(() => {
|
|
241
|
+
panelRef.current?.collapse();
|
|
242
|
+
});
|
|
243
|
+
expect(panelRef.current?.getSize()).toEqual(0);
|
|
244
|
+
|
|
245
|
+
// Toggling the panel should expand to the minSize override if one is specified
|
|
246
|
+
// Note this only works because the previous non-collapsed size is less than the minSize override
|
|
247
|
+
act(() => {
|
|
248
|
+
panelRef.current?.expand(15);
|
|
249
|
+
});
|
|
250
|
+
expect(panelRef.current?.getSize()).toEqual(15);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it("should support the (optional) default size", () => {
|
|
254
|
+
const panelRef = createRef<ImperativePanelHandle>();
|
|
255
|
+
|
|
256
|
+
root = createRoot(container);
|
|
257
|
+
|
|
258
|
+
function renderPanelGroup() {
|
|
259
|
+
act(() => {
|
|
260
|
+
root.render(
|
|
261
|
+
<PanelGroup autoSaveId="test" direction="horizontal">
|
|
262
|
+
<Panel
|
|
263
|
+
collapsible
|
|
264
|
+
defaultSize={0}
|
|
265
|
+
minSize={0}
|
|
266
|
+
ref={panelRef}
|
|
267
|
+
/>
|
|
268
|
+
<PanelResizeHandle />
|
|
269
|
+
<Panel />
|
|
270
|
+
</PanelGroup>
|
|
271
|
+
);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Re-render and confirmed collapsed by default
|
|
276
|
+
renderPanelGroup();
|
|
277
|
+
act(() => {
|
|
278
|
+
panelRef.current?.collapse();
|
|
279
|
+
});
|
|
280
|
+
expect(panelRef.current?.getSize()).toEqual(0);
|
|
281
|
+
|
|
282
|
+
// In this case, toggling the panel to expanded will not change its size
|
|
283
|
+
act(() => {
|
|
284
|
+
panelRef.current?.expand();
|
|
285
|
+
});
|
|
286
|
+
expect(panelRef.current?.getSize()).toEqual(0);
|
|
287
|
+
|
|
288
|
+
// But we can override the toggle behavior by passing an explicit min size
|
|
289
|
+
act(() => {
|
|
290
|
+
panelRef.current?.expand(10);
|
|
291
|
+
});
|
|
292
|
+
expect(panelRef.current?.getSize()).toEqual(10);
|
|
293
|
+
|
|
294
|
+
// Toggling an already-expanded panel should not do anything even if we pass a default size
|
|
295
|
+
act(() => {
|
|
296
|
+
panelRef.current?.expand(15);
|
|
297
|
+
});
|
|
298
|
+
expect(panelRef.current?.getSize()).toEqual(10);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
196
301
|
});
|
|
197
302
|
|
|
198
303
|
describe("resize", () => {
|
package/src/Panel.ts
CHANGED
|
@@ -46,7 +46,7 @@ export type PanelData = {
|
|
|
46
46
|
|
|
47
47
|
export type ImperativePanelHandle = {
|
|
48
48
|
collapse: () => void;
|
|
49
|
-
expand: () => void;
|
|
49
|
+
expand: (minSize?: number) => void;
|
|
50
50
|
getId(): string;
|
|
51
51
|
getSize(): number;
|
|
52
52
|
isCollapsed: () => boolean;
|
|
@@ -200,8 +200,8 @@ export function PanelWithForwardedRef({
|
|
|
200
200
|
collapse: () => {
|
|
201
201
|
collapsePanel(panelDataRef.current);
|
|
202
202
|
},
|
|
203
|
-
expand: () => {
|
|
204
|
-
expandPanel(panelDataRef.current);
|
|
203
|
+
expand: (minSize?: number) => {
|
|
204
|
+
expandPanel(panelDataRef.current, minSize);
|
|
205
205
|
},
|
|
206
206
|
getId() {
|
|
207
207
|
return panelId;
|
package/src/PanelGroup.ts
CHANGED
|
@@ -386,65 +386,72 @@ function PanelGroupWithForwardedRef({
|
|
|
386
386
|
}, []);
|
|
387
387
|
|
|
388
388
|
// External APIs are safe to memoize via committed values ref
|
|
389
|
-
const expandPanel = useCallback(
|
|
390
|
-
|
|
391
|
-
|
|
389
|
+
const expandPanel = useCallback(
|
|
390
|
+
(panelData: PanelData, minSizeOverride?: number) => {
|
|
391
|
+
const { onLayout } = committedValuesRef.current;
|
|
392
|
+
const { layout: prevLayout, panelDataArray } = eagerValuesRef.current;
|
|
392
393
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
if (panelData.constraints.collapsible) {
|
|
395
|
+
const panelConstraintsArray = panelDataArray.map(
|
|
396
|
+
(panelData) => panelData.constraints
|
|
397
|
+
);
|
|
397
398
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
399
|
+
const {
|
|
400
|
+
collapsedSize = 0,
|
|
401
|
+
panelSize = 0,
|
|
402
|
+
minSize: minSizeFromProps = 0,
|
|
403
|
+
pivotIndices,
|
|
404
|
+
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
404
405
|
|
|
405
|
-
|
|
406
|
-
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
407
|
-
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(
|
|
408
|
-
panelData.id
|
|
409
|
-
);
|
|
406
|
+
const minSize = minSizeOverride ?? minSizeFromProps;
|
|
410
407
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
408
|
+
if (fuzzyNumbersEqual(panelSize, collapsedSize)) {
|
|
409
|
+
// Restore this panel to the size it was before it was collapsed, if possible.
|
|
410
|
+
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(
|
|
411
|
+
panelData.id
|
|
412
|
+
);
|
|
415
413
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
414
|
+
const baseSize =
|
|
415
|
+
prevPanelSize != null && prevPanelSize >= minSize
|
|
416
|
+
? prevPanelSize
|
|
417
|
+
: minSize;
|
|
418
|
+
|
|
419
|
+
const isLastPanel =
|
|
420
|
+
findPanelDataIndex(panelDataArray, panelData) ===
|
|
421
|
+
panelDataArray.length - 1;
|
|
422
|
+
const delta = isLastPanel
|
|
423
|
+
? panelSize - baseSize
|
|
424
|
+
: baseSize - panelSize;
|
|
425
|
+
|
|
426
|
+
const nextLayout = adjustLayoutByDelta({
|
|
427
|
+
delta,
|
|
428
|
+
initialLayout: prevLayout,
|
|
429
|
+
panelConstraints: panelConstraintsArray,
|
|
430
|
+
pivotIndices,
|
|
431
|
+
prevLayout,
|
|
432
|
+
trigger: "imperative-api",
|
|
433
|
+
});
|
|
420
434
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
initialLayout: prevLayout,
|
|
424
|
-
panelConstraints: panelConstraintsArray,
|
|
425
|
-
pivotIndices,
|
|
426
|
-
prevLayout,
|
|
427
|
-
trigger: "imperative-api",
|
|
428
|
-
});
|
|
435
|
+
if (!compareLayouts(prevLayout, nextLayout)) {
|
|
436
|
+
setLayout(nextLayout);
|
|
429
437
|
|
|
430
|
-
|
|
431
|
-
setLayout(nextLayout);
|
|
438
|
+
eagerValuesRef.current.layout = nextLayout;
|
|
432
439
|
|
|
433
|
-
|
|
440
|
+
if (onLayout) {
|
|
441
|
+
onLayout(nextLayout);
|
|
442
|
+
}
|
|
434
443
|
|
|
435
|
-
|
|
436
|
-
|
|
444
|
+
callPanelCallbacks(
|
|
445
|
+
panelDataArray,
|
|
446
|
+
nextLayout,
|
|
447
|
+
panelIdToLastNotifiedSizeMapRef.current
|
|
448
|
+
);
|
|
437
449
|
}
|
|
438
|
-
|
|
439
|
-
callPanelCallbacks(
|
|
440
|
-
panelDataArray,
|
|
441
|
-
nextLayout,
|
|
442
|
-
panelIdToLastNotifiedSizeMapRef.current
|
|
443
|
-
);
|
|
444
450
|
}
|
|
445
451
|
}
|
|
446
|
-
}
|
|
447
|
-
|
|
452
|
+
},
|
|
453
|
+
[]
|
|
454
|
+
);
|
|
448
455
|
|
|
449
456
|
// External APIs are safe to memoize via committed values ref
|
|
450
457
|
const getPanelSize = useCallback((panelData: PanelData) => {
|
package/src/PanelGroupContext.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type TPanelGroupContext = {
|
|
|
16
16
|
collapsePanel: (panelData: PanelData) => void;
|
|
17
17
|
direction: "horizontal" | "vertical";
|
|
18
18
|
dragState: DragState | null;
|
|
19
|
-
expandPanel: (panelData: PanelData) => void;
|
|
19
|
+
expandPanel: (panelData: PanelData, minSizeOverride?: number) => void;
|
|
20
20
|
getPanelSize: (panelData: PanelData) => number;
|
|
21
21
|
getPanelStyle: (
|
|
22
22
|
panelData: PanelData,
|