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
|
@@ -1,35 +1,14 @@
|
|
|
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)];
|
|
24
|
-
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
2
|
+
import { createContext, useLayoutEffect, useRef, forwardRef, createElement, useContext, useImperativeHandle, useState, useCallback, useEffect, useMemo } from 'react';
|
|
25
3
|
|
|
26
4
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
27
5
|
|
|
28
6
|
const PanelGroupContext = createContext(null);
|
|
29
7
|
PanelGroupContext.displayName = "PanelGroupContext";
|
|
30
8
|
|
|
31
|
-
const useIsomorphicLayoutEffect =
|
|
9
|
+
const useIsomorphicLayoutEffect = useLayoutEffect ;
|
|
32
10
|
|
|
11
|
+
const useId = React["useId".toString()];
|
|
33
12
|
const wrappedUseId = typeof useId === "function" ? useId : () => null;
|
|
34
13
|
let counter = 0;
|
|
35
14
|
function useUniqueId(idFromParams = null) {
|
|
@@ -157,7 +136,7 @@ function PanelWithForwardedRef({
|
|
|
157
136
|
...rest,
|
|
158
137
|
children,
|
|
159
138
|
className: classNameFromProps,
|
|
160
|
-
id:
|
|
139
|
+
id: panelId,
|
|
161
140
|
style: {
|
|
162
141
|
...style,
|
|
163
142
|
...styleFromProps
|
|
@@ -642,7 +621,9 @@ function updateListeners() {
|
|
|
642
621
|
body
|
|
643
622
|
} = ownerDocument;
|
|
644
623
|
body.removeEventListener("contextmenu", handlePointerUp);
|
|
645
|
-
body.removeEventListener("pointerdown", handlePointerDown
|
|
624
|
+
body.removeEventListener("pointerdown", handlePointerDown, {
|
|
625
|
+
capture: true
|
|
626
|
+
});
|
|
646
627
|
body.removeEventListener("pointerleave", handlePointerMove);
|
|
647
628
|
body.removeEventListener("pointermove", handlePointerMove);
|
|
648
629
|
});
|
|
@@ -2236,8 +2217,11 @@ function PanelResizeHandle({
|
|
|
2236
2217
|
hitAreaMargins,
|
|
2237
2218
|
id: idFromProps,
|
|
2238
2219
|
onBlur,
|
|
2220
|
+
onClick,
|
|
2239
2221
|
onDragging,
|
|
2240
2222
|
onFocus,
|
|
2223
|
+
onPointerDown,
|
|
2224
|
+
onPointerUp,
|
|
2241
2225
|
style: styleFromProps = {},
|
|
2242
2226
|
tabIndex = 0,
|
|
2243
2227
|
tagName: Type = "div",
|
|
@@ -2248,10 +2232,16 @@ function PanelResizeHandle({
|
|
|
2248
2232
|
|
|
2249
2233
|
// Use a ref to guard against users passing inline props
|
|
2250
2234
|
const callbacksRef = useRef({
|
|
2251
|
-
|
|
2235
|
+
onClick,
|
|
2236
|
+
onDragging,
|
|
2237
|
+
onPointerDown,
|
|
2238
|
+
onPointerUp
|
|
2252
2239
|
});
|
|
2253
2240
|
useEffect(() => {
|
|
2241
|
+
callbacksRef.current.onClick = onClick;
|
|
2254
2242
|
callbacksRef.current.onDragging = onDragging;
|
|
2243
|
+
callbacksRef.current.onPointerDown = onPointerDown;
|
|
2244
|
+
callbacksRef.current.onPointerUp = onPointerUp;
|
|
2255
2245
|
});
|
|
2256
2246
|
const panelGroupContext = useContext(PanelGroupContext);
|
|
2257
2247
|
if (panelGroupContext === null) {
|
|
@@ -2294,20 +2284,22 @@ function PanelResizeHandle({
|
|
|
2294
2284
|
}
|
|
2295
2285
|
const element = elementRef.current;
|
|
2296
2286
|
assert(element, "Element ref not attached");
|
|
2287
|
+
let didMove = false;
|
|
2297
2288
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2298
2289
|
if (isActive) {
|
|
2299
2290
|
switch (action) {
|
|
2300
2291
|
case "down":
|
|
2301
2292
|
{
|
|
2302
2293
|
setState("drag");
|
|
2294
|
+
didMove = false;
|
|
2303
2295
|
assert(event, 'Expected event to be defined for "down" action');
|
|
2304
2296
|
startDragging(resizeHandleId, event);
|
|
2305
2297
|
const {
|
|
2306
|
-
onDragging
|
|
2298
|
+
onDragging,
|
|
2299
|
+
onPointerDown
|
|
2307
2300
|
} = callbacksRef.current;
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
}
|
|
2301
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
|
|
2302
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
|
|
2311
2303
|
break;
|
|
2312
2304
|
}
|
|
2313
2305
|
case "move":
|
|
@@ -2315,6 +2307,7 @@ function PanelResizeHandle({
|
|
|
2315
2307
|
const {
|
|
2316
2308
|
state
|
|
2317
2309
|
} = committedValuesRef.current;
|
|
2310
|
+
didMove = true;
|
|
2318
2311
|
if (state !== "drag") {
|
|
2319
2312
|
setState("hover");
|
|
2320
2313
|
}
|
|
@@ -2327,10 +2320,14 @@ function PanelResizeHandle({
|
|
|
2327
2320
|
setState("hover");
|
|
2328
2321
|
stopDragging();
|
|
2329
2322
|
const {
|
|
2330
|
-
|
|
2323
|
+
onClick,
|
|
2324
|
+
onDragging,
|
|
2325
|
+
onPointerUp
|
|
2331
2326
|
} = callbacksRef.current;
|
|
2332
|
-
|
|
2333
|
-
|
|
2327
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
|
|
2328
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
2329
|
+
if (!didMove) {
|
|
2330
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
2334
2331
|
}
|
|
2335
2332
|
break;
|
|
2336
2333
|
}
|
|
@@ -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
|
-
useRef({
|
|
100
|
+
React.useRef({
|
|
123
101
|
didLogMissingDefaultSizeWarning: false
|
|
124
102
|
});
|
|
125
103
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -155,7 +133,7 @@ function PanelWithForwardedRef({
|
|
|
155
133
|
unregisterPanel(panelData);
|
|
156
134
|
};
|
|
157
135
|
}, [order, panelId, registerPanel, unregisterPanel]);
|
|
158
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
136
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
159
137
|
collapse: () => {
|
|
160
138
|
collapsePanel(panelDataRef.current);
|
|
161
139
|
},
|
|
@@ -179,11 +157,11 @@ function PanelWithForwardedRef({
|
|
|
179
157
|
}
|
|
180
158
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
181
159
|
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
182
|
-
return createElement(Type, {
|
|
160
|
+
return React.createElement(Type, {
|
|
183
161
|
...rest,
|
|
184
162
|
children,
|
|
185
163
|
className: classNameFromProps,
|
|
186
|
-
id:
|
|
164
|
+
id: panelId,
|
|
187
165
|
style: {
|
|
188
166
|
...style,
|
|
189
167
|
...styleFromProps
|
|
@@ -196,7 +174,7 @@ function PanelWithForwardedRef({
|
|
|
196
174
|
"data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
|
|
197
175
|
});
|
|
198
176
|
}
|
|
199
|
-
const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
177
|
+
const Panel = React.forwardRef((props, ref) => React.createElement(PanelWithForwardedRef, {
|
|
200
178
|
...props,
|
|
201
179
|
forwardedRef: ref
|
|
202
180
|
}));
|
|
@@ -668,7 +646,9 @@ function updateListeners() {
|
|
|
668
646
|
body
|
|
669
647
|
} = ownerDocument;
|
|
670
648
|
body.removeEventListener("contextmenu", handlePointerUp);
|
|
671
|
-
body.removeEventListener("pointerdown", handlePointerDown
|
|
649
|
+
body.removeEventListener("pointerdown", handlePointerDown, {
|
|
650
|
+
capture: true
|
|
651
|
+
});
|
|
672
652
|
body.removeEventListener("pointerleave", handlePointerMove);
|
|
673
653
|
body.removeEventListener("pointermove", handlePointerMove);
|
|
674
654
|
});
|
|
@@ -716,8 +696,8 @@ function updateResizeHandlerStates(action, event) {
|
|
|
716
696
|
}
|
|
717
697
|
|
|
718
698
|
function useForceUpdate() {
|
|
719
|
-
const [_, setCount] = useState(0);
|
|
720
|
-
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
699
|
+
const [_, setCount] = React.useState(0);
|
|
700
|
+
return React.useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
721
701
|
}
|
|
722
702
|
|
|
723
703
|
function assert(expectedCondition, message) {
|
|
@@ -1130,7 +1110,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1130
1110
|
panelGroupElement,
|
|
1131
1111
|
setLayout
|
|
1132
1112
|
}) {
|
|
1133
|
-
useRef({
|
|
1113
|
+
React.useRef({
|
|
1134
1114
|
didWarnAboutMissingResizeHandle: false
|
|
1135
1115
|
});
|
|
1136
1116
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -1167,7 +1147,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1167
1147
|
});
|
|
1168
1148
|
};
|
|
1169
1149
|
}, [groupId, layout, panelDataArray, panelGroupElement]);
|
|
1170
|
-
useEffect(() => {
|
|
1150
|
+
React.useEffect(() => {
|
|
1171
1151
|
if (!panelGroupElement) {
|
|
1172
1152
|
return;
|
|
1173
1153
|
}
|
|
@@ -1626,14 +1606,14 @@ function PanelGroupWithForwardedRef({
|
|
|
1626
1606
|
...rest
|
|
1627
1607
|
}) {
|
|
1628
1608
|
const groupId = useUniqueId(idFromProps);
|
|
1629
|
-
const panelGroupElementRef = useRef(null);
|
|
1630
|
-
const [dragState, setDragState] = useState(null);
|
|
1631
|
-
const [layout, setLayout] = useState([]);
|
|
1609
|
+
const panelGroupElementRef = React.useRef(null);
|
|
1610
|
+
const [dragState, setDragState] = React.useState(null);
|
|
1611
|
+
const [layout, setLayout] = React.useState([]);
|
|
1632
1612
|
const forceUpdate = useForceUpdate();
|
|
1633
|
-
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1634
|
-
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1635
|
-
const prevDeltaRef = useRef(0);
|
|
1636
|
-
const committedValuesRef = useRef({
|
|
1613
|
+
const panelIdToLastNotifiedSizeMapRef = React.useRef({});
|
|
1614
|
+
const panelSizeBeforeCollapseRef = React.useRef(new Map());
|
|
1615
|
+
const prevDeltaRef = React.useRef(0);
|
|
1616
|
+
const committedValuesRef = React.useRef({
|
|
1637
1617
|
autoSaveId,
|
|
1638
1618
|
direction,
|
|
1639
1619
|
dragState,
|
|
@@ -1642,17 +1622,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1642
1622
|
onLayout,
|
|
1643
1623
|
storage
|
|
1644
1624
|
});
|
|
1645
|
-
const eagerValuesRef = useRef({
|
|
1625
|
+
const eagerValuesRef = React.useRef({
|
|
1646
1626
|
layout,
|
|
1647
1627
|
panelDataArray: [],
|
|
1648
1628
|
panelDataArrayChanged: false
|
|
1649
1629
|
});
|
|
1650
|
-
useRef({
|
|
1630
|
+
React.useRef({
|
|
1651
1631
|
didLogIdAndOrderWarning: false,
|
|
1652
1632
|
didLogPanelConstraintsWarning: false,
|
|
1653
1633
|
prevPanelIds: []
|
|
1654
1634
|
});
|
|
1655
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
1635
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
1656
1636
|
getId: () => committedValuesRef.current.id,
|
|
1657
1637
|
getLayout: () => {
|
|
1658
1638
|
const {
|
|
@@ -1699,7 +1679,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1699
1679
|
setLayout,
|
|
1700
1680
|
panelGroupElement: panelGroupElementRef.current
|
|
1701
1681
|
});
|
|
1702
|
-
useEffect(() => {
|
|
1682
|
+
React.useEffect(() => {
|
|
1703
1683
|
const {
|
|
1704
1684
|
panelDataArray
|
|
1705
1685
|
} = eagerValuesRef.current;
|
|
@@ -1726,11 +1706,11 @@ function PanelGroupWithForwardedRef({
|
|
|
1726
1706
|
}, [autoSaveId, layout, storage]);
|
|
1727
1707
|
|
|
1728
1708
|
// DEV warnings
|
|
1729
|
-
useEffect(() => {
|
|
1709
|
+
React.useEffect(() => {
|
|
1730
1710
|
});
|
|
1731
1711
|
|
|
1732
1712
|
// External APIs are safe to memoize via committed values ref
|
|
1733
|
-
const collapsePanel = useCallback(panelData => {
|
|
1713
|
+
const collapsePanel = React.useCallback(panelData => {
|
|
1734
1714
|
const {
|
|
1735
1715
|
onLayout
|
|
1736
1716
|
} = committedValuesRef.current;
|
|
@@ -1773,7 +1753,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1773
1753
|
}, []);
|
|
1774
1754
|
|
|
1775
1755
|
// External APIs are safe to memoize via committed values ref
|
|
1776
|
-
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1756
|
+
const expandPanel = React.useCallback((panelData, minSizeOverride) => {
|
|
1777
1757
|
const {
|
|
1778
1758
|
onLayout
|
|
1779
1759
|
} = committedValuesRef.current;
|
|
@@ -1817,7 +1797,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1817
1797
|
}, []);
|
|
1818
1798
|
|
|
1819
1799
|
// External APIs are safe to memoize via committed values ref
|
|
1820
|
-
const getPanelSize = useCallback(panelData => {
|
|
1800
|
+
const getPanelSize = React.useCallback(panelData => {
|
|
1821
1801
|
const {
|
|
1822
1802
|
layout,
|
|
1823
1803
|
panelDataArray
|
|
@@ -1830,7 +1810,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1830
1810
|
}, []);
|
|
1831
1811
|
|
|
1832
1812
|
// This API should never read from committedValuesRef
|
|
1833
|
-
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1813
|
+
const getPanelStyle = React.useCallback((panelData, defaultSize) => {
|
|
1834
1814
|
const {
|
|
1835
1815
|
panelDataArray
|
|
1836
1816
|
} = eagerValuesRef.current;
|
|
@@ -1845,7 +1825,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1845
1825
|
}, [dragState, layout]);
|
|
1846
1826
|
|
|
1847
1827
|
// External APIs are safe to memoize via committed values ref
|
|
1848
|
-
const isPanelCollapsed = useCallback(panelData => {
|
|
1828
|
+
const isPanelCollapsed = React.useCallback(panelData => {
|
|
1849
1829
|
const {
|
|
1850
1830
|
layout,
|
|
1851
1831
|
panelDataArray
|
|
@@ -1860,7 +1840,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1860
1840
|
}, []);
|
|
1861
1841
|
|
|
1862
1842
|
// External APIs are safe to memoize via committed values ref
|
|
1863
|
-
const isPanelExpanded = useCallback(panelData => {
|
|
1843
|
+
const isPanelExpanded = React.useCallback(panelData => {
|
|
1864
1844
|
const {
|
|
1865
1845
|
layout,
|
|
1866
1846
|
panelDataArray
|
|
@@ -1873,7 +1853,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1873
1853
|
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1874
1854
|
return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
|
|
1875
1855
|
}, []);
|
|
1876
|
-
const registerPanel = useCallback(panelData => {
|
|
1856
|
+
const registerPanel = React.useCallback(panelData => {
|
|
1877
1857
|
const {
|
|
1878
1858
|
panelDataArray
|
|
1879
1859
|
} = eagerValuesRef.current;
|
|
@@ -1950,7 +1930,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1950
1930
|
eagerValues.layout = [];
|
|
1951
1931
|
};
|
|
1952
1932
|
}, []);
|
|
1953
|
-
const registerResizeHandle = useCallback(dragHandleId => {
|
|
1933
|
+
const registerResizeHandle = React.useCallback(dragHandleId => {
|
|
1954
1934
|
let isRTL = false;
|
|
1955
1935
|
const panelGroupElement = panelGroupElementRef.current;
|
|
1956
1936
|
if (panelGroupElement) {
|
|
@@ -2029,7 +2009,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2029
2009
|
}, []);
|
|
2030
2010
|
|
|
2031
2011
|
// External APIs are safe to memoize via committed values ref
|
|
2032
|
-
const resizePanel = useCallback((panelData, unsafePanelSize) => {
|
|
2012
|
+
const resizePanel = React.useCallback((panelData, unsafePanelSize) => {
|
|
2033
2013
|
const {
|
|
2034
2014
|
onLayout
|
|
2035
2015
|
} = committedValuesRef.current;
|
|
@@ -2062,7 +2042,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2062
2042
|
callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
2063
2043
|
}
|
|
2064
2044
|
}, []);
|
|
2065
|
-
const reevaluatePanelConstraints = useCallback((panelData, prevConstraints) => {
|
|
2045
|
+
const reevaluatePanelConstraints = React.useCallback((panelData, prevConstraints) => {
|
|
2066
2046
|
const {
|
|
2067
2047
|
layout,
|
|
2068
2048
|
panelDataArray
|
|
@@ -2096,7 +2076,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2096
2076
|
}, [resizePanel]);
|
|
2097
2077
|
|
|
2098
2078
|
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2099
|
-
const startDragging = useCallback((dragHandleId, event) => {
|
|
2079
|
+
const startDragging = React.useCallback((dragHandleId, event) => {
|
|
2100
2080
|
const {
|
|
2101
2081
|
direction
|
|
2102
2082
|
} = committedValuesRef.current;
|
|
@@ -2116,10 +2096,10 @@ function PanelGroupWithForwardedRef({
|
|
|
2116
2096
|
initialLayout: layout
|
|
2117
2097
|
});
|
|
2118
2098
|
}, []);
|
|
2119
|
-
const stopDragging = useCallback(() => {
|
|
2099
|
+
const stopDragging = React.useCallback(() => {
|
|
2120
2100
|
setDragState(null);
|
|
2121
2101
|
}, []);
|
|
2122
|
-
const unregisterPanel = useCallback(panelData => {
|
|
2102
|
+
const unregisterPanel = React.useCallback(panelData => {
|
|
2123
2103
|
const {
|
|
2124
2104
|
panelDataArray
|
|
2125
2105
|
} = eagerValuesRef.current;
|
|
@@ -2136,7 +2116,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2136
2116
|
forceUpdate();
|
|
2137
2117
|
}
|
|
2138
2118
|
}, [forceUpdate]);
|
|
2139
|
-
const context = useMemo(() => ({
|
|
2119
|
+
const context = React.useMemo(() => ({
|
|
2140
2120
|
collapsePanel,
|
|
2141
2121
|
direction,
|
|
2142
2122
|
dragState,
|
|
@@ -2162,9 +2142,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2162
2142
|
overflow: "hidden",
|
|
2163
2143
|
width: "100%"
|
|
2164
2144
|
};
|
|
2165
|
-
return createElement(PanelGroupContext.Provider, {
|
|
2145
|
+
return React.createElement(PanelGroupContext.Provider, {
|
|
2166
2146
|
value: context
|
|
2167
|
-
}, createElement(Type, {
|
|
2147
|
+
}, React.createElement(Type, {
|
|
2168
2148
|
...rest,
|
|
2169
2149
|
children,
|
|
2170
2150
|
className: classNameFromProps,
|
|
@@ -2180,7 +2160,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2180
2160
|
"data-panel-group-id": groupId
|
|
2181
2161
|
}));
|
|
2182
2162
|
}
|
|
2183
|
-
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
2163
|
+
const PanelGroup = React.forwardRef((props, ref) => React.createElement(PanelGroupWithForwardedRef, {
|
|
2184
2164
|
...props,
|
|
2185
2165
|
forwardedRef: ref
|
|
2186
2166
|
}));
|
|
@@ -2209,7 +2189,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
2209
2189
|
resizeHandler,
|
|
2210
2190
|
panelGroupElement
|
|
2211
2191
|
}) {
|
|
2212
|
-
useEffect(() => {
|
|
2192
|
+
React.useEffect(() => {
|
|
2213
2193
|
if (disabled || resizeHandler == null || panelGroupElement == null) {
|
|
2214
2194
|
return;
|
|
2215
2195
|
}
|
|
@@ -2262,24 +2242,33 @@ function PanelResizeHandle({
|
|
|
2262
2242
|
hitAreaMargins,
|
|
2263
2243
|
id: idFromProps,
|
|
2264
2244
|
onBlur,
|
|
2245
|
+
onClick,
|
|
2265
2246
|
onDragging,
|
|
2266
2247
|
onFocus,
|
|
2248
|
+
onPointerDown,
|
|
2249
|
+
onPointerUp,
|
|
2267
2250
|
style: styleFromProps = {},
|
|
2268
2251
|
tabIndex = 0,
|
|
2269
2252
|
tagName: Type = "div",
|
|
2270
2253
|
...rest
|
|
2271
2254
|
}) {
|
|
2272
2255
|
var _hitAreaMargins$coars, _hitAreaMargins$fine;
|
|
2273
|
-
const elementRef = useRef(null);
|
|
2256
|
+
const elementRef = React.useRef(null);
|
|
2274
2257
|
|
|
2275
2258
|
// Use a ref to guard against users passing inline props
|
|
2276
|
-
const callbacksRef = useRef({
|
|
2277
|
-
|
|
2259
|
+
const callbacksRef = React.useRef({
|
|
2260
|
+
onClick,
|
|
2261
|
+
onDragging,
|
|
2262
|
+
onPointerDown,
|
|
2263
|
+
onPointerUp
|
|
2278
2264
|
});
|
|
2279
|
-
useEffect(() => {
|
|
2265
|
+
React.useEffect(() => {
|
|
2266
|
+
callbacksRef.current.onClick = onClick;
|
|
2280
2267
|
callbacksRef.current.onDragging = onDragging;
|
|
2268
|
+
callbacksRef.current.onPointerDown = onPointerDown;
|
|
2269
|
+
callbacksRef.current.onPointerUp = onPointerUp;
|
|
2281
2270
|
});
|
|
2282
|
-
const panelGroupContext = useContext(PanelGroupContext);
|
|
2271
|
+
const panelGroupContext = React.useContext(PanelGroupContext);
|
|
2283
2272
|
if (panelGroupContext === null) {
|
|
2284
2273
|
throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
|
|
2285
2274
|
}
|
|
@@ -2292,16 +2281,16 @@ function PanelResizeHandle({
|
|
|
2292
2281
|
panelGroupElement
|
|
2293
2282
|
} = panelGroupContext;
|
|
2294
2283
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
2295
|
-
const [state, setState] = useState("inactive");
|
|
2296
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
2297
|
-
const [resizeHandler, setResizeHandler] = useState(null);
|
|
2298
|
-
const committedValuesRef = useRef({
|
|
2284
|
+
const [state, setState] = React.useState("inactive");
|
|
2285
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
2286
|
+
const [resizeHandler, setResizeHandler] = React.useState(null);
|
|
2287
|
+
const committedValuesRef = React.useRef({
|
|
2299
2288
|
state
|
|
2300
2289
|
});
|
|
2301
2290
|
useIsomorphicLayoutEffect(() => {
|
|
2302
2291
|
committedValuesRef.current.state = state;
|
|
2303
2292
|
});
|
|
2304
|
-
useEffect(() => {
|
|
2293
|
+
React.useEffect(() => {
|
|
2305
2294
|
if (disabled) {
|
|
2306
2295
|
setResizeHandler(null);
|
|
2307
2296
|
} else {
|
|
@@ -2314,26 +2303,28 @@ function PanelResizeHandle({
|
|
|
2314
2303
|
// so that inline object values won't trigger re-renders
|
|
2315
2304
|
const coarseHitAreaMargins = (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15;
|
|
2316
2305
|
const fineHitAreaMargins = (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5;
|
|
2317
|
-
useEffect(() => {
|
|
2306
|
+
React.useEffect(() => {
|
|
2318
2307
|
if (disabled || resizeHandler == null) {
|
|
2319
2308
|
return;
|
|
2320
2309
|
}
|
|
2321
2310
|
const element = elementRef.current;
|
|
2322
2311
|
assert(element, "Element ref not attached");
|
|
2312
|
+
let didMove = false;
|
|
2323
2313
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2324
2314
|
if (isActive) {
|
|
2325
2315
|
switch (action) {
|
|
2326
2316
|
case "down":
|
|
2327
2317
|
{
|
|
2328
2318
|
setState("drag");
|
|
2319
|
+
didMove = false;
|
|
2329
2320
|
assert(event, 'Expected event to be defined for "down" action');
|
|
2330
2321
|
startDragging(resizeHandleId, event);
|
|
2331
2322
|
const {
|
|
2332
|
-
onDragging
|
|
2323
|
+
onDragging,
|
|
2324
|
+
onPointerDown
|
|
2333
2325
|
} = callbacksRef.current;
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
}
|
|
2326
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
|
|
2327
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
|
|
2337
2328
|
break;
|
|
2338
2329
|
}
|
|
2339
2330
|
case "move":
|
|
@@ -2341,6 +2332,7 @@ function PanelResizeHandle({
|
|
|
2341
2332
|
const {
|
|
2342
2333
|
state
|
|
2343
2334
|
} = committedValuesRef.current;
|
|
2335
|
+
didMove = true;
|
|
2344
2336
|
if (state !== "drag") {
|
|
2345
2337
|
setState("hover");
|
|
2346
2338
|
}
|
|
@@ -2353,10 +2345,14 @@ function PanelResizeHandle({
|
|
|
2353
2345
|
setState("hover");
|
|
2354
2346
|
stopDragging();
|
|
2355
2347
|
const {
|
|
2356
|
-
|
|
2348
|
+
onClick,
|
|
2349
|
+
onDragging,
|
|
2350
|
+
onPointerUp
|
|
2357
2351
|
} = callbacksRef.current;
|
|
2358
|
-
|
|
2359
|
-
|
|
2352
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
|
|
2353
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
2354
|
+
if (!didMove) {
|
|
2355
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
2360
2356
|
}
|
|
2361
2357
|
break;
|
|
2362
2358
|
}
|
|
@@ -2380,7 +2376,7 @@ function PanelResizeHandle({
|
|
|
2380
2376
|
touchAction: "none",
|
|
2381
2377
|
userSelect: "none"
|
|
2382
2378
|
};
|
|
2383
|
-
return createElement(Type, {
|
|
2379
|
+
return React.createElement(Type, {
|
|
2384
2380
|
...rest,
|
|
2385
2381
|
children,
|
|
2386
2382
|
className: classNameFromProps,
|