react-resizable-panels 1.0.5 → 1.0.7
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 +10 -2
- package/README.md +210 -4
- package/dist/declarations/src/Panel.d.ts +7 -7
- package/dist/declarations/src/PanelGroup.d.ts +6 -6
- package/dist/declarations/src/PanelResizeHandle.d.ts +4 -4
- package/dist/declarations/src/index.d.ts +10 -1
- package/dist/declarations/src/utils/dom/calculateAvailablePanelSizeInPixels.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getAvailableGroupSizePixels.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getPanelElement.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getPanelElementsForGroup.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getPanelGroupElement.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getResizeHandleElement.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getResizeHandleElementIndex.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getResizeHandleElementsForGroup.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getResizeHandlePanelIds.d.ts +2 -0
- package/dist/react-resizable-panels.browser.cjs.js +65 -8
- package/dist/react-resizable-panels.browser.cjs.mjs +10 -1
- package/dist/react-resizable-panels.browser.development.cjs.js +65 -8
- package/dist/react-resizable-panels.browser.development.cjs.mjs +10 -1
- package/dist/react-resizable-panels.browser.development.esm.js +57 -9
- package/dist/react-resizable-panels.browser.esm.js +57 -9
- package/dist/react-resizable-panels.cjs.js +65 -8
- package/dist/react-resizable-panels.cjs.mjs +10 -1
- package/dist/react-resizable-panels.development.cjs.js +65 -8
- package/dist/react-resizable-panels.development.cjs.mjs +10 -1
- package/dist/react-resizable-panels.development.esm.js +57 -9
- package/dist/react-resizable-panels.development.node.cjs.js +65 -8
- package/dist/react-resizable-panels.development.node.cjs.mjs +10 -1
- package/dist/react-resizable-panels.development.node.esm.js +57 -9
- package/dist/react-resizable-panels.esm.js +57 -9
- package/dist/react-resizable-panels.node.cjs.js +65 -8
- package/dist/react-resizable-panels.node.cjs.mjs +10 -1
- package/dist/react-resizable-panels.node.esm.js +57 -9
- package/package.json +1 -1
- package/src/Panel.ts +7 -4
- package/src/PanelGroup.ts +7 -4
- package/src/PanelResizeHandle.ts +15 -12
- package/src/hooks/useWindowSplitterBehavior.ts +1 -1
- package/src/index.ts +23 -3
- package/src/utils/dom/getPanelElement.ts +2 -2
- package/src/utils/dom/getPanelElementsForGroup.ts +1 -1
- package/src/utils/dom/getPanelGroupElement.ts +2 -2
- package/src/utils/dom/getResizeHandleElement.ts +2 -2
- package/src/utils/dom/getResizeHandleElementsForGroup.ts +1 -1
|
@@ -1770,7 +1770,7 @@ function PanelResizeHandle({
|
|
|
1770
1770
|
tagName: Type = "div",
|
|
1771
1771
|
...rest
|
|
1772
1772
|
}) {
|
|
1773
|
-
const
|
|
1773
|
+
const elementRef = useRef(null);
|
|
1774
1774
|
|
|
1775
1775
|
// Use a ref to guard against users passing inline props
|
|
1776
1776
|
const callbacksRef = useRef({
|
|
@@ -1798,9 +1798,9 @@ function PanelResizeHandle({
|
|
|
1798
1798
|
const stopDraggingAndBlur = useCallback(() => {
|
|
1799
1799
|
// Clicking on the drag handle shouldn't leave it focused;
|
|
1800
1800
|
// That would cause the PanelGroup to think it was still active.
|
|
1801
|
-
const
|
|
1802
|
-
assert(
|
|
1803
|
-
|
|
1801
|
+
const element = elementRef.current;
|
|
1802
|
+
assert(element);
|
|
1803
|
+
element.blur();
|
|
1804
1804
|
stopDragging();
|
|
1805
1805
|
const {
|
|
1806
1806
|
onDragging
|
|
@@ -1827,9 +1827,9 @@ function PanelResizeHandle({
|
|
|
1827
1827
|
const onMouseLeave = event => {
|
|
1828
1828
|
resizeHandler(event);
|
|
1829
1829
|
};
|
|
1830
|
-
const
|
|
1831
|
-
assert(
|
|
1832
|
-
const targetDocument =
|
|
1830
|
+
const element = elementRef.current;
|
|
1831
|
+
assert(element);
|
|
1832
|
+
const targetDocument = element.ownerDocument;
|
|
1833
1833
|
targetDocument.body.addEventListener("contextmenu", stopDraggingAndBlur);
|
|
1834
1834
|
targetDocument.body.addEventListener("mousemove", onMove);
|
|
1835
1835
|
targetDocument.body.addEventListener("touchmove", onMove);
|
|
@@ -1886,7 +1886,7 @@ function PanelResizeHandle({
|
|
|
1886
1886
|
onDragging(true);
|
|
1887
1887
|
}
|
|
1888
1888
|
},
|
|
1889
|
-
ref:
|
|
1889
|
+
ref: elementRef,
|
|
1890
1890
|
role: "separator",
|
|
1891
1891
|
style: {
|
|
1892
1892
|
...style,
|
|
@@ -1904,4 +1904,52 @@ function PanelResizeHandle({
|
|
|
1904
1904
|
}
|
|
1905
1905
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1906
1906
|
|
|
1907
|
-
|
|
1907
|
+
function calculateAvailablePanelSizeInPixels(groupId) {
|
|
1908
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1909
|
+
if (panelGroupElement == null) {
|
|
1910
|
+
return NaN;
|
|
1911
|
+
}
|
|
1912
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1913
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1914
|
+
if (direction === "horizontal") {
|
|
1915
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1916
|
+
return accumulated + handle.offsetWidth;
|
|
1917
|
+
}, 0);
|
|
1918
|
+
} else {
|
|
1919
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1920
|
+
return accumulated + handle.offsetHeight;
|
|
1921
|
+
}, 0);
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
function getAvailableGroupSizePixels(groupId) {
|
|
1926
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1927
|
+
if (panelGroupElement == null) {
|
|
1928
|
+
return NaN;
|
|
1929
|
+
}
|
|
1930
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1931
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1932
|
+
if (direction === "horizontal") {
|
|
1933
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1934
|
+
return accumulated + handle.offsetWidth;
|
|
1935
|
+
}, 0);
|
|
1936
|
+
} else {
|
|
1937
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1938
|
+
return accumulated + handle.offsetHeight;
|
|
1939
|
+
}, 0);
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
function getPanelElement(id) {
|
|
1944
|
+
const element = document.querySelector(`[data-panel-id="${id}"]`);
|
|
1945
|
+
if (element) {
|
|
1946
|
+
return element;
|
|
1947
|
+
}
|
|
1948
|
+
return null;
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
function getPanelElementsForGroup(groupId) {
|
|
1952
|
+
return Array.from(document.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
export { Panel, PanelGroup, PanelResizeHandle, assert, calculateAvailablePanelSizeInPixels, getAvailableGroupSizePixels, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds };
|
|
@@ -1665,7 +1665,7 @@ function PanelResizeHandle({
|
|
|
1665
1665
|
tagName: Type = "div",
|
|
1666
1666
|
...rest
|
|
1667
1667
|
}) {
|
|
1668
|
-
const
|
|
1668
|
+
const elementRef = useRef(null);
|
|
1669
1669
|
|
|
1670
1670
|
// Use a ref to guard against users passing inline props
|
|
1671
1671
|
const callbacksRef = useRef({
|
|
@@ -1693,9 +1693,9 @@ function PanelResizeHandle({
|
|
|
1693
1693
|
const stopDraggingAndBlur = useCallback(() => {
|
|
1694
1694
|
// Clicking on the drag handle shouldn't leave it focused;
|
|
1695
1695
|
// That would cause the PanelGroup to think it was still active.
|
|
1696
|
-
const
|
|
1697
|
-
assert(
|
|
1698
|
-
|
|
1696
|
+
const element = elementRef.current;
|
|
1697
|
+
assert(element);
|
|
1698
|
+
element.blur();
|
|
1699
1699
|
stopDragging();
|
|
1700
1700
|
const {
|
|
1701
1701
|
onDragging
|
|
@@ -1722,9 +1722,9 @@ function PanelResizeHandle({
|
|
|
1722
1722
|
const onMouseLeave = event => {
|
|
1723
1723
|
resizeHandler(event);
|
|
1724
1724
|
};
|
|
1725
|
-
const
|
|
1726
|
-
assert(
|
|
1727
|
-
const targetDocument =
|
|
1725
|
+
const element = elementRef.current;
|
|
1726
|
+
assert(element);
|
|
1727
|
+
const targetDocument = element.ownerDocument;
|
|
1728
1728
|
targetDocument.body.addEventListener("contextmenu", stopDraggingAndBlur);
|
|
1729
1729
|
targetDocument.body.addEventListener("mousemove", onMove);
|
|
1730
1730
|
targetDocument.body.addEventListener("touchmove", onMove);
|
|
@@ -1781,7 +1781,7 @@ function PanelResizeHandle({
|
|
|
1781
1781
|
onDragging(true);
|
|
1782
1782
|
}
|
|
1783
1783
|
},
|
|
1784
|
-
ref:
|
|
1784
|
+
ref: elementRef,
|
|
1785
1785
|
role: "separator",
|
|
1786
1786
|
style: {
|
|
1787
1787
|
...style,
|
|
@@ -1799,4 +1799,52 @@ function PanelResizeHandle({
|
|
|
1799
1799
|
}
|
|
1800
1800
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1801
1801
|
|
|
1802
|
-
|
|
1802
|
+
function calculateAvailablePanelSizeInPixels(groupId) {
|
|
1803
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1804
|
+
if (panelGroupElement == null) {
|
|
1805
|
+
return NaN;
|
|
1806
|
+
}
|
|
1807
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1808
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1809
|
+
if (direction === "horizontal") {
|
|
1810
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1811
|
+
return accumulated + handle.offsetWidth;
|
|
1812
|
+
}, 0);
|
|
1813
|
+
} else {
|
|
1814
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1815
|
+
return accumulated + handle.offsetHeight;
|
|
1816
|
+
}, 0);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
function getAvailableGroupSizePixels(groupId) {
|
|
1821
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1822
|
+
if (panelGroupElement == null) {
|
|
1823
|
+
return NaN;
|
|
1824
|
+
}
|
|
1825
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1826
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1827
|
+
if (direction === "horizontal") {
|
|
1828
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1829
|
+
return accumulated + handle.offsetWidth;
|
|
1830
|
+
}, 0);
|
|
1831
|
+
} else {
|
|
1832
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1833
|
+
return accumulated + handle.offsetHeight;
|
|
1834
|
+
}, 0);
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
function getPanelElement(id) {
|
|
1839
|
+
const element = document.querySelector(`[data-panel-id="${id}"]`);
|
|
1840
|
+
if (element) {
|
|
1841
|
+
return element;
|
|
1842
|
+
}
|
|
1843
|
+
return null;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
function getPanelElementsForGroup(groupId) {
|
|
1847
|
+
return Array.from(document.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
export { Panel, PanelGroup, PanelResizeHandle, assert, calculateAvailablePanelSizeInPixels, getAvailableGroupSizePixels, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds };
|
|
@@ -1691,7 +1691,7 @@ function PanelResizeHandle({
|
|
|
1691
1691
|
tagName: Type = "div",
|
|
1692
1692
|
...rest
|
|
1693
1693
|
}) {
|
|
1694
|
-
const
|
|
1694
|
+
const elementRef = useRef(null);
|
|
1695
1695
|
|
|
1696
1696
|
// Use a ref to guard against users passing inline props
|
|
1697
1697
|
const callbacksRef = useRef({
|
|
@@ -1719,9 +1719,9 @@ function PanelResizeHandle({
|
|
|
1719
1719
|
const stopDraggingAndBlur = useCallback(() => {
|
|
1720
1720
|
// Clicking on the drag handle shouldn't leave it focused;
|
|
1721
1721
|
// That would cause the PanelGroup to think it was still active.
|
|
1722
|
-
const
|
|
1723
|
-
assert(
|
|
1724
|
-
|
|
1722
|
+
const element = elementRef.current;
|
|
1723
|
+
assert(element);
|
|
1724
|
+
element.blur();
|
|
1725
1725
|
stopDragging();
|
|
1726
1726
|
const {
|
|
1727
1727
|
onDragging
|
|
@@ -1748,9 +1748,9 @@ function PanelResizeHandle({
|
|
|
1748
1748
|
const onMouseLeave = event => {
|
|
1749
1749
|
resizeHandler(event);
|
|
1750
1750
|
};
|
|
1751
|
-
const
|
|
1752
|
-
assert(
|
|
1753
|
-
const targetDocument =
|
|
1751
|
+
const element = elementRef.current;
|
|
1752
|
+
assert(element);
|
|
1753
|
+
const targetDocument = element.ownerDocument;
|
|
1754
1754
|
targetDocument.body.addEventListener("contextmenu", stopDraggingAndBlur);
|
|
1755
1755
|
targetDocument.body.addEventListener("mousemove", onMove);
|
|
1756
1756
|
targetDocument.body.addEventListener("touchmove", onMove);
|
|
@@ -1807,7 +1807,7 @@ function PanelResizeHandle({
|
|
|
1807
1807
|
onDragging(true);
|
|
1808
1808
|
}
|
|
1809
1809
|
},
|
|
1810
|
-
ref:
|
|
1810
|
+
ref: elementRef,
|
|
1811
1811
|
role: "separator",
|
|
1812
1812
|
style: {
|
|
1813
1813
|
...style,
|
|
@@ -1825,7 +1825,64 @@ function PanelResizeHandle({
|
|
|
1825
1825
|
}
|
|
1826
1826
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1827
1827
|
|
|
1828
|
+
function calculateAvailablePanelSizeInPixels(groupId) {
|
|
1829
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1830
|
+
if (panelGroupElement == null) {
|
|
1831
|
+
return NaN;
|
|
1832
|
+
}
|
|
1833
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1834
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1835
|
+
if (direction === "horizontal") {
|
|
1836
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1837
|
+
return accumulated + handle.offsetWidth;
|
|
1838
|
+
}, 0);
|
|
1839
|
+
} else {
|
|
1840
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1841
|
+
return accumulated + handle.offsetHeight;
|
|
1842
|
+
}, 0);
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
function getAvailableGroupSizePixels(groupId) {
|
|
1847
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1848
|
+
if (panelGroupElement == null) {
|
|
1849
|
+
return NaN;
|
|
1850
|
+
}
|
|
1851
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1852
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1853
|
+
if (direction === "horizontal") {
|
|
1854
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1855
|
+
return accumulated + handle.offsetWidth;
|
|
1856
|
+
}, 0);
|
|
1857
|
+
} else {
|
|
1858
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1859
|
+
return accumulated + handle.offsetHeight;
|
|
1860
|
+
}, 0);
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
function getPanelElement(id) {
|
|
1865
|
+
const element = document.querySelector(`[data-panel-id="${id}"]`);
|
|
1866
|
+
if (element) {
|
|
1867
|
+
return element;
|
|
1868
|
+
}
|
|
1869
|
+
return null;
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
function getPanelElementsForGroup(groupId) {
|
|
1873
|
+
return Array.from(document.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1828
1876
|
exports.Panel = Panel;
|
|
1829
1877
|
exports.PanelGroup = PanelGroup;
|
|
1830
1878
|
exports.PanelResizeHandle = PanelResizeHandle;
|
|
1831
1879
|
exports.assert = assert;
|
|
1880
|
+
exports.calculateAvailablePanelSizeInPixels = calculateAvailablePanelSizeInPixels;
|
|
1881
|
+
exports.getAvailableGroupSizePixels = getAvailableGroupSizePixels;
|
|
1882
|
+
exports.getPanelElement = getPanelElement;
|
|
1883
|
+
exports.getPanelElementsForGroup = getPanelElementsForGroup;
|
|
1884
|
+
exports.getPanelGroupElement = getPanelGroupElement;
|
|
1885
|
+
exports.getResizeHandleElement = getResizeHandleElement;
|
|
1886
|
+
exports.getResizeHandleElementIndex = getResizeHandleElementIndex;
|
|
1887
|
+
exports.getResizeHandleElementsForGroup = getResizeHandleElementsForGroup;
|
|
1888
|
+
exports.getResizeHandlePanelIds = getResizeHandlePanelIds;
|
|
@@ -2,5 +2,14 @@ export {
|
|
|
2
2
|
Panel,
|
|
3
3
|
PanelGroup,
|
|
4
4
|
PanelResizeHandle,
|
|
5
|
-
assert
|
|
5
|
+
assert,
|
|
6
|
+
calculateAvailablePanelSizeInPixels,
|
|
7
|
+
getAvailableGroupSizePixels,
|
|
8
|
+
getPanelElement,
|
|
9
|
+
getPanelElementsForGroup,
|
|
10
|
+
getPanelGroupElement,
|
|
11
|
+
getResizeHandleElement,
|
|
12
|
+
getResizeHandleElementIndex,
|
|
13
|
+
getResizeHandleElementsForGroup,
|
|
14
|
+
getResizeHandlePanelIds
|
|
6
15
|
} from "./react-resizable-panels.cjs.js";
|
|
@@ -1801,7 +1801,7 @@ function PanelResizeHandle({
|
|
|
1801
1801
|
tagName: Type = "div",
|
|
1802
1802
|
...rest
|
|
1803
1803
|
}) {
|
|
1804
|
-
const
|
|
1804
|
+
const elementRef = useRef(null);
|
|
1805
1805
|
|
|
1806
1806
|
// Use a ref to guard against users passing inline props
|
|
1807
1807
|
const callbacksRef = useRef({
|
|
@@ -1829,9 +1829,9 @@ function PanelResizeHandle({
|
|
|
1829
1829
|
const stopDraggingAndBlur = useCallback(() => {
|
|
1830
1830
|
// Clicking on the drag handle shouldn't leave it focused;
|
|
1831
1831
|
// That would cause the PanelGroup to think it was still active.
|
|
1832
|
-
const
|
|
1833
|
-
assert(
|
|
1834
|
-
|
|
1832
|
+
const element = elementRef.current;
|
|
1833
|
+
assert(element);
|
|
1834
|
+
element.blur();
|
|
1835
1835
|
stopDragging();
|
|
1836
1836
|
const {
|
|
1837
1837
|
onDragging
|
|
@@ -1858,9 +1858,9 @@ function PanelResizeHandle({
|
|
|
1858
1858
|
const onMouseLeave = event => {
|
|
1859
1859
|
resizeHandler(event);
|
|
1860
1860
|
};
|
|
1861
|
-
const
|
|
1862
|
-
assert(
|
|
1863
|
-
const targetDocument =
|
|
1861
|
+
const element = elementRef.current;
|
|
1862
|
+
assert(element);
|
|
1863
|
+
const targetDocument = element.ownerDocument;
|
|
1864
1864
|
targetDocument.body.addEventListener("contextmenu", stopDraggingAndBlur);
|
|
1865
1865
|
targetDocument.body.addEventListener("mousemove", onMove);
|
|
1866
1866
|
targetDocument.body.addEventListener("touchmove", onMove);
|
|
@@ -1917,7 +1917,7 @@ function PanelResizeHandle({
|
|
|
1917
1917
|
onDragging(true);
|
|
1918
1918
|
}
|
|
1919
1919
|
},
|
|
1920
|
-
ref:
|
|
1920
|
+
ref: elementRef,
|
|
1921
1921
|
role: "separator",
|
|
1922
1922
|
style: {
|
|
1923
1923
|
...style,
|
|
@@ -1935,7 +1935,64 @@ function PanelResizeHandle({
|
|
|
1935
1935
|
}
|
|
1936
1936
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1937
1937
|
|
|
1938
|
+
function calculateAvailablePanelSizeInPixels(groupId) {
|
|
1939
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1940
|
+
if (panelGroupElement == null) {
|
|
1941
|
+
return NaN;
|
|
1942
|
+
}
|
|
1943
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1944
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1945
|
+
if (direction === "horizontal") {
|
|
1946
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1947
|
+
return accumulated + handle.offsetWidth;
|
|
1948
|
+
}, 0);
|
|
1949
|
+
} else {
|
|
1950
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1951
|
+
return accumulated + handle.offsetHeight;
|
|
1952
|
+
}, 0);
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
function getAvailableGroupSizePixels(groupId) {
|
|
1957
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1958
|
+
if (panelGroupElement == null) {
|
|
1959
|
+
return NaN;
|
|
1960
|
+
}
|
|
1961
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1962
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1963
|
+
if (direction === "horizontal") {
|
|
1964
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1965
|
+
return accumulated + handle.offsetWidth;
|
|
1966
|
+
}, 0);
|
|
1967
|
+
} else {
|
|
1968
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1969
|
+
return accumulated + handle.offsetHeight;
|
|
1970
|
+
}, 0);
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
function getPanelElement(id) {
|
|
1975
|
+
const element = document.querySelector(`[data-panel-id="${id}"]`);
|
|
1976
|
+
if (element) {
|
|
1977
|
+
return element;
|
|
1978
|
+
}
|
|
1979
|
+
return null;
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
function getPanelElementsForGroup(groupId) {
|
|
1983
|
+
return Array.from(document.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1938
1986
|
exports.Panel = Panel;
|
|
1939
1987
|
exports.PanelGroup = PanelGroup;
|
|
1940
1988
|
exports.PanelResizeHandle = PanelResizeHandle;
|
|
1941
1989
|
exports.assert = assert;
|
|
1990
|
+
exports.calculateAvailablePanelSizeInPixels = calculateAvailablePanelSizeInPixels;
|
|
1991
|
+
exports.getAvailableGroupSizePixels = getAvailableGroupSizePixels;
|
|
1992
|
+
exports.getPanelElement = getPanelElement;
|
|
1993
|
+
exports.getPanelElementsForGroup = getPanelElementsForGroup;
|
|
1994
|
+
exports.getPanelGroupElement = getPanelGroupElement;
|
|
1995
|
+
exports.getResizeHandleElement = getResizeHandleElement;
|
|
1996
|
+
exports.getResizeHandleElementIndex = getResizeHandleElementIndex;
|
|
1997
|
+
exports.getResizeHandleElementsForGroup = getResizeHandleElementsForGroup;
|
|
1998
|
+
exports.getResizeHandlePanelIds = getResizeHandlePanelIds;
|
|
@@ -2,5 +2,14 @@ export {
|
|
|
2
2
|
Panel,
|
|
3
3
|
PanelGroup,
|
|
4
4
|
PanelResizeHandle,
|
|
5
|
-
assert
|
|
5
|
+
assert,
|
|
6
|
+
calculateAvailablePanelSizeInPixels,
|
|
7
|
+
getAvailableGroupSizePixels,
|
|
8
|
+
getPanelElement,
|
|
9
|
+
getPanelElementsForGroup,
|
|
10
|
+
getPanelGroupElement,
|
|
11
|
+
getResizeHandleElement,
|
|
12
|
+
getResizeHandleElementIndex,
|
|
13
|
+
getResizeHandleElementsForGroup,
|
|
14
|
+
getResizeHandlePanelIds
|
|
6
15
|
} from "./react-resizable-panels.development.cjs.js";
|
|
@@ -1777,7 +1777,7 @@ function PanelResizeHandle({
|
|
|
1777
1777
|
tagName: Type = "div",
|
|
1778
1778
|
...rest
|
|
1779
1779
|
}) {
|
|
1780
|
-
const
|
|
1780
|
+
const elementRef = useRef(null);
|
|
1781
1781
|
|
|
1782
1782
|
// Use a ref to guard against users passing inline props
|
|
1783
1783
|
const callbacksRef = useRef({
|
|
@@ -1805,9 +1805,9 @@ function PanelResizeHandle({
|
|
|
1805
1805
|
const stopDraggingAndBlur = useCallback(() => {
|
|
1806
1806
|
// Clicking on the drag handle shouldn't leave it focused;
|
|
1807
1807
|
// That would cause the PanelGroup to think it was still active.
|
|
1808
|
-
const
|
|
1809
|
-
assert(
|
|
1810
|
-
|
|
1808
|
+
const element = elementRef.current;
|
|
1809
|
+
assert(element);
|
|
1810
|
+
element.blur();
|
|
1811
1811
|
stopDragging();
|
|
1812
1812
|
const {
|
|
1813
1813
|
onDragging
|
|
@@ -1834,9 +1834,9 @@ function PanelResizeHandle({
|
|
|
1834
1834
|
const onMouseLeave = event => {
|
|
1835
1835
|
resizeHandler(event);
|
|
1836
1836
|
};
|
|
1837
|
-
const
|
|
1838
|
-
assert(
|
|
1839
|
-
const targetDocument =
|
|
1837
|
+
const element = elementRef.current;
|
|
1838
|
+
assert(element);
|
|
1839
|
+
const targetDocument = element.ownerDocument;
|
|
1840
1840
|
targetDocument.body.addEventListener("contextmenu", stopDraggingAndBlur);
|
|
1841
1841
|
targetDocument.body.addEventListener("mousemove", onMove);
|
|
1842
1842
|
targetDocument.body.addEventListener("touchmove", onMove);
|
|
@@ -1893,7 +1893,7 @@ function PanelResizeHandle({
|
|
|
1893
1893
|
onDragging(true);
|
|
1894
1894
|
}
|
|
1895
1895
|
},
|
|
1896
|
-
ref:
|
|
1896
|
+
ref: elementRef,
|
|
1897
1897
|
role: "separator",
|
|
1898
1898
|
style: {
|
|
1899
1899
|
...style,
|
|
@@ -1911,4 +1911,52 @@ function PanelResizeHandle({
|
|
|
1911
1911
|
}
|
|
1912
1912
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1913
1913
|
|
|
1914
|
-
|
|
1914
|
+
function calculateAvailablePanelSizeInPixels(groupId) {
|
|
1915
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1916
|
+
if (panelGroupElement == null) {
|
|
1917
|
+
return NaN;
|
|
1918
|
+
}
|
|
1919
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1920
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1921
|
+
if (direction === "horizontal") {
|
|
1922
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1923
|
+
return accumulated + handle.offsetWidth;
|
|
1924
|
+
}, 0);
|
|
1925
|
+
} else {
|
|
1926
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1927
|
+
return accumulated + handle.offsetHeight;
|
|
1928
|
+
}, 0);
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
function getAvailableGroupSizePixels(groupId) {
|
|
1933
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1934
|
+
if (panelGroupElement == null) {
|
|
1935
|
+
return NaN;
|
|
1936
|
+
}
|
|
1937
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1938
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1939
|
+
if (direction === "horizontal") {
|
|
1940
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1941
|
+
return accumulated + handle.offsetWidth;
|
|
1942
|
+
}, 0);
|
|
1943
|
+
} else {
|
|
1944
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1945
|
+
return accumulated + handle.offsetHeight;
|
|
1946
|
+
}, 0);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
function getPanelElement(id) {
|
|
1951
|
+
const element = document.querySelector(`[data-panel-id="${id}"]`);
|
|
1952
|
+
if (element) {
|
|
1953
|
+
return element;
|
|
1954
|
+
}
|
|
1955
|
+
return null;
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
function getPanelElementsForGroup(groupId) {
|
|
1959
|
+
return Array.from(document.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
export { Panel, PanelGroup, PanelResizeHandle, assert, calculateAvailablePanelSizeInPixels, getAvailableGroupSizePixels, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds };
|
|
@@ -1590,7 +1590,7 @@ function PanelResizeHandle({
|
|
|
1590
1590
|
tagName: Type = "div",
|
|
1591
1591
|
...rest
|
|
1592
1592
|
}) {
|
|
1593
|
-
const
|
|
1593
|
+
const elementRef = useRef(null);
|
|
1594
1594
|
|
|
1595
1595
|
// Use a ref to guard against users passing inline props
|
|
1596
1596
|
const callbacksRef = useRef({
|
|
@@ -1618,9 +1618,9 @@ function PanelResizeHandle({
|
|
|
1618
1618
|
const stopDraggingAndBlur = useCallback(() => {
|
|
1619
1619
|
// Clicking on the drag handle shouldn't leave it focused;
|
|
1620
1620
|
// That would cause the PanelGroup to think it was still active.
|
|
1621
|
-
const
|
|
1622
|
-
assert(
|
|
1623
|
-
|
|
1621
|
+
const element = elementRef.current;
|
|
1622
|
+
assert(element);
|
|
1623
|
+
element.blur();
|
|
1624
1624
|
stopDragging();
|
|
1625
1625
|
const {
|
|
1626
1626
|
onDragging
|
|
@@ -1647,9 +1647,9 @@ function PanelResizeHandle({
|
|
|
1647
1647
|
const onMouseLeave = event => {
|
|
1648
1648
|
resizeHandler(event);
|
|
1649
1649
|
};
|
|
1650
|
-
const
|
|
1651
|
-
assert(
|
|
1652
|
-
const targetDocument =
|
|
1650
|
+
const element = elementRef.current;
|
|
1651
|
+
assert(element);
|
|
1652
|
+
const targetDocument = element.ownerDocument;
|
|
1653
1653
|
targetDocument.body.addEventListener("contextmenu", stopDraggingAndBlur);
|
|
1654
1654
|
targetDocument.body.addEventListener("mousemove", onMove);
|
|
1655
1655
|
targetDocument.body.addEventListener("touchmove", onMove);
|
|
@@ -1706,7 +1706,7 @@ function PanelResizeHandle({
|
|
|
1706
1706
|
onDragging(true);
|
|
1707
1707
|
}
|
|
1708
1708
|
},
|
|
1709
|
-
ref:
|
|
1709
|
+
ref: elementRef,
|
|
1710
1710
|
role: "separator",
|
|
1711
1711
|
style: {
|
|
1712
1712
|
...style,
|
|
@@ -1724,7 +1724,64 @@ function PanelResizeHandle({
|
|
|
1724
1724
|
}
|
|
1725
1725
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1726
1726
|
|
|
1727
|
+
function calculateAvailablePanelSizeInPixels(groupId) {
|
|
1728
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1729
|
+
if (panelGroupElement == null) {
|
|
1730
|
+
return NaN;
|
|
1731
|
+
}
|
|
1732
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1733
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1734
|
+
if (direction === "horizontal") {
|
|
1735
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1736
|
+
return accumulated + handle.offsetWidth;
|
|
1737
|
+
}, 0);
|
|
1738
|
+
} else {
|
|
1739
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1740
|
+
return accumulated + handle.offsetHeight;
|
|
1741
|
+
}, 0);
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
function getAvailableGroupSizePixels(groupId) {
|
|
1746
|
+
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1747
|
+
if (panelGroupElement == null) {
|
|
1748
|
+
return NaN;
|
|
1749
|
+
}
|
|
1750
|
+
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1751
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1752
|
+
if (direction === "horizontal") {
|
|
1753
|
+
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1754
|
+
return accumulated + handle.offsetWidth;
|
|
1755
|
+
}, 0);
|
|
1756
|
+
} else {
|
|
1757
|
+
return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
|
|
1758
|
+
return accumulated + handle.offsetHeight;
|
|
1759
|
+
}, 0);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
function getPanelElement(id) {
|
|
1764
|
+
const element = document.querySelector(`[data-panel-id="${id}"]`);
|
|
1765
|
+
if (element) {
|
|
1766
|
+
return element;
|
|
1767
|
+
}
|
|
1768
|
+
return null;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
function getPanelElementsForGroup(groupId) {
|
|
1772
|
+
return Array.from(document.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1727
1775
|
exports.Panel = Panel;
|
|
1728
1776
|
exports.PanelGroup = PanelGroup;
|
|
1729
1777
|
exports.PanelResizeHandle = PanelResizeHandle;
|
|
1730
1778
|
exports.assert = assert;
|
|
1779
|
+
exports.calculateAvailablePanelSizeInPixels = calculateAvailablePanelSizeInPixels;
|
|
1780
|
+
exports.getAvailableGroupSizePixels = getAvailableGroupSizePixels;
|
|
1781
|
+
exports.getPanelElement = getPanelElement;
|
|
1782
|
+
exports.getPanelElementsForGroup = getPanelElementsForGroup;
|
|
1783
|
+
exports.getPanelGroupElement = getPanelGroupElement;
|
|
1784
|
+
exports.getResizeHandleElement = getResizeHandleElement;
|
|
1785
|
+
exports.getResizeHandleElementIndex = getResizeHandleElementIndex;
|
|
1786
|
+
exports.getResizeHandleElementsForGroup = getResizeHandleElementsForGroup;
|
|
1787
|
+
exports.getResizeHandlePanelIds = getResizeHandlePanelIds;
|
|
@@ -2,5 +2,14 @@ export {
|
|
|
2
2
|
Panel,
|
|
3
3
|
PanelGroup,
|
|
4
4
|
PanelResizeHandle,
|
|
5
|
-
assert
|
|
5
|
+
assert,
|
|
6
|
+
calculateAvailablePanelSizeInPixels,
|
|
7
|
+
getAvailableGroupSizePixels,
|
|
8
|
+
getPanelElement,
|
|
9
|
+
getPanelElementsForGroup,
|
|
10
|
+
getPanelGroupElement,
|
|
11
|
+
getResizeHandleElement,
|
|
12
|
+
getResizeHandleElementIndex,
|
|
13
|
+
getResizeHandleElementsForGroup,
|
|
14
|
+
getResizeHandlePanelIds
|
|
6
15
|
} from "./react-resizable-panels.development.node.cjs.js";
|