react-resizable-panels 2.1.7 → 2.1.8
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/README.md +4 -0
- package/dist/declarations/src/Panel.d.ts +1 -1
- package/dist/declarations/src/PanelGroup.d.ts +1 -1
- package/dist/declarations/src/PanelResizeHandle.d.ts +6 -3
- package/dist/react-resizable-panels.browser.cjs.js +83 -87
- package/dist/react-resizable-panels.browser.development.cjs.js +83 -87
- package/dist/react-resizable-panels.browser.development.esm.js +31 -34
- package/dist/react-resizable-panels.browser.esm.js +31 -34
- package/dist/react-resizable-panels.cjs.js +83 -87
- package/dist/react-resizable-panels.development.cjs.js +83 -87
- package/dist/react-resizable-panels.development.esm.js +31 -34
- package/dist/react-resizable-panels.development.node.cjs.js +82 -85
- package/dist/react-resizable-panels.development.node.esm.js +30 -32
- package/dist/react-resizable-panels.esm.js +31 -34
- package/dist/react-resizable-panels.node.cjs.js +82 -85
- package/dist/react-resizable-panels.node.esm.js +30 -32
- package/package.json +1 -2
- package/dist/declarations/src/vendor/react.d.ts +0 -7
|
@@ -24,38 +24,17 @@ function _interopNamespace(e) {
|
|
|
24
24
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
26
|
|
|
27
|
-
// This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
|
|
28
|
-
|
|
29
|
-
// eslint-disable-next-line no-restricted-imports
|
|
30
|
-
|
|
31
|
-
const {
|
|
32
|
-
createElement,
|
|
33
|
-
createContext,
|
|
34
|
-
createRef,
|
|
35
|
-
forwardRef,
|
|
36
|
-
useCallback,
|
|
37
|
-
useContext,
|
|
38
|
-
useEffect,
|
|
39
|
-
useImperativeHandle,
|
|
40
|
-
useLayoutEffect,
|
|
41
|
-
useMemo,
|
|
42
|
-
useRef,
|
|
43
|
-
useState
|
|
44
|
-
} = React__namespace;
|
|
45
|
-
|
|
46
|
-
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
47
|
-
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
48
|
-
|
|
49
27
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
50
28
|
|
|
51
|
-
const PanelGroupContext = createContext(null);
|
|
29
|
+
const PanelGroupContext = React.createContext(null);
|
|
52
30
|
PanelGroupContext.displayName = "PanelGroupContext";
|
|
53
31
|
|
|
32
|
+
const useId = React__namespace["useId".toString()];
|
|
54
33
|
const wrappedUseId = typeof useId === "function" ? useId : () => null;
|
|
55
34
|
let counter = 0;
|
|
56
35
|
function useUniqueId(idFromParams = null) {
|
|
57
36
|
const idFromUseId = wrappedUseId();
|
|
58
|
-
const idRef = useRef(idFromParams || idFromUseId || null);
|
|
37
|
+
const idRef = React.useRef(idFromParams || idFromUseId || null);
|
|
59
38
|
if (idRef.current === null) {
|
|
60
39
|
idRef.current = "" + counter++;
|
|
61
40
|
}
|
|
@@ -80,7 +59,7 @@ function PanelWithForwardedRef({
|
|
|
80
59
|
tagName: Type = "div",
|
|
81
60
|
...rest
|
|
82
61
|
}) {
|
|
83
|
-
const context = useContext(PanelGroupContext);
|
|
62
|
+
const context = React.useContext(PanelGroupContext);
|
|
84
63
|
if (context === null) {
|
|
85
64
|
throw Error(`Panel components must be rendered within a PanelGroup container`);
|
|
86
65
|
}
|
|
@@ -97,7 +76,7 @@ function PanelWithForwardedRef({
|
|
|
97
76
|
unregisterPanel
|
|
98
77
|
} = context;
|
|
99
78
|
const panelId = useUniqueId(idFromProps);
|
|
100
|
-
const panelDataRef = useRef({
|
|
79
|
+
const panelDataRef = React.useRef({
|
|
101
80
|
callbacks: {
|
|
102
81
|
onCollapse,
|
|
103
82
|
onExpand,
|
|
@@ -114,7 +93,7 @@ function PanelWithForwardedRef({
|
|
|
114
93
|
idIsFromProps: idFromProps !== undefined,
|
|
115
94
|
order
|
|
116
95
|
});
|
|
117
|
-
const devWarningsRef = useRef({
|
|
96
|
+
const devWarningsRef = React.useRef({
|
|
118
97
|
didLogMissingDefaultSizeWarning: false
|
|
119
98
|
});
|
|
120
99
|
|
|
@@ -128,7 +107,7 @@ function PanelWithForwardedRef({
|
|
|
128
107
|
}
|
|
129
108
|
}
|
|
130
109
|
}
|
|
131
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
110
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
132
111
|
collapse: () => {
|
|
133
112
|
collapsePanel(panelDataRef.current);
|
|
134
113
|
},
|
|
@@ -152,11 +131,11 @@ function PanelWithForwardedRef({
|
|
|
152
131
|
}
|
|
153
132
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
154
133
|
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
155
|
-
return createElement(Type, {
|
|
134
|
+
return React.createElement(Type, {
|
|
156
135
|
...rest,
|
|
157
136
|
children,
|
|
158
137
|
className: classNameFromProps,
|
|
159
|
-
id:
|
|
138
|
+
id: panelId,
|
|
160
139
|
style: {
|
|
161
140
|
...style,
|
|
162
141
|
...styleFromProps
|
|
@@ -169,7 +148,7 @@ function PanelWithForwardedRef({
|
|
|
169
148
|
"data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
|
|
170
149
|
});
|
|
171
150
|
}
|
|
172
|
-
const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
151
|
+
const Panel = React.forwardRef((props, ref) => React.createElement(PanelWithForwardedRef, {
|
|
173
152
|
...props,
|
|
174
153
|
forwardedRef: ref
|
|
175
154
|
}));
|
|
@@ -641,7 +620,9 @@ function updateListeners() {
|
|
|
641
620
|
body
|
|
642
621
|
} = ownerDocument;
|
|
643
622
|
body.removeEventListener("contextmenu", handlePointerUp);
|
|
644
|
-
body.removeEventListener("pointerdown", handlePointerDown
|
|
623
|
+
body.removeEventListener("pointerdown", handlePointerDown, {
|
|
624
|
+
capture: true
|
|
625
|
+
});
|
|
645
626
|
body.removeEventListener("pointerleave", handlePointerMove);
|
|
646
627
|
body.removeEventListener("pointermove", handlePointerMove);
|
|
647
628
|
});
|
|
@@ -689,8 +670,8 @@ function updateResizeHandlerStates(action, event) {
|
|
|
689
670
|
}
|
|
690
671
|
|
|
691
672
|
function useForceUpdate() {
|
|
692
|
-
const [_, setCount] = useState(0);
|
|
693
|
-
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
673
|
+
const [_, setCount] = React.useState(0);
|
|
674
|
+
return React.useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
694
675
|
}
|
|
695
676
|
|
|
696
677
|
function assert(expectedCondition, message) {
|
|
@@ -1064,10 +1045,10 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1064
1045
|
panelGroupElement,
|
|
1065
1046
|
setLayout
|
|
1066
1047
|
}) {
|
|
1067
|
-
useRef({
|
|
1048
|
+
React.useRef({
|
|
1068
1049
|
didWarnAboutMissingResizeHandle: false
|
|
1069
1050
|
});
|
|
1070
|
-
useEffect(() => {
|
|
1051
|
+
React.useEffect(() => {
|
|
1071
1052
|
if (!panelGroupElement) {
|
|
1072
1053
|
return;
|
|
1073
1054
|
}
|
|
@@ -1527,14 +1508,14 @@ function PanelGroupWithForwardedRef({
|
|
|
1527
1508
|
...rest
|
|
1528
1509
|
}) {
|
|
1529
1510
|
const groupId = useUniqueId(idFromProps);
|
|
1530
|
-
const panelGroupElementRef = useRef(null);
|
|
1531
|
-
const [dragState, setDragState] = useState(null);
|
|
1532
|
-
const [layout, setLayout] = useState([]);
|
|
1511
|
+
const panelGroupElementRef = React.useRef(null);
|
|
1512
|
+
const [dragState, setDragState] = React.useState(null);
|
|
1513
|
+
const [layout, setLayout] = React.useState([]);
|
|
1533
1514
|
const forceUpdate = useForceUpdate();
|
|
1534
|
-
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1535
|
-
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1536
|
-
const prevDeltaRef = useRef(0);
|
|
1537
|
-
const committedValuesRef = useRef({
|
|
1515
|
+
const panelIdToLastNotifiedSizeMapRef = React.useRef({});
|
|
1516
|
+
const panelSizeBeforeCollapseRef = React.useRef(new Map());
|
|
1517
|
+
const prevDeltaRef = React.useRef(0);
|
|
1518
|
+
const committedValuesRef = React.useRef({
|
|
1538
1519
|
autoSaveId,
|
|
1539
1520
|
direction,
|
|
1540
1521
|
dragState,
|
|
@@ -1543,17 +1524,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1543
1524
|
onLayout,
|
|
1544
1525
|
storage
|
|
1545
1526
|
});
|
|
1546
|
-
const eagerValuesRef = useRef({
|
|
1527
|
+
const eagerValuesRef = React.useRef({
|
|
1547
1528
|
layout,
|
|
1548
1529
|
panelDataArray: [],
|
|
1549
1530
|
panelDataArrayChanged: false
|
|
1550
1531
|
});
|
|
1551
|
-
const devWarningsRef = useRef({
|
|
1532
|
+
const devWarningsRef = React.useRef({
|
|
1552
1533
|
didLogIdAndOrderWarning: false,
|
|
1553
1534
|
didLogPanelConstraintsWarning: false,
|
|
1554
1535
|
prevPanelIds: []
|
|
1555
1536
|
});
|
|
1556
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
1537
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
1557
1538
|
getId: () => committedValuesRef.current.id,
|
|
1558
1539
|
getLayout: () => {
|
|
1559
1540
|
const {
|
|
@@ -1592,7 +1573,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1592
1573
|
setLayout,
|
|
1593
1574
|
panelGroupElement: panelGroupElementRef.current
|
|
1594
1575
|
});
|
|
1595
|
-
useEffect(() => {
|
|
1576
|
+
React.useEffect(() => {
|
|
1596
1577
|
const {
|
|
1597
1578
|
panelDataArray
|
|
1598
1579
|
} = eagerValuesRef.current;
|
|
@@ -1619,7 +1600,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1619
1600
|
}, [autoSaveId, layout, storage]);
|
|
1620
1601
|
|
|
1621
1602
|
// DEV warnings
|
|
1622
|
-
useEffect(() => {
|
|
1603
|
+
React.useEffect(() => {
|
|
1623
1604
|
{
|
|
1624
1605
|
const {
|
|
1625
1606
|
panelDataArray
|
|
@@ -1665,7 +1646,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1665
1646
|
});
|
|
1666
1647
|
|
|
1667
1648
|
// External APIs are safe to memoize via committed values ref
|
|
1668
|
-
const collapsePanel = useCallback(panelData => {
|
|
1649
|
+
const collapsePanel = React.useCallback(panelData => {
|
|
1669
1650
|
const {
|
|
1670
1651
|
onLayout
|
|
1671
1652
|
} = committedValuesRef.current;
|
|
@@ -1708,7 +1689,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1708
1689
|
}, []);
|
|
1709
1690
|
|
|
1710
1691
|
// External APIs are safe to memoize via committed values ref
|
|
1711
|
-
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1692
|
+
const expandPanel = React.useCallback((panelData, minSizeOverride) => {
|
|
1712
1693
|
const {
|
|
1713
1694
|
onLayout
|
|
1714
1695
|
} = committedValuesRef.current;
|
|
@@ -1752,7 +1733,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1752
1733
|
}, []);
|
|
1753
1734
|
|
|
1754
1735
|
// External APIs are safe to memoize via committed values ref
|
|
1755
|
-
const getPanelSize = useCallback(panelData => {
|
|
1736
|
+
const getPanelSize = React.useCallback(panelData => {
|
|
1756
1737
|
const {
|
|
1757
1738
|
layout,
|
|
1758
1739
|
panelDataArray
|
|
@@ -1765,7 +1746,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1765
1746
|
}, []);
|
|
1766
1747
|
|
|
1767
1748
|
// This API should never read from committedValuesRef
|
|
1768
|
-
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1749
|
+
const getPanelStyle = React.useCallback((panelData, defaultSize) => {
|
|
1769
1750
|
const {
|
|
1770
1751
|
panelDataArray
|
|
1771
1752
|
} = eagerValuesRef.current;
|
|
@@ -1780,7 +1761,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1780
1761
|
}, [dragState, layout]);
|
|
1781
1762
|
|
|
1782
1763
|
// External APIs are safe to memoize via committed values ref
|
|
1783
|
-
const isPanelCollapsed = useCallback(panelData => {
|
|
1764
|
+
const isPanelCollapsed = React.useCallback(panelData => {
|
|
1784
1765
|
const {
|
|
1785
1766
|
layout,
|
|
1786
1767
|
panelDataArray
|
|
@@ -1795,7 +1776,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1795
1776
|
}, []);
|
|
1796
1777
|
|
|
1797
1778
|
// External APIs are safe to memoize via committed values ref
|
|
1798
|
-
const isPanelExpanded = useCallback(panelData => {
|
|
1779
|
+
const isPanelExpanded = React.useCallback(panelData => {
|
|
1799
1780
|
const {
|
|
1800
1781
|
layout,
|
|
1801
1782
|
panelDataArray
|
|
@@ -1808,7 +1789,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1808
1789
|
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1809
1790
|
return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
|
|
1810
1791
|
}, []);
|
|
1811
|
-
const registerPanel = useCallback(panelData => {
|
|
1792
|
+
const registerPanel = React.useCallback(panelData => {
|
|
1812
1793
|
const {
|
|
1813
1794
|
panelDataArray
|
|
1814
1795
|
} = eagerValuesRef.current;
|
|
@@ -1829,7 +1810,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1829
1810
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1830
1811
|
forceUpdate();
|
|
1831
1812
|
}, [forceUpdate]);
|
|
1832
|
-
const registerResizeHandle = useCallback(dragHandleId => {
|
|
1813
|
+
const registerResizeHandle = React.useCallback(dragHandleId => {
|
|
1833
1814
|
let isRTL = false;
|
|
1834
1815
|
const panelGroupElement = panelGroupElementRef.current;
|
|
1835
1816
|
if (panelGroupElement) {
|
|
@@ -1908,7 +1889,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1908
1889
|
}, []);
|
|
1909
1890
|
|
|
1910
1891
|
// External APIs are safe to memoize via committed values ref
|
|
1911
|
-
const resizePanel = useCallback((panelData, unsafePanelSize) => {
|
|
1892
|
+
const resizePanel = React.useCallback((panelData, unsafePanelSize) => {
|
|
1912
1893
|
const {
|
|
1913
1894
|
onLayout
|
|
1914
1895
|
} = committedValuesRef.current;
|
|
@@ -1941,7 +1922,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1941
1922
|
callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
1942
1923
|
}
|
|
1943
1924
|
}, []);
|
|
1944
|
-
const reevaluatePanelConstraints = useCallback((panelData, prevConstraints) => {
|
|
1925
|
+
const reevaluatePanelConstraints = React.useCallback((panelData, prevConstraints) => {
|
|
1945
1926
|
const {
|
|
1946
1927
|
layout,
|
|
1947
1928
|
panelDataArray
|
|
@@ -1975,7 +1956,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1975
1956
|
}, [resizePanel]);
|
|
1976
1957
|
|
|
1977
1958
|
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
1978
|
-
const startDragging = useCallback((dragHandleId, event) => {
|
|
1959
|
+
const startDragging = React.useCallback((dragHandleId, event) => {
|
|
1979
1960
|
const {
|
|
1980
1961
|
direction
|
|
1981
1962
|
} = committedValuesRef.current;
|
|
@@ -1995,10 +1976,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1995
1976
|
initialLayout: layout
|
|
1996
1977
|
});
|
|
1997
1978
|
}, []);
|
|
1998
|
-
const stopDragging = useCallback(() => {
|
|
1979
|
+
const stopDragging = React.useCallback(() => {
|
|
1999
1980
|
setDragState(null);
|
|
2000
1981
|
}, []);
|
|
2001
|
-
const unregisterPanel = useCallback(panelData => {
|
|
1982
|
+
const unregisterPanel = React.useCallback(panelData => {
|
|
2002
1983
|
const {
|
|
2003
1984
|
panelDataArray
|
|
2004
1985
|
} = eagerValuesRef.current;
|
|
@@ -2015,7 +1996,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2015
1996
|
forceUpdate();
|
|
2016
1997
|
}
|
|
2017
1998
|
}, [forceUpdate]);
|
|
2018
|
-
const context = useMemo(() => ({
|
|
1999
|
+
const context = React.useMemo(() => ({
|
|
2019
2000
|
collapsePanel,
|
|
2020
2001
|
direction,
|
|
2021
2002
|
dragState,
|
|
@@ -2041,9 +2022,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2041
2022
|
overflow: "hidden",
|
|
2042
2023
|
width: "100%"
|
|
2043
2024
|
};
|
|
2044
|
-
return createElement(PanelGroupContext.Provider, {
|
|
2025
|
+
return React.createElement(PanelGroupContext.Provider, {
|
|
2045
2026
|
value: context
|
|
2046
|
-
}, createElement(Type, {
|
|
2027
|
+
}, React.createElement(Type, {
|
|
2047
2028
|
...rest,
|
|
2048
2029
|
children,
|
|
2049
2030
|
className: classNameFromProps,
|
|
@@ -2059,7 +2040,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2059
2040
|
"data-panel-group-id": groupId
|
|
2060
2041
|
}));
|
|
2061
2042
|
}
|
|
2062
|
-
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
2043
|
+
const PanelGroup = React.forwardRef((props, ref) => React.createElement(PanelGroupWithForwardedRef, {
|
|
2063
2044
|
...props,
|
|
2064
2045
|
forwardedRef: ref
|
|
2065
2046
|
}));
|
|
@@ -2088,7 +2069,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
2088
2069
|
resizeHandler,
|
|
2089
2070
|
panelGroupElement
|
|
2090
2071
|
}) {
|
|
2091
|
-
useEffect(() => {
|
|
2072
|
+
React.useEffect(() => {
|
|
2092
2073
|
if (disabled || resizeHandler == null || panelGroupElement == null) {
|
|
2093
2074
|
return;
|
|
2094
2075
|
}
|
|
@@ -2141,24 +2122,33 @@ function PanelResizeHandle({
|
|
|
2141
2122
|
hitAreaMargins,
|
|
2142
2123
|
id: idFromProps,
|
|
2143
2124
|
onBlur,
|
|
2125
|
+
onClick,
|
|
2144
2126
|
onDragging,
|
|
2145
2127
|
onFocus,
|
|
2128
|
+
onPointerDown,
|
|
2129
|
+
onPointerUp,
|
|
2146
2130
|
style: styleFromProps = {},
|
|
2147
2131
|
tabIndex = 0,
|
|
2148
2132
|
tagName: Type = "div",
|
|
2149
2133
|
...rest
|
|
2150
2134
|
}) {
|
|
2151
2135
|
var _hitAreaMargins$coars, _hitAreaMargins$fine;
|
|
2152
|
-
const elementRef = useRef(null);
|
|
2136
|
+
const elementRef = React.useRef(null);
|
|
2153
2137
|
|
|
2154
2138
|
// Use a ref to guard against users passing inline props
|
|
2155
|
-
const callbacksRef = useRef({
|
|
2156
|
-
|
|
2139
|
+
const callbacksRef = React.useRef({
|
|
2140
|
+
onClick,
|
|
2141
|
+
onDragging,
|
|
2142
|
+
onPointerDown,
|
|
2143
|
+
onPointerUp
|
|
2157
2144
|
});
|
|
2158
|
-
useEffect(() => {
|
|
2145
|
+
React.useEffect(() => {
|
|
2146
|
+
callbacksRef.current.onClick = onClick;
|
|
2159
2147
|
callbacksRef.current.onDragging = onDragging;
|
|
2148
|
+
callbacksRef.current.onPointerDown = onPointerDown;
|
|
2149
|
+
callbacksRef.current.onPointerUp = onPointerUp;
|
|
2160
2150
|
});
|
|
2161
|
-
const panelGroupContext = useContext(PanelGroupContext);
|
|
2151
|
+
const panelGroupContext = React.useContext(PanelGroupContext);
|
|
2162
2152
|
if (panelGroupContext === null) {
|
|
2163
2153
|
throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
|
|
2164
2154
|
}
|
|
@@ -2171,13 +2161,13 @@ function PanelResizeHandle({
|
|
|
2171
2161
|
panelGroupElement
|
|
2172
2162
|
} = panelGroupContext;
|
|
2173
2163
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
2174
|
-
const [state, setState] = useState("inactive");
|
|
2175
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
2176
|
-
const [resizeHandler, setResizeHandler] = useState(null);
|
|
2177
|
-
const committedValuesRef = useRef({
|
|
2164
|
+
const [state, setState] = React.useState("inactive");
|
|
2165
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
2166
|
+
const [resizeHandler, setResizeHandler] = React.useState(null);
|
|
2167
|
+
const committedValuesRef = React.useRef({
|
|
2178
2168
|
state
|
|
2179
2169
|
});
|
|
2180
|
-
useEffect(() => {
|
|
2170
|
+
React.useEffect(() => {
|
|
2181
2171
|
if (disabled) {
|
|
2182
2172
|
setResizeHandler(null);
|
|
2183
2173
|
} else {
|
|
@@ -2190,26 +2180,28 @@ function PanelResizeHandle({
|
|
|
2190
2180
|
// so that inline object values won't trigger re-renders
|
|
2191
2181
|
const coarseHitAreaMargins = (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15;
|
|
2192
2182
|
const fineHitAreaMargins = (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5;
|
|
2193
|
-
useEffect(() => {
|
|
2183
|
+
React.useEffect(() => {
|
|
2194
2184
|
if (disabled || resizeHandler == null) {
|
|
2195
2185
|
return;
|
|
2196
2186
|
}
|
|
2197
2187
|
const element = elementRef.current;
|
|
2198
2188
|
assert(element, "Element ref not attached");
|
|
2189
|
+
let didMove = false;
|
|
2199
2190
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2200
2191
|
if (isActive) {
|
|
2201
2192
|
switch (action) {
|
|
2202
2193
|
case "down":
|
|
2203
2194
|
{
|
|
2204
2195
|
setState("drag");
|
|
2196
|
+
didMove = false;
|
|
2205
2197
|
assert(event, 'Expected event to be defined for "down" action');
|
|
2206
2198
|
startDragging(resizeHandleId, event);
|
|
2207
2199
|
const {
|
|
2208
|
-
onDragging
|
|
2200
|
+
onDragging,
|
|
2201
|
+
onPointerDown
|
|
2209
2202
|
} = callbacksRef.current;
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
}
|
|
2203
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
|
|
2204
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
|
|
2213
2205
|
break;
|
|
2214
2206
|
}
|
|
2215
2207
|
case "move":
|
|
@@ -2217,6 +2209,7 @@ function PanelResizeHandle({
|
|
|
2217
2209
|
const {
|
|
2218
2210
|
state
|
|
2219
2211
|
} = committedValuesRef.current;
|
|
2212
|
+
didMove = true;
|
|
2220
2213
|
if (state !== "drag") {
|
|
2221
2214
|
setState("hover");
|
|
2222
2215
|
}
|
|
@@ -2229,10 +2222,14 @@ function PanelResizeHandle({
|
|
|
2229
2222
|
setState("hover");
|
|
2230
2223
|
stopDragging();
|
|
2231
2224
|
const {
|
|
2232
|
-
|
|
2225
|
+
onClick,
|
|
2226
|
+
onDragging,
|
|
2227
|
+
onPointerUp
|
|
2233
2228
|
} = callbacksRef.current;
|
|
2234
|
-
|
|
2235
|
-
|
|
2229
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
|
|
2230
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
2231
|
+
if (!didMove) {
|
|
2232
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
2236
2233
|
}
|
|
2237
2234
|
break;
|
|
2238
2235
|
}
|
|
@@ -2256,7 +2253,7 @@ function PanelResizeHandle({
|
|
|
2256
2253
|
touchAction: "none",
|
|
2257
2254
|
userSelect: "none"
|
|
2258
2255
|
};
|
|
2259
|
-
return createElement(Type, {
|
|
2256
|
+
return React.createElement(Type, {
|
|
2260
2257
|
...rest,
|
|
2261
2258
|
children,
|
|
2262
2259
|
className: classNameFromProps,
|
|
@@ -1,32 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
// This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line no-restricted-imports
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
createElement,
|
|
9
|
-
createContext,
|
|
10
|
-
createRef,
|
|
11
|
-
forwardRef,
|
|
12
|
-
useCallback,
|
|
13
|
-
useContext,
|
|
14
|
-
useEffect,
|
|
15
|
-
useImperativeHandle,
|
|
16
|
-
useLayoutEffect,
|
|
17
|
-
useMemo,
|
|
18
|
-
useRef,
|
|
19
|
-
useState
|
|
20
|
-
} = React;
|
|
21
|
-
|
|
22
|
-
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
23
|
-
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
2
|
+
import { createContext, useRef, forwardRef, createElement, useContext, useImperativeHandle, useState, useCallback, useEffect, useMemo } from 'react';
|
|
24
3
|
|
|
25
4
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
26
5
|
|
|
27
6
|
const PanelGroupContext = createContext(null);
|
|
28
7
|
PanelGroupContext.displayName = "PanelGroupContext";
|
|
29
8
|
|
|
9
|
+
const useId = React["useId".toString()];
|
|
30
10
|
const wrappedUseId = typeof useId === "function" ? useId : () => null;
|
|
31
11
|
let counter = 0;
|
|
32
12
|
function useUniqueId(idFromParams = null) {
|
|
@@ -132,7 +112,7 @@ function PanelWithForwardedRef({
|
|
|
132
112
|
...rest,
|
|
133
113
|
children,
|
|
134
114
|
className: classNameFromProps,
|
|
135
|
-
id:
|
|
115
|
+
id: panelId,
|
|
136
116
|
style: {
|
|
137
117
|
...style,
|
|
138
118
|
...styleFromProps
|
|
@@ -617,7 +597,9 @@ function updateListeners() {
|
|
|
617
597
|
body
|
|
618
598
|
} = ownerDocument;
|
|
619
599
|
body.removeEventListener("contextmenu", handlePointerUp);
|
|
620
|
-
body.removeEventListener("pointerdown", handlePointerDown
|
|
600
|
+
body.removeEventListener("pointerdown", handlePointerDown, {
|
|
601
|
+
capture: true
|
|
602
|
+
});
|
|
621
603
|
body.removeEventListener("pointerleave", handlePointerMove);
|
|
622
604
|
body.removeEventListener("pointermove", handlePointerMove);
|
|
623
605
|
});
|
|
@@ -2117,8 +2099,11 @@ function PanelResizeHandle({
|
|
|
2117
2099
|
hitAreaMargins,
|
|
2118
2100
|
id: idFromProps,
|
|
2119
2101
|
onBlur,
|
|
2102
|
+
onClick,
|
|
2120
2103
|
onDragging,
|
|
2121
2104
|
onFocus,
|
|
2105
|
+
onPointerDown,
|
|
2106
|
+
onPointerUp,
|
|
2122
2107
|
style: styleFromProps = {},
|
|
2123
2108
|
tabIndex = 0,
|
|
2124
2109
|
tagName: Type = "div",
|
|
@@ -2129,10 +2114,16 @@ function PanelResizeHandle({
|
|
|
2129
2114
|
|
|
2130
2115
|
// Use a ref to guard against users passing inline props
|
|
2131
2116
|
const callbacksRef = useRef({
|
|
2132
|
-
|
|
2117
|
+
onClick,
|
|
2118
|
+
onDragging,
|
|
2119
|
+
onPointerDown,
|
|
2120
|
+
onPointerUp
|
|
2133
2121
|
});
|
|
2134
2122
|
useEffect(() => {
|
|
2123
|
+
callbacksRef.current.onClick = onClick;
|
|
2135
2124
|
callbacksRef.current.onDragging = onDragging;
|
|
2125
|
+
callbacksRef.current.onPointerDown = onPointerDown;
|
|
2126
|
+
callbacksRef.current.onPointerUp = onPointerUp;
|
|
2136
2127
|
});
|
|
2137
2128
|
const panelGroupContext = useContext(PanelGroupContext);
|
|
2138
2129
|
if (panelGroupContext === null) {
|
|
@@ -2172,20 +2163,22 @@ function PanelResizeHandle({
|
|
|
2172
2163
|
}
|
|
2173
2164
|
const element = elementRef.current;
|
|
2174
2165
|
assert(element, "Element ref not attached");
|
|
2166
|
+
let didMove = false;
|
|
2175
2167
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2176
2168
|
if (isActive) {
|
|
2177
2169
|
switch (action) {
|
|
2178
2170
|
case "down":
|
|
2179
2171
|
{
|
|
2180
2172
|
setState("drag");
|
|
2173
|
+
didMove = false;
|
|
2181
2174
|
assert(event, 'Expected event to be defined for "down" action');
|
|
2182
2175
|
startDragging(resizeHandleId, event);
|
|
2183
2176
|
const {
|
|
2184
|
-
onDragging
|
|
2177
|
+
onDragging,
|
|
2178
|
+
onPointerDown
|
|
2185
2179
|
} = callbacksRef.current;
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
}
|
|
2180
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
|
|
2181
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
|
|
2189
2182
|
break;
|
|
2190
2183
|
}
|
|
2191
2184
|
case "move":
|
|
@@ -2193,6 +2186,7 @@ function PanelResizeHandle({
|
|
|
2193
2186
|
const {
|
|
2194
2187
|
state
|
|
2195
2188
|
} = committedValuesRef.current;
|
|
2189
|
+
didMove = true;
|
|
2196
2190
|
if (state !== "drag") {
|
|
2197
2191
|
setState("hover");
|
|
2198
2192
|
}
|
|
@@ -2205,10 +2199,14 @@ function PanelResizeHandle({
|
|
|
2205
2199
|
setState("hover");
|
|
2206
2200
|
stopDragging();
|
|
2207
2201
|
const {
|
|
2208
|
-
|
|
2202
|
+
onClick,
|
|
2203
|
+
onDragging,
|
|
2204
|
+
onPointerUp
|
|
2209
2205
|
} = callbacksRef.current;
|
|
2210
|
-
|
|
2211
|
-
|
|
2206
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
|
|
2207
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
2208
|
+
if (!didMove) {
|
|
2209
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
2212
2210
|
}
|
|
2213
2211
|
break;
|
|
2214
2212
|
}
|