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
|
@@ -26,41 +26,19 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
26
26
|
|
|
27
27
|
const isBrowser = typeof window !== "undefined";
|
|
28
28
|
|
|
29
|
-
// This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
|
|
30
|
-
|
|
31
|
-
// eslint-disable-next-line no-restricted-imports
|
|
32
|
-
|
|
33
|
-
const {
|
|
34
|
-
createElement,
|
|
35
|
-
createContext,
|
|
36
|
-
createRef,
|
|
37
|
-
forwardRef,
|
|
38
|
-
useCallback,
|
|
39
|
-
useContext,
|
|
40
|
-
useEffect,
|
|
41
|
-
useImperativeHandle,
|
|
42
|
-
useLayoutEffect,
|
|
43
|
-
useMemo,
|
|
44
|
-
useRef,
|
|
45
|
-
useState
|
|
46
|
-
} = React__namespace;
|
|
47
|
-
|
|
48
|
-
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
49
|
-
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
50
|
-
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
51
|
-
|
|
52
29
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
53
30
|
|
|
54
|
-
const PanelGroupContext = createContext(null);
|
|
31
|
+
const PanelGroupContext = React.createContext(null);
|
|
55
32
|
PanelGroupContext.displayName = "PanelGroupContext";
|
|
56
33
|
|
|
57
|
-
const useIsomorphicLayoutEffect = isBrowser ?
|
|
34
|
+
const useIsomorphicLayoutEffect = isBrowser ? React.useLayoutEffect : () => {};
|
|
58
35
|
|
|
36
|
+
const useId = React__namespace["useId".toString()];
|
|
59
37
|
const wrappedUseId = typeof useId === "function" ? useId : () => null;
|
|
60
38
|
let counter = 0;
|
|
61
39
|
function useUniqueId(idFromParams = null) {
|
|
62
40
|
const idFromUseId = wrappedUseId();
|
|
63
|
-
const idRef = useRef(idFromParams || idFromUseId || null);
|
|
41
|
+
const idRef = React.useRef(idFromParams || idFromUseId || null);
|
|
64
42
|
if (idRef.current === null) {
|
|
65
43
|
idRef.current = "" + counter++;
|
|
66
44
|
}
|
|
@@ -85,7 +63,7 @@ function PanelWithForwardedRef({
|
|
|
85
63
|
tagName: Type = "div",
|
|
86
64
|
...rest
|
|
87
65
|
}) {
|
|
88
|
-
const context = useContext(PanelGroupContext);
|
|
66
|
+
const context = React.useContext(PanelGroupContext);
|
|
89
67
|
if (context === null) {
|
|
90
68
|
throw Error(`Panel components must be rendered within a PanelGroup container`);
|
|
91
69
|
}
|
|
@@ -102,7 +80,7 @@ function PanelWithForwardedRef({
|
|
|
102
80
|
unregisterPanel
|
|
103
81
|
} = context;
|
|
104
82
|
const panelId = useUniqueId(idFromProps);
|
|
105
|
-
const panelDataRef = useRef({
|
|
83
|
+
const panelDataRef = React.useRef({
|
|
106
84
|
callbacks: {
|
|
107
85
|
onCollapse,
|
|
108
86
|
onExpand,
|
|
@@ -119,7 +97,7 @@ function PanelWithForwardedRef({
|
|
|
119
97
|
idIsFromProps: idFromProps !== undefined,
|
|
120
98
|
order
|
|
121
99
|
});
|
|
122
|
-
const devWarningsRef = useRef({
|
|
100
|
+
const devWarningsRef = React.useRef({
|
|
123
101
|
didLogMissingDefaultSizeWarning: false
|
|
124
102
|
});
|
|
125
103
|
|
|
@@ -166,7 +144,7 @@ function PanelWithForwardedRef({
|
|
|
166
144
|
unregisterPanel(panelData);
|
|
167
145
|
};
|
|
168
146
|
}, [order, panelId, registerPanel, unregisterPanel]);
|
|
169
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
147
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
170
148
|
collapse: () => {
|
|
171
149
|
collapsePanel(panelDataRef.current);
|
|
172
150
|
},
|
|
@@ -190,11 +168,11 @@ function PanelWithForwardedRef({
|
|
|
190
168
|
}
|
|
191
169
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
192
170
|
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
193
|
-
return createElement(Type, {
|
|
171
|
+
return React.createElement(Type, {
|
|
194
172
|
...rest,
|
|
195
173
|
children,
|
|
196
174
|
className: classNameFromProps,
|
|
197
|
-
id:
|
|
175
|
+
id: panelId,
|
|
198
176
|
style: {
|
|
199
177
|
...style,
|
|
200
178
|
...styleFromProps
|
|
@@ -207,7 +185,7 @@ function PanelWithForwardedRef({
|
|
|
207
185
|
"data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
|
|
208
186
|
});
|
|
209
187
|
}
|
|
210
|
-
const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
188
|
+
const Panel = React.forwardRef((props, ref) => React.createElement(PanelWithForwardedRef, {
|
|
211
189
|
...props,
|
|
212
190
|
forwardedRef: ref
|
|
213
191
|
}));
|
|
@@ -679,7 +657,9 @@ function updateListeners() {
|
|
|
679
657
|
body
|
|
680
658
|
} = ownerDocument;
|
|
681
659
|
body.removeEventListener("contextmenu", handlePointerUp);
|
|
682
|
-
body.removeEventListener("pointerdown", handlePointerDown
|
|
660
|
+
body.removeEventListener("pointerdown", handlePointerDown, {
|
|
661
|
+
capture: true
|
|
662
|
+
});
|
|
683
663
|
body.removeEventListener("pointerleave", handlePointerMove);
|
|
684
664
|
body.removeEventListener("pointermove", handlePointerMove);
|
|
685
665
|
});
|
|
@@ -727,8 +707,8 @@ function updateResizeHandlerStates(action, event) {
|
|
|
727
707
|
}
|
|
728
708
|
|
|
729
709
|
function useForceUpdate() {
|
|
730
|
-
const [_, setCount] = useState(0);
|
|
731
|
-
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
710
|
+
const [_, setCount] = React.useState(0);
|
|
711
|
+
return React.useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
732
712
|
}
|
|
733
713
|
|
|
734
714
|
function assert(expectedCondition, message) {
|
|
@@ -1141,7 +1121,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1141
1121
|
panelGroupElement,
|
|
1142
1122
|
setLayout
|
|
1143
1123
|
}) {
|
|
1144
|
-
const devWarningsRef = useRef({
|
|
1124
|
+
const devWarningsRef = React.useRef({
|
|
1145
1125
|
didWarnAboutMissingResizeHandle: false
|
|
1146
1126
|
});
|
|
1147
1127
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -1188,7 +1168,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1188
1168
|
});
|
|
1189
1169
|
};
|
|
1190
1170
|
}, [groupId, layout, panelDataArray, panelGroupElement]);
|
|
1191
|
-
useEffect(() => {
|
|
1171
|
+
React.useEffect(() => {
|
|
1192
1172
|
if (!panelGroupElement) {
|
|
1193
1173
|
return;
|
|
1194
1174
|
}
|
|
@@ -1695,14 +1675,14 @@ function PanelGroupWithForwardedRef({
|
|
|
1695
1675
|
...rest
|
|
1696
1676
|
}) {
|
|
1697
1677
|
const groupId = useUniqueId(idFromProps);
|
|
1698
|
-
const panelGroupElementRef = useRef(null);
|
|
1699
|
-
const [dragState, setDragState] = useState(null);
|
|
1700
|
-
const [layout, setLayout] = useState([]);
|
|
1678
|
+
const panelGroupElementRef = React.useRef(null);
|
|
1679
|
+
const [dragState, setDragState] = React.useState(null);
|
|
1680
|
+
const [layout, setLayout] = React.useState([]);
|
|
1701
1681
|
const forceUpdate = useForceUpdate();
|
|
1702
|
-
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1703
|
-
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1704
|
-
const prevDeltaRef = useRef(0);
|
|
1705
|
-
const committedValuesRef = useRef({
|
|
1682
|
+
const panelIdToLastNotifiedSizeMapRef = React.useRef({});
|
|
1683
|
+
const panelSizeBeforeCollapseRef = React.useRef(new Map());
|
|
1684
|
+
const prevDeltaRef = React.useRef(0);
|
|
1685
|
+
const committedValuesRef = React.useRef({
|
|
1706
1686
|
autoSaveId,
|
|
1707
1687
|
direction,
|
|
1708
1688
|
dragState,
|
|
@@ -1711,17 +1691,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1711
1691
|
onLayout,
|
|
1712
1692
|
storage
|
|
1713
1693
|
});
|
|
1714
|
-
const eagerValuesRef = useRef({
|
|
1694
|
+
const eagerValuesRef = React.useRef({
|
|
1715
1695
|
layout,
|
|
1716
1696
|
panelDataArray: [],
|
|
1717
1697
|
panelDataArrayChanged: false
|
|
1718
1698
|
});
|
|
1719
|
-
const devWarningsRef = useRef({
|
|
1699
|
+
const devWarningsRef = React.useRef({
|
|
1720
1700
|
didLogIdAndOrderWarning: false,
|
|
1721
1701
|
didLogPanelConstraintsWarning: false,
|
|
1722
1702
|
prevPanelIds: []
|
|
1723
1703
|
});
|
|
1724
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
1704
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
1725
1705
|
getId: () => committedValuesRef.current.id,
|
|
1726
1706
|
getLayout: () => {
|
|
1727
1707
|
const {
|
|
@@ -1768,7 +1748,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1768
1748
|
setLayout,
|
|
1769
1749
|
panelGroupElement: panelGroupElementRef.current
|
|
1770
1750
|
});
|
|
1771
|
-
useEffect(() => {
|
|
1751
|
+
React.useEffect(() => {
|
|
1772
1752
|
const {
|
|
1773
1753
|
panelDataArray
|
|
1774
1754
|
} = eagerValuesRef.current;
|
|
@@ -1795,7 +1775,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1795
1775
|
}, [autoSaveId, layout, storage]);
|
|
1796
1776
|
|
|
1797
1777
|
// DEV warnings
|
|
1798
|
-
useEffect(() => {
|
|
1778
|
+
React.useEffect(() => {
|
|
1799
1779
|
{
|
|
1800
1780
|
const {
|
|
1801
1781
|
panelDataArray
|
|
@@ -1841,7 +1821,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1841
1821
|
});
|
|
1842
1822
|
|
|
1843
1823
|
// External APIs are safe to memoize via committed values ref
|
|
1844
|
-
const collapsePanel = useCallback(panelData => {
|
|
1824
|
+
const collapsePanel = React.useCallback(panelData => {
|
|
1845
1825
|
const {
|
|
1846
1826
|
onLayout
|
|
1847
1827
|
} = committedValuesRef.current;
|
|
@@ -1884,7 +1864,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1884
1864
|
}, []);
|
|
1885
1865
|
|
|
1886
1866
|
// External APIs are safe to memoize via committed values ref
|
|
1887
|
-
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1867
|
+
const expandPanel = React.useCallback((panelData, minSizeOverride) => {
|
|
1888
1868
|
const {
|
|
1889
1869
|
onLayout
|
|
1890
1870
|
} = committedValuesRef.current;
|
|
@@ -1928,7 +1908,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1928
1908
|
}, []);
|
|
1929
1909
|
|
|
1930
1910
|
// External APIs are safe to memoize via committed values ref
|
|
1931
|
-
const getPanelSize = useCallback(panelData => {
|
|
1911
|
+
const getPanelSize = React.useCallback(panelData => {
|
|
1932
1912
|
const {
|
|
1933
1913
|
layout,
|
|
1934
1914
|
panelDataArray
|
|
@@ -1941,7 +1921,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1941
1921
|
}, []);
|
|
1942
1922
|
|
|
1943
1923
|
// This API should never read from committedValuesRef
|
|
1944
|
-
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1924
|
+
const getPanelStyle = React.useCallback((panelData, defaultSize) => {
|
|
1945
1925
|
const {
|
|
1946
1926
|
panelDataArray
|
|
1947
1927
|
} = eagerValuesRef.current;
|
|
@@ -1956,7 +1936,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1956
1936
|
}, [dragState, layout]);
|
|
1957
1937
|
|
|
1958
1938
|
// External APIs are safe to memoize via committed values ref
|
|
1959
|
-
const isPanelCollapsed = useCallback(panelData => {
|
|
1939
|
+
const isPanelCollapsed = React.useCallback(panelData => {
|
|
1960
1940
|
const {
|
|
1961
1941
|
layout,
|
|
1962
1942
|
panelDataArray
|
|
@@ -1971,7 +1951,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1971
1951
|
}, []);
|
|
1972
1952
|
|
|
1973
1953
|
// External APIs are safe to memoize via committed values ref
|
|
1974
|
-
const isPanelExpanded = useCallback(panelData => {
|
|
1954
|
+
const isPanelExpanded = React.useCallback(panelData => {
|
|
1975
1955
|
const {
|
|
1976
1956
|
layout,
|
|
1977
1957
|
panelDataArray
|
|
@@ -1984,7 +1964,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1984
1964
|
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1985
1965
|
return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
|
|
1986
1966
|
}, []);
|
|
1987
|
-
const registerPanel = useCallback(panelData => {
|
|
1967
|
+
const registerPanel = React.useCallback(panelData => {
|
|
1988
1968
|
const {
|
|
1989
1969
|
panelDataArray
|
|
1990
1970
|
} = eagerValuesRef.current;
|
|
@@ -2061,7 +2041,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2061
2041
|
eagerValues.layout = [];
|
|
2062
2042
|
};
|
|
2063
2043
|
}, []);
|
|
2064
|
-
const registerResizeHandle = useCallback(dragHandleId => {
|
|
2044
|
+
const registerResizeHandle = React.useCallback(dragHandleId => {
|
|
2065
2045
|
let isRTL = false;
|
|
2066
2046
|
const panelGroupElement = panelGroupElementRef.current;
|
|
2067
2047
|
if (panelGroupElement) {
|
|
@@ -2140,7 +2120,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2140
2120
|
}, []);
|
|
2141
2121
|
|
|
2142
2122
|
// External APIs are safe to memoize via committed values ref
|
|
2143
|
-
const resizePanel = useCallback((panelData, unsafePanelSize) => {
|
|
2123
|
+
const resizePanel = React.useCallback((panelData, unsafePanelSize) => {
|
|
2144
2124
|
const {
|
|
2145
2125
|
onLayout
|
|
2146
2126
|
} = committedValuesRef.current;
|
|
@@ -2173,7 +2153,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2173
2153
|
callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
2174
2154
|
}
|
|
2175
2155
|
}, []);
|
|
2176
|
-
const reevaluatePanelConstraints = useCallback((panelData, prevConstraints) => {
|
|
2156
|
+
const reevaluatePanelConstraints = React.useCallback((panelData, prevConstraints) => {
|
|
2177
2157
|
const {
|
|
2178
2158
|
layout,
|
|
2179
2159
|
panelDataArray
|
|
@@ -2207,7 +2187,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2207
2187
|
}, [resizePanel]);
|
|
2208
2188
|
|
|
2209
2189
|
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2210
|
-
const startDragging = useCallback((dragHandleId, event) => {
|
|
2190
|
+
const startDragging = React.useCallback((dragHandleId, event) => {
|
|
2211
2191
|
const {
|
|
2212
2192
|
direction
|
|
2213
2193
|
} = committedValuesRef.current;
|
|
@@ -2227,10 +2207,10 @@ function PanelGroupWithForwardedRef({
|
|
|
2227
2207
|
initialLayout: layout
|
|
2228
2208
|
});
|
|
2229
2209
|
}, []);
|
|
2230
|
-
const stopDragging = useCallback(() => {
|
|
2210
|
+
const stopDragging = React.useCallback(() => {
|
|
2231
2211
|
setDragState(null);
|
|
2232
2212
|
}, []);
|
|
2233
|
-
const unregisterPanel = useCallback(panelData => {
|
|
2213
|
+
const unregisterPanel = React.useCallback(panelData => {
|
|
2234
2214
|
const {
|
|
2235
2215
|
panelDataArray
|
|
2236
2216
|
} = eagerValuesRef.current;
|
|
@@ -2247,7 +2227,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2247
2227
|
forceUpdate();
|
|
2248
2228
|
}
|
|
2249
2229
|
}, [forceUpdate]);
|
|
2250
|
-
const context = useMemo(() => ({
|
|
2230
|
+
const context = React.useMemo(() => ({
|
|
2251
2231
|
collapsePanel,
|
|
2252
2232
|
direction,
|
|
2253
2233
|
dragState,
|
|
@@ -2273,9 +2253,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2273
2253
|
overflow: "hidden",
|
|
2274
2254
|
width: "100%"
|
|
2275
2255
|
};
|
|
2276
|
-
return createElement(PanelGroupContext.Provider, {
|
|
2256
|
+
return React.createElement(PanelGroupContext.Provider, {
|
|
2277
2257
|
value: context
|
|
2278
|
-
}, createElement(Type, {
|
|
2258
|
+
}, React.createElement(Type, {
|
|
2279
2259
|
...rest,
|
|
2280
2260
|
children,
|
|
2281
2261
|
className: classNameFromProps,
|
|
@@ -2291,7 +2271,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2291
2271
|
"data-panel-group-id": groupId
|
|
2292
2272
|
}));
|
|
2293
2273
|
}
|
|
2294
|
-
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
2274
|
+
const PanelGroup = React.forwardRef((props, ref) => React.createElement(PanelGroupWithForwardedRef, {
|
|
2295
2275
|
...props,
|
|
2296
2276
|
forwardedRef: ref
|
|
2297
2277
|
}));
|
|
@@ -2320,7 +2300,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
2320
2300
|
resizeHandler,
|
|
2321
2301
|
panelGroupElement
|
|
2322
2302
|
}) {
|
|
2323
|
-
useEffect(() => {
|
|
2303
|
+
React.useEffect(() => {
|
|
2324
2304
|
if (disabled || resizeHandler == null || panelGroupElement == null) {
|
|
2325
2305
|
return;
|
|
2326
2306
|
}
|
|
@@ -2373,24 +2353,33 @@ function PanelResizeHandle({
|
|
|
2373
2353
|
hitAreaMargins,
|
|
2374
2354
|
id: idFromProps,
|
|
2375
2355
|
onBlur,
|
|
2356
|
+
onClick,
|
|
2376
2357
|
onDragging,
|
|
2377
2358
|
onFocus,
|
|
2359
|
+
onPointerDown,
|
|
2360
|
+
onPointerUp,
|
|
2378
2361
|
style: styleFromProps = {},
|
|
2379
2362
|
tabIndex = 0,
|
|
2380
2363
|
tagName: Type = "div",
|
|
2381
2364
|
...rest
|
|
2382
2365
|
}) {
|
|
2383
2366
|
var _hitAreaMargins$coars, _hitAreaMargins$fine;
|
|
2384
|
-
const elementRef = useRef(null);
|
|
2367
|
+
const elementRef = React.useRef(null);
|
|
2385
2368
|
|
|
2386
2369
|
// Use a ref to guard against users passing inline props
|
|
2387
|
-
const callbacksRef = useRef({
|
|
2388
|
-
|
|
2370
|
+
const callbacksRef = React.useRef({
|
|
2371
|
+
onClick,
|
|
2372
|
+
onDragging,
|
|
2373
|
+
onPointerDown,
|
|
2374
|
+
onPointerUp
|
|
2389
2375
|
});
|
|
2390
|
-
useEffect(() => {
|
|
2376
|
+
React.useEffect(() => {
|
|
2377
|
+
callbacksRef.current.onClick = onClick;
|
|
2391
2378
|
callbacksRef.current.onDragging = onDragging;
|
|
2379
|
+
callbacksRef.current.onPointerDown = onPointerDown;
|
|
2380
|
+
callbacksRef.current.onPointerUp = onPointerUp;
|
|
2392
2381
|
});
|
|
2393
|
-
const panelGroupContext = useContext(PanelGroupContext);
|
|
2382
|
+
const panelGroupContext = React.useContext(PanelGroupContext);
|
|
2394
2383
|
if (panelGroupContext === null) {
|
|
2395
2384
|
throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
|
|
2396
2385
|
}
|
|
@@ -2403,16 +2392,16 @@ function PanelResizeHandle({
|
|
|
2403
2392
|
panelGroupElement
|
|
2404
2393
|
} = panelGroupContext;
|
|
2405
2394
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
2406
|
-
const [state, setState] = useState("inactive");
|
|
2407
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
2408
|
-
const [resizeHandler, setResizeHandler] = useState(null);
|
|
2409
|
-
const committedValuesRef = useRef({
|
|
2395
|
+
const [state, setState] = React.useState("inactive");
|
|
2396
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
2397
|
+
const [resizeHandler, setResizeHandler] = React.useState(null);
|
|
2398
|
+
const committedValuesRef = React.useRef({
|
|
2410
2399
|
state
|
|
2411
2400
|
});
|
|
2412
2401
|
useIsomorphicLayoutEffect(() => {
|
|
2413
2402
|
committedValuesRef.current.state = state;
|
|
2414
2403
|
});
|
|
2415
|
-
useEffect(() => {
|
|
2404
|
+
React.useEffect(() => {
|
|
2416
2405
|
if (disabled) {
|
|
2417
2406
|
setResizeHandler(null);
|
|
2418
2407
|
} else {
|
|
@@ -2425,26 +2414,28 @@ function PanelResizeHandle({
|
|
|
2425
2414
|
// so that inline object values won't trigger re-renders
|
|
2426
2415
|
const coarseHitAreaMargins = (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15;
|
|
2427
2416
|
const fineHitAreaMargins = (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5;
|
|
2428
|
-
useEffect(() => {
|
|
2417
|
+
React.useEffect(() => {
|
|
2429
2418
|
if (disabled || resizeHandler == null) {
|
|
2430
2419
|
return;
|
|
2431
2420
|
}
|
|
2432
2421
|
const element = elementRef.current;
|
|
2433
2422
|
assert(element, "Element ref not attached");
|
|
2423
|
+
let didMove = false;
|
|
2434
2424
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2435
2425
|
if (isActive) {
|
|
2436
2426
|
switch (action) {
|
|
2437
2427
|
case "down":
|
|
2438
2428
|
{
|
|
2439
2429
|
setState("drag");
|
|
2430
|
+
didMove = false;
|
|
2440
2431
|
assert(event, 'Expected event to be defined for "down" action');
|
|
2441
2432
|
startDragging(resizeHandleId, event);
|
|
2442
2433
|
const {
|
|
2443
|
-
onDragging
|
|
2434
|
+
onDragging,
|
|
2435
|
+
onPointerDown
|
|
2444
2436
|
} = callbacksRef.current;
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
}
|
|
2437
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
|
|
2438
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
|
|
2448
2439
|
break;
|
|
2449
2440
|
}
|
|
2450
2441
|
case "move":
|
|
@@ -2452,6 +2443,7 @@ function PanelResizeHandle({
|
|
|
2452
2443
|
const {
|
|
2453
2444
|
state
|
|
2454
2445
|
} = committedValuesRef.current;
|
|
2446
|
+
didMove = true;
|
|
2455
2447
|
if (state !== "drag") {
|
|
2456
2448
|
setState("hover");
|
|
2457
2449
|
}
|
|
@@ -2464,10 +2456,14 @@ function PanelResizeHandle({
|
|
|
2464
2456
|
setState("hover");
|
|
2465
2457
|
stopDragging();
|
|
2466
2458
|
const {
|
|
2467
|
-
|
|
2459
|
+
onClick,
|
|
2460
|
+
onDragging,
|
|
2461
|
+
onPointerUp
|
|
2468
2462
|
} = callbacksRef.current;
|
|
2469
|
-
|
|
2470
|
-
|
|
2463
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
|
|
2464
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
2465
|
+
if (!didMove) {
|
|
2466
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
2471
2467
|
}
|
|
2472
2468
|
break;
|
|
2473
2469
|
}
|
|
@@ -2491,7 +2487,7 @@ function PanelResizeHandle({
|
|
|
2491
2487
|
touchAction: "none",
|
|
2492
2488
|
userSelect: "none"
|
|
2493
2489
|
};
|
|
2494
|
-
return createElement(Type, {
|
|
2490
|
+
return React.createElement(Type, {
|
|
2495
2491
|
...rest,
|
|
2496
2492
|
children,
|
|
2497
2493
|
className: classNameFromProps,
|
|
@@ -1,37 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { createContext, useLayoutEffect, useRef, forwardRef, createElement, useContext, useImperativeHandle, useState, useCallback, useEffect, useMemo } from 'react';
|
|
2
3
|
|
|
3
4
|
const isBrowser = typeof window !== "undefined";
|
|
4
5
|
|
|
5
|
-
// This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line no-restricted-imports
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
createElement,
|
|
11
|
-
createContext,
|
|
12
|
-
createRef,
|
|
13
|
-
forwardRef,
|
|
14
|
-
useCallback,
|
|
15
|
-
useContext,
|
|
16
|
-
useEffect,
|
|
17
|
-
useImperativeHandle,
|
|
18
|
-
useLayoutEffect,
|
|
19
|
-
useMemo,
|
|
20
|
-
useRef,
|
|
21
|
-
useState
|
|
22
|
-
} = React;
|
|
23
|
-
|
|
24
|
-
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
25
|
-
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
26
|
-
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
27
|
-
|
|
28
6
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
29
7
|
|
|
30
8
|
const PanelGroupContext = createContext(null);
|
|
31
9
|
PanelGroupContext.displayName = "PanelGroupContext";
|
|
32
10
|
|
|
33
|
-
const useIsomorphicLayoutEffect = isBrowser ?
|
|
11
|
+
const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : () => {};
|
|
34
12
|
|
|
13
|
+
const useId = React["useId".toString()];
|
|
35
14
|
const wrappedUseId = typeof useId === "function" ? useId : () => null;
|
|
36
15
|
let counter = 0;
|
|
37
16
|
function useUniqueId(idFromParams = null) {
|
|
@@ -170,7 +149,7 @@ function PanelWithForwardedRef({
|
|
|
170
149
|
...rest,
|
|
171
150
|
children,
|
|
172
151
|
className: classNameFromProps,
|
|
173
|
-
id:
|
|
152
|
+
id: panelId,
|
|
174
153
|
style: {
|
|
175
154
|
...style,
|
|
176
155
|
...styleFromProps
|
|
@@ -655,7 +634,9 @@ function updateListeners() {
|
|
|
655
634
|
body
|
|
656
635
|
} = ownerDocument;
|
|
657
636
|
body.removeEventListener("contextmenu", handlePointerUp);
|
|
658
|
-
body.removeEventListener("pointerdown", handlePointerDown
|
|
637
|
+
body.removeEventListener("pointerdown", handlePointerDown, {
|
|
638
|
+
capture: true
|
|
639
|
+
});
|
|
659
640
|
body.removeEventListener("pointerleave", handlePointerMove);
|
|
660
641
|
body.removeEventListener("pointermove", handlePointerMove);
|
|
661
642
|
});
|
|
@@ -2349,8 +2330,11 @@ function PanelResizeHandle({
|
|
|
2349
2330
|
hitAreaMargins,
|
|
2350
2331
|
id: idFromProps,
|
|
2351
2332
|
onBlur,
|
|
2333
|
+
onClick,
|
|
2352
2334
|
onDragging,
|
|
2353
2335
|
onFocus,
|
|
2336
|
+
onPointerDown,
|
|
2337
|
+
onPointerUp,
|
|
2354
2338
|
style: styleFromProps = {},
|
|
2355
2339
|
tabIndex = 0,
|
|
2356
2340
|
tagName: Type = "div",
|
|
@@ -2361,10 +2345,16 @@ function PanelResizeHandle({
|
|
|
2361
2345
|
|
|
2362
2346
|
// Use a ref to guard against users passing inline props
|
|
2363
2347
|
const callbacksRef = useRef({
|
|
2364
|
-
|
|
2348
|
+
onClick,
|
|
2349
|
+
onDragging,
|
|
2350
|
+
onPointerDown,
|
|
2351
|
+
onPointerUp
|
|
2365
2352
|
});
|
|
2366
2353
|
useEffect(() => {
|
|
2354
|
+
callbacksRef.current.onClick = onClick;
|
|
2367
2355
|
callbacksRef.current.onDragging = onDragging;
|
|
2356
|
+
callbacksRef.current.onPointerDown = onPointerDown;
|
|
2357
|
+
callbacksRef.current.onPointerUp = onPointerUp;
|
|
2368
2358
|
});
|
|
2369
2359
|
const panelGroupContext = useContext(PanelGroupContext);
|
|
2370
2360
|
if (panelGroupContext === null) {
|
|
@@ -2407,20 +2397,22 @@ function PanelResizeHandle({
|
|
|
2407
2397
|
}
|
|
2408
2398
|
const element = elementRef.current;
|
|
2409
2399
|
assert(element, "Element ref not attached");
|
|
2400
|
+
let didMove = false;
|
|
2410
2401
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2411
2402
|
if (isActive) {
|
|
2412
2403
|
switch (action) {
|
|
2413
2404
|
case "down":
|
|
2414
2405
|
{
|
|
2415
2406
|
setState("drag");
|
|
2407
|
+
didMove = false;
|
|
2416
2408
|
assert(event, 'Expected event to be defined for "down" action');
|
|
2417
2409
|
startDragging(resizeHandleId, event);
|
|
2418
2410
|
const {
|
|
2419
|
-
onDragging
|
|
2411
|
+
onDragging,
|
|
2412
|
+
onPointerDown
|
|
2420
2413
|
} = callbacksRef.current;
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
}
|
|
2414
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
|
|
2415
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
|
|
2424
2416
|
break;
|
|
2425
2417
|
}
|
|
2426
2418
|
case "move":
|
|
@@ -2428,6 +2420,7 @@ function PanelResizeHandle({
|
|
|
2428
2420
|
const {
|
|
2429
2421
|
state
|
|
2430
2422
|
} = committedValuesRef.current;
|
|
2423
|
+
didMove = true;
|
|
2431
2424
|
if (state !== "drag") {
|
|
2432
2425
|
setState("hover");
|
|
2433
2426
|
}
|
|
@@ -2440,10 +2433,14 @@ function PanelResizeHandle({
|
|
|
2440
2433
|
setState("hover");
|
|
2441
2434
|
stopDragging();
|
|
2442
2435
|
const {
|
|
2443
|
-
|
|
2436
|
+
onClick,
|
|
2437
|
+
onDragging,
|
|
2438
|
+
onPointerUp
|
|
2444
2439
|
} = callbacksRef.current;
|
|
2445
|
-
|
|
2446
|
-
|
|
2440
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
|
|
2441
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
2442
|
+
if (!didMove) {
|
|
2443
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
2447
2444
|
}
|
|
2448
2445
|
break;
|
|
2449
2446
|
}
|