react-resizable-panels 2.1.6 → 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 +90 -94
- package/dist/react-resizable-panels.browser.development.cjs.js +90 -94
- package/dist/react-resizable-panels.browser.development.esm.js +38 -41
- package/dist/react-resizable-panels.browser.esm.js +38 -41
- package/dist/react-resizable-panels.cjs.js +90 -94
- package/dist/react-resizable-panels.development.cjs.js +90 -94
- package/dist/react-resizable-panels.development.esm.js +38 -41
- package/dist/react-resizable-panels.development.node.cjs.js +89 -92
- package/dist/react-resizable-panels.development.node.esm.js +37 -39
- package/dist/react-resizable-panels.esm.js +38 -41
- package/dist/react-resizable-panels.node.cjs.js +89 -92
- package/dist/react-resizable-panels.node.esm.js +37 -39
- package/package.json +7 -2
- package/.eslintrc.cjs +0 -27
- package/CHANGELOG.md +0 -574
- package/dist/declarations/src/vendor/react.d.ts +0 -7
- package/jest.config.js +0 -10
- package/src/Panel.test.tsx +0 -1084
- package/src/Panel.ts +0 -259
- package/src/PanelGroup.test.tsx +0 -443
- package/src/PanelGroup.ts +0 -999
- package/src/PanelGroupContext.ts +0 -42
- package/src/PanelResizeHandle.test.tsx +0 -367
- package/src/PanelResizeHandle.ts +0 -246
- package/src/PanelResizeHandleRegistry.ts +0 -336
- package/src/constants.ts +0 -1
- package/src/env-conditions/browser.ts +0 -1
- package/src/env-conditions/development.ts +0 -1
- package/src/env-conditions/node.ts +0 -1
- package/src/env-conditions/production.ts +0 -1
- package/src/env-conditions/unknown.ts +0 -1
- package/src/hooks/useForceUpdate.ts +0 -7
- package/src/hooks/useIsomorphicEffect.ts +0 -8
- package/src/hooks/useUniqueId.ts +0 -19
- package/src/hooks/useWindowSplitterBehavior.ts +0 -90
- package/src/hooks/useWindowSplitterPanelGroupBehavior.ts +0 -201
- package/src/index.ts +0 -77
- package/src/types.ts +0 -5
- package/src/utils/adjustLayoutByDelta.test.ts +0 -2061
- package/src/utils/adjustLayoutByDelta.ts +0 -308
- package/src/utils/arrays.ts +0 -13
- package/src/utils/assert.ts +0 -10
- package/src/utils/calculateAriaValues.test.ts +0 -106
- package/src/utils/calculateAriaValues.ts +0 -45
- package/src/utils/calculateDeltaPercentage.ts +0 -63
- package/src/utils/calculateDragOffsetPercentage.ts +0 -40
- package/src/utils/calculateUnsafeDefaultLayout.test.ts +0 -87
- package/src/utils/calculateUnsafeDefaultLayout.ts +0 -50
- package/src/utils/callPanelCallbacks.ts +0 -49
- package/src/utils/compareLayouts.test.ts +0 -9
- package/src/utils/compareLayouts.ts +0 -12
- package/src/utils/computePanelFlexBoxStyle.test.ts +0 -123
- package/src/utils/computePanelFlexBoxStyle.ts +0 -50
- package/src/utils/csp.ts +0 -9
- package/src/utils/cursor.ts +0 -103
- package/src/utils/debounce.ts +0 -18
- package/src/utils/determinePivotIndices.ts +0 -15
- package/src/utils/dom/getPanelElement.ts +0 -10
- package/src/utils/dom/getPanelElementsForGroup.ts +0 -8
- package/src/utils/dom/getPanelGroupElement.ts +0 -21
- package/src/utils/dom/getResizeHandleElement.ts +0 -10
- package/src/utils/dom/getResizeHandleElementIndex.ts +0 -13
- package/src/utils/dom/getResizeHandleElementsForGroup.ts +0 -10
- package/src/utils/dom/getResizeHandlePanelIds.ts +0 -19
- package/src/utils/events/getResizeEventCoordinates.ts +0 -23
- package/src/utils/events/getResizeEventCursorPosition.ts +0 -14
- package/src/utils/events/index.ts +0 -13
- package/src/utils/getInputType.ts +0 -5
- package/src/utils/initializeDefaultStorage.ts +0 -26
- package/src/utils/numbers/fuzzyCompareNumbers.test.ts +0 -16
- package/src/utils/numbers/fuzzyCompareNumbers.ts +0 -21
- package/src/utils/numbers/fuzzyLayoutsEqual.ts +0 -22
- package/src/utils/numbers/fuzzyNumbersEqual.ts +0 -9
- package/src/utils/rects/getIntersectingRectangle.test.ts +0 -198
- package/src/utils/rects/getIntersectingRectangle.ts +0 -28
- package/src/utils/rects/intersects.test.ts +0 -197
- package/src/utils/rects/intersects.ts +0 -23
- package/src/utils/rects/types.ts +0 -6
- package/src/utils/resizePanel.test.ts +0 -59
- package/src/utils/resizePanel.ts +0 -47
- package/src/utils/serialization.ts +0 -87
- package/src/utils/test-utils.ts +0 -205
- package/src/utils/validatePanelConstraints.test.ts +0 -143
- package/src/utils/validatePanelConstraints.ts +0 -69
- package/src/utils/validatePanelGroupLayout.test.ts +0 -148
- package/src/utils/validatePanelGroupLayout.ts +0 -95
- package/src/vendor/react.ts +0 -73
- package/src/vendor/stacking-order.ts +0 -139
|
@@ -24,41 +24,19 @@ 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
|
-
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
49
|
-
|
|
50
27
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
51
28
|
|
|
52
|
-
const PanelGroupContext = createContext(null);
|
|
29
|
+
const PanelGroupContext = React.createContext(null);
|
|
53
30
|
PanelGroupContext.displayName = "PanelGroupContext";
|
|
54
31
|
|
|
55
|
-
const useIsomorphicLayoutEffect =
|
|
32
|
+
const useIsomorphicLayoutEffect = React.useLayoutEffect ;
|
|
56
33
|
|
|
34
|
+
const useId = React__namespace["useId".toString()];
|
|
57
35
|
const wrappedUseId = typeof useId === "function" ? useId : () => null;
|
|
58
36
|
let counter = 0;
|
|
59
37
|
function useUniqueId(idFromParams = null) {
|
|
60
38
|
const idFromUseId = wrappedUseId();
|
|
61
|
-
const idRef = useRef(idFromParams || idFromUseId || null);
|
|
39
|
+
const idRef = React.useRef(idFromParams || idFromUseId || null);
|
|
62
40
|
if (idRef.current === null) {
|
|
63
41
|
idRef.current = "" + counter++;
|
|
64
42
|
}
|
|
@@ -83,7 +61,7 @@ function PanelWithForwardedRef({
|
|
|
83
61
|
tagName: Type = "div",
|
|
84
62
|
...rest
|
|
85
63
|
}) {
|
|
86
|
-
const context = useContext(PanelGroupContext);
|
|
64
|
+
const context = React.useContext(PanelGroupContext);
|
|
87
65
|
if (context === null) {
|
|
88
66
|
throw Error(`Panel components must be rendered within a PanelGroup container`);
|
|
89
67
|
}
|
|
@@ -100,7 +78,7 @@ function PanelWithForwardedRef({
|
|
|
100
78
|
unregisterPanel
|
|
101
79
|
} = context;
|
|
102
80
|
const panelId = useUniqueId(idFromProps);
|
|
103
|
-
const panelDataRef = useRef({
|
|
81
|
+
const panelDataRef = React.useRef({
|
|
104
82
|
callbacks: {
|
|
105
83
|
onCollapse,
|
|
106
84
|
onExpand,
|
|
@@ -117,7 +95,7 @@ function PanelWithForwardedRef({
|
|
|
117
95
|
idIsFromProps: idFromProps !== undefined,
|
|
118
96
|
order
|
|
119
97
|
});
|
|
120
|
-
const devWarningsRef = useRef({
|
|
98
|
+
const devWarningsRef = React.useRef({
|
|
121
99
|
didLogMissingDefaultSizeWarning: false
|
|
122
100
|
});
|
|
123
101
|
|
|
@@ -159,7 +137,7 @@ function PanelWithForwardedRef({
|
|
|
159
137
|
unregisterPanel(panelData);
|
|
160
138
|
};
|
|
161
139
|
}, [order, panelId, registerPanel, unregisterPanel]);
|
|
162
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
140
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
163
141
|
collapse: () => {
|
|
164
142
|
collapsePanel(panelDataRef.current);
|
|
165
143
|
},
|
|
@@ -183,11 +161,11 @@ function PanelWithForwardedRef({
|
|
|
183
161
|
}
|
|
184
162
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
185
163
|
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
186
|
-
return createElement(Type, {
|
|
164
|
+
return React.createElement(Type, {
|
|
187
165
|
...rest,
|
|
188
166
|
children,
|
|
189
167
|
className: classNameFromProps,
|
|
190
|
-
id:
|
|
168
|
+
id: panelId,
|
|
191
169
|
style: {
|
|
192
170
|
...style,
|
|
193
171
|
...styleFromProps
|
|
@@ -200,7 +178,7 @@ function PanelWithForwardedRef({
|
|
|
200
178
|
"data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
|
|
201
179
|
});
|
|
202
180
|
}
|
|
203
|
-
const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
181
|
+
const Panel = React.forwardRef((props, ref) => React.createElement(PanelWithForwardedRef, {
|
|
204
182
|
...props,
|
|
205
183
|
forwardedRef: ref
|
|
206
184
|
}));
|
|
@@ -337,8 +315,8 @@ function intersects(rectOne, rectTwo, strict) {
|
|
|
337
315
|
/**
|
|
338
316
|
* Determine which of two nodes appears in front of the other —
|
|
339
317
|
* if `a` is in front, returns 1, otherwise returns -1
|
|
340
|
-
* @param {HTMLElement} a
|
|
341
|
-
* @param {HTMLElement} b
|
|
318
|
+
* @param {HTMLElement | SVGElement} a
|
|
319
|
+
* @param {HTMLElement | SVGElement} b
|
|
342
320
|
*/
|
|
343
321
|
function compare(a, b) {
|
|
344
322
|
if (a === b) throw new Error("Cannot compare node with itself");
|
|
@@ -376,7 +354,7 @@ function compare(a, b) {
|
|
|
376
354
|
}
|
|
377
355
|
const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
378
356
|
|
|
379
|
-
/** @param {HTMLElement} node */
|
|
357
|
+
/** @param {HTMLElement | SVGElement} node */
|
|
380
358
|
function is_flex_item(node) {
|
|
381
359
|
var _get_parent;
|
|
382
360
|
// @ts-ignore
|
|
@@ -384,7 +362,7 @@ function is_flex_item(node) {
|
|
|
384
362
|
return display === "flex" || display === "inline-flex";
|
|
385
363
|
}
|
|
386
364
|
|
|
387
|
-
/** @param {HTMLElement} node */
|
|
365
|
+
/** @param {HTMLElement | SVGElement} node */
|
|
388
366
|
function creates_stacking_context(node) {
|
|
389
367
|
const style = getComputedStyle(node);
|
|
390
368
|
|
|
@@ -409,7 +387,7 @@ function creates_stacking_context(node) {
|
|
|
409
387
|
return false;
|
|
410
388
|
}
|
|
411
389
|
|
|
412
|
-
/** @param {HTMLElement[]} nodes */
|
|
390
|
+
/** @param {(HTMLElement| SVGElement)[]} nodes */
|
|
413
391
|
function find_stacking_context(nodes) {
|
|
414
392
|
let i = nodes.length;
|
|
415
393
|
while (i--) {
|
|
@@ -420,7 +398,7 @@ function find_stacking_context(nodes) {
|
|
|
420
398
|
return null;
|
|
421
399
|
}
|
|
422
400
|
|
|
423
|
-
/** @param {HTMLElement} node */
|
|
401
|
+
/** @param {HTMLElement | SVGElement} node */
|
|
424
402
|
function get_z_index(node) {
|
|
425
403
|
return node && Number(getComputedStyle(node).zIndex) || 0;
|
|
426
404
|
}
|
|
@@ -582,7 +560,7 @@ function recalculateIntersectingHandles({
|
|
|
582
560
|
}) {
|
|
583
561
|
intersectingHandles.splice(0);
|
|
584
562
|
let targetElement = null;
|
|
585
|
-
if (target instanceof HTMLElement) {
|
|
563
|
+
if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
586
564
|
targetElement = target;
|
|
587
565
|
}
|
|
588
566
|
registeredResizeHandlers.forEach(data => {
|
|
@@ -672,7 +650,9 @@ function updateListeners() {
|
|
|
672
650
|
body
|
|
673
651
|
} = ownerDocument;
|
|
674
652
|
body.removeEventListener("contextmenu", handlePointerUp);
|
|
675
|
-
body.removeEventListener("pointerdown", handlePointerDown
|
|
653
|
+
body.removeEventListener("pointerdown", handlePointerDown, {
|
|
654
|
+
capture: true
|
|
655
|
+
});
|
|
676
656
|
body.removeEventListener("pointerleave", handlePointerMove);
|
|
677
657
|
body.removeEventListener("pointermove", handlePointerMove);
|
|
678
658
|
});
|
|
@@ -720,8 +700,8 @@ function updateResizeHandlerStates(action, event) {
|
|
|
720
700
|
}
|
|
721
701
|
|
|
722
702
|
function useForceUpdate() {
|
|
723
|
-
const [_, setCount] = useState(0);
|
|
724
|
-
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
703
|
+
const [_, setCount] = React.useState(0);
|
|
704
|
+
return React.useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
725
705
|
}
|
|
726
706
|
|
|
727
707
|
function assert(expectedCondition, message) {
|
|
@@ -1134,7 +1114,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1134
1114
|
panelGroupElement,
|
|
1135
1115
|
setLayout
|
|
1136
1116
|
}) {
|
|
1137
|
-
const devWarningsRef = useRef({
|
|
1117
|
+
const devWarningsRef = React.useRef({
|
|
1138
1118
|
didWarnAboutMissingResizeHandle: false
|
|
1139
1119
|
});
|
|
1140
1120
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -1181,7 +1161,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1181
1161
|
});
|
|
1182
1162
|
};
|
|
1183
1163
|
}, [groupId, layout, panelDataArray, panelGroupElement]);
|
|
1184
|
-
useEffect(() => {
|
|
1164
|
+
React.useEffect(() => {
|
|
1185
1165
|
if (!panelGroupElement) {
|
|
1186
1166
|
return;
|
|
1187
1167
|
}
|
|
@@ -1688,14 +1668,14 @@ function PanelGroupWithForwardedRef({
|
|
|
1688
1668
|
...rest
|
|
1689
1669
|
}) {
|
|
1690
1670
|
const groupId = useUniqueId(idFromProps);
|
|
1691
|
-
const panelGroupElementRef = useRef(null);
|
|
1692
|
-
const [dragState, setDragState] = useState(null);
|
|
1693
|
-
const [layout, setLayout] = useState([]);
|
|
1671
|
+
const panelGroupElementRef = React.useRef(null);
|
|
1672
|
+
const [dragState, setDragState] = React.useState(null);
|
|
1673
|
+
const [layout, setLayout] = React.useState([]);
|
|
1694
1674
|
const forceUpdate = useForceUpdate();
|
|
1695
|
-
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1696
|
-
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1697
|
-
const prevDeltaRef = useRef(0);
|
|
1698
|
-
const committedValuesRef = useRef({
|
|
1675
|
+
const panelIdToLastNotifiedSizeMapRef = React.useRef({});
|
|
1676
|
+
const panelSizeBeforeCollapseRef = React.useRef(new Map());
|
|
1677
|
+
const prevDeltaRef = React.useRef(0);
|
|
1678
|
+
const committedValuesRef = React.useRef({
|
|
1699
1679
|
autoSaveId,
|
|
1700
1680
|
direction,
|
|
1701
1681
|
dragState,
|
|
@@ -1704,17 +1684,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1704
1684
|
onLayout,
|
|
1705
1685
|
storage
|
|
1706
1686
|
});
|
|
1707
|
-
const eagerValuesRef = useRef({
|
|
1687
|
+
const eagerValuesRef = React.useRef({
|
|
1708
1688
|
layout,
|
|
1709
1689
|
panelDataArray: [],
|
|
1710
1690
|
panelDataArrayChanged: false
|
|
1711
1691
|
});
|
|
1712
|
-
const devWarningsRef = useRef({
|
|
1692
|
+
const devWarningsRef = React.useRef({
|
|
1713
1693
|
didLogIdAndOrderWarning: false,
|
|
1714
1694
|
didLogPanelConstraintsWarning: false,
|
|
1715
1695
|
prevPanelIds: []
|
|
1716
1696
|
});
|
|
1717
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
1697
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
1718
1698
|
getId: () => committedValuesRef.current.id,
|
|
1719
1699
|
getLayout: () => {
|
|
1720
1700
|
const {
|
|
@@ -1761,7 +1741,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1761
1741
|
setLayout,
|
|
1762
1742
|
panelGroupElement: panelGroupElementRef.current
|
|
1763
1743
|
});
|
|
1764
|
-
useEffect(() => {
|
|
1744
|
+
React.useEffect(() => {
|
|
1765
1745
|
const {
|
|
1766
1746
|
panelDataArray
|
|
1767
1747
|
} = eagerValuesRef.current;
|
|
@@ -1788,7 +1768,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1788
1768
|
}, [autoSaveId, layout, storage]);
|
|
1789
1769
|
|
|
1790
1770
|
// DEV warnings
|
|
1791
|
-
useEffect(() => {
|
|
1771
|
+
React.useEffect(() => {
|
|
1792
1772
|
{
|
|
1793
1773
|
const {
|
|
1794
1774
|
panelDataArray
|
|
@@ -1834,7 +1814,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1834
1814
|
});
|
|
1835
1815
|
|
|
1836
1816
|
// External APIs are safe to memoize via committed values ref
|
|
1837
|
-
const collapsePanel = useCallback(panelData => {
|
|
1817
|
+
const collapsePanel = React.useCallback(panelData => {
|
|
1838
1818
|
const {
|
|
1839
1819
|
onLayout
|
|
1840
1820
|
} = committedValuesRef.current;
|
|
@@ -1877,7 +1857,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1877
1857
|
}, []);
|
|
1878
1858
|
|
|
1879
1859
|
// External APIs are safe to memoize via committed values ref
|
|
1880
|
-
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1860
|
+
const expandPanel = React.useCallback((panelData, minSizeOverride) => {
|
|
1881
1861
|
const {
|
|
1882
1862
|
onLayout
|
|
1883
1863
|
} = committedValuesRef.current;
|
|
@@ -1921,7 +1901,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1921
1901
|
}, []);
|
|
1922
1902
|
|
|
1923
1903
|
// External APIs are safe to memoize via committed values ref
|
|
1924
|
-
const getPanelSize = useCallback(panelData => {
|
|
1904
|
+
const getPanelSize = React.useCallback(panelData => {
|
|
1925
1905
|
const {
|
|
1926
1906
|
layout,
|
|
1927
1907
|
panelDataArray
|
|
@@ -1934,7 +1914,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1934
1914
|
}, []);
|
|
1935
1915
|
|
|
1936
1916
|
// This API should never read from committedValuesRef
|
|
1937
|
-
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1917
|
+
const getPanelStyle = React.useCallback((panelData, defaultSize) => {
|
|
1938
1918
|
const {
|
|
1939
1919
|
panelDataArray
|
|
1940
1920
|
} = eagerValuesRef.current;
|
|
@@ -1949,7 +1929,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1949
1929
|
}, [dragState, layout]);
|
|
1950
1930
|
|
|
1951
1931
|
// External APIs are safe to memoize via committed values ref
|
|
1952
|
-
const isPanelCollapsed = useCallback(panelData => {
|
|
1932
|
+
const isPanelCollapsed = React.useCallback(panelData => {
|
|
1953
1933
|
const {
|
|
1954
1934
|
layout,
|
|
1955
1935
|
panelDataArray
|
|
@@ -1964,7 +1944,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1964
1944
|
}, []);
|
|
1965
1945
|
|
|
1966
1946
|
// External APIs are safe to memoize via committed values ref
|
|
1967
|
-
const isPanelExpanded = useCallback(panelData => {
|
|
1947
|
+
const isPanelExpanded = React.useCallback(panelData => {
|
|
1968
1948
|
const {
|
|
1969
1949
|
layout,
|
|
1970
1950
|
panelDataArray
|
|
@@ -1977,7 +1957,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1977
1957
|
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1978
1958
|
return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
|
|
1979
1959
|
}, []);
|
|
1980
|
-
const registerPanel = useCallback(panelData => {
|
|
1960
|
+
const registerPanel = React.useCallback(panelData => {
|
|
1981
1961
|
const {
|
|
1982
1962
|
panelDataArray
|
|
1983
1963
|
} = eagerValuesRef.current;
|
|
@@ -2054,7 +2034,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2054
2034
|
eagerValues.layout = [];
|
|
2055
2035
|
};
|
|
2056
2036
|
}, []);
|
|
2057
|
-
const registerResizeHandle = useCallback(dragHandleId => {
|
|
2037
|
+
const registerResizeHandle = React.useCallback(dragHandleId => {
|
|
2058
2038
|
let isRTL = false;
|
|
2059
2039
|
const panelGroupElement = panelGroupElementRef.current;
|
|
2060
2040
|
if (panelGroupElement) {
|
|
@@ -2133,7 +2113,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2133
2113
|
}, []);
|
|
2134
2114
|
|
|
2135
2115
|
// External APIs are safe to memoize via committed values ref
|
|
2136
|
-
const resizePanel = useCallback((panelData, unsafePanelSize) => {
|
|
2116
|
+
const resizePanel = React.useCallback((panelData, unsafePanelSize) => {
|
|
2137
2117
|
const {
|
|
2138
2118
|
onLayout
|
|
2139
2119
|
} = committedValuesRef.current;
|
|
@@ -2166,7 +2146,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2166
2146
|
callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
2167
2147
|
}
|
|
2168
2148
|
}, []);
|
|
2169
|
-
const reevaluatePanelConstraints = useCallback((panelData, prevConstraints) => {
|
|
2149
|
+
const reevaluatePanelConstraints = React.useCallback((panelData, prevConstraints) => {
|
|
2170
2150
|
const {
|
|
2171
2151
|
layout,
|
|
2172
2152
|
panelDataArray
|
|
@@ -2200,7 +2180,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2200
2180
|
}, [resizePanel]);
|
|
2201
2181
|
|
|
2202
2182
|
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2203
|
-
const startDragging = useCallback((dragHandleId, event) => {
|
|
2183
|
+
const startDragging = React.useCallback((dragHandleId, event) => {
|
|
2204
2184
|
const {
|
|
2205
2185
|
direction
|
|
2206
2186
|
} = committedValuesRef.current;
|
|
@@ -2220,10 +2200,10 @@ function PanelGroupWithForwardedRef({
|
|
|
2220
2200
|
initialLayout: layout
|
|
2221
2201
|
});
|
|
2222
2202
|
}, []);
|
|
2223
|
-
const stopDragging = useCallback(() => {
|
|
2203
|
+
const stopDragging = React.useCallback(() => {
|
|
2224
2204
|
setDragState(null);
|
|
2225
2205
|
}, []);
|
|
2226
|
-
const unregisterPanel = useCallback(panelData => {
|
|
2206
|
+
const unregisterPanel = React.useCallback(panelData => {
|
|
2227
2207
|
const {
|
|
2228
2208
|
panelDataArray
|
|
2229
2209
|
} = eagerValuesRef.current;
|
|
@@ -2240,7 +2220,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2240
2220
|
forceUpdate();
|
|
2241
2221
|
}
|
|
2242
2222
|
}, [forceUpdate]);
|
|
2243
|
-
const context = useMemo(() => ({
|
|
2223
|
+
const context = React.useMemo(() => ({
|
|
2244
2224
|
collapsePanel,
|
|
2245
2225
|
direction,
|
|
2246
2226
|
dragState,
|
|
@@ -2266,9 +2246,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2266
2246
|
overflow: "hidden",
|
|
2267
2247
|
width: "100%"
|
|
2268
2248
|
};
|
|
2269
|
-
return createElement(PanelGroupContext.Provider, {
|
|
2249
|
+
return React.createElement(PanelGroupContext.Provider, {
|
|
2270
2250
|
value: context
|
|
2271
|
-
}, createElement(Type, {
|
|
2251
|
+
}, React.createElement(Type, {
|
|
2272
2252
|
...rest,
|
|
2273
2253
|
children,
|
|
2274
2254
|
className: classNameFromProps,
|
|
@@ -2284,7 +2264,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2284
2264
|
"data-panel-group-id": groupId
|
|
2285
2265
|
}));
|
|
2286
2266
|
}
|
|
2287
|
-
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
2267
|
+
const PanelGroup = React.forwardRef((props, ref) => React.createElement(PanelGroupWithForwardedRef, {
|
|
2288
2268
|
...props,
|
|
2289
2269
|
forwardedRef: ref
|
|
2290
2270
|
}));
|
|
@@ -2313,7 +2293,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
2313
2293
|
resizeHandler,
|
|
2314
2294
|
panelGroupElement
|
|
2315
2295
|
}) {
|
|
2316
|
-
useEffect(() => {
|
|
2296
|
+
React.useEffect(() => {
|
|
2317
2297
|
if (disabled || resizeHandler == null || panelGroupElement == null) {
|
|
2318
2298
|
return;
|
|
2319
2299
|
}
|
|
@@ -2366,24 +2346,33 @@ function PanelResizeHandle({
|
|
|
2366
2346
|
hitAreaMargins,
|
|
2367
2347
|
id: idFromProps,
|
|
2368
2348
|
onBlur,
|
|
2349
|
+
onClick,
|
|
2369
2350
|
onDragging,
|
|
2370
2351
|
onFocus,
|
|
2352
|
+
onPointerDown,
|
|
2353
|
+
onPointerUp,
|
|
2371
2354
|
style: styleFromProps = {},
|
|
2372
2355
|
tabIndex = 0,
|
|
2373
2356
|
tagName: Type = "div",
|
|
2374
2357
|
...rest
|
|
2375
2358
|
}) {
|
|
2376
2359
|
var _hitAreaMargins$coars, _hitAreaMargins$fine;
|
|
2377
|
-
const elementRef = useRef(null);
|
|
2360
|
+
const elementRef = React.useRef(null);
|
|
2378
2361
|
|
|
2379
2362
|
// Use a ref to guard against users passing inline props
|
|
2380
|
-
const callbacksRef = useRef({
|
|
2381
|
-
|
|
2363
|
+
const callbacksRef = React.useRef({
|
|
2364
|
+
onClick,
|
|
2365
|
+
onDragging,
|
|
2366
|
+
onPointerDown,
|
|
2367
|
+
onPointerUp
|
|
2382
2368
|
});
|
|
2383
|
-
useEffect(() => {
|
|
2369
|
+
React.useEffect(() => {
|
|
2370
|
+
callbacksRef.current.onClick = onClick;
|
|
2384
2371
|
callbacksRef.current.onDragging = onDragging;
|
|
2372
|
+
callbacksRef.current.onPointerDown = onPointerDown;
|
|
2373
|
+
callbacksRef.current.onPointerUp = onPointerUp;
|
|
2385
2374
|
});
|
|
2386
|
-
const panelGroupContext = useContext(PanelGroupContext);
|
|
2375
|
+
const panelGroupContext = React.useContext(PanelGroupContext);
|
|
2387
2376
|
if (panelGroupContext === null) {
|
|
2388
2377
|
throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
|
|
2389
2378
|
}
|
|
@@ -2396,16 +2385,16 @@ function PanelResizeHandle({
|
|
|
2396
2385
|
panelGroupElement
|
|
2397
2386
|
} = panelGroupContext;
|
|
2398
2387
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
2399
|
-
const [state, setState] = useState("inactive");
|
|
2400
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
2401
|
-
const [resizeHandler, setResizeHandler] = useState(null);
|
|
2402
|
-
const committedValuesRef = useRef({
|
|
2388
|
+
const [state, setState] = React.useState("inactive");
|
|
2389
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
2390
|
+
const [resizeHandler, setResizeHandler] = React.useState(null);
|
|
2391
|
+
const committedValuesRef = React.useRef({
|
|
2403
2392
|
state
|
|
2404
2393
|
});
|
|
2405
2394
|
useIsomorphicLayoutEffect(() => {
|
|
2406
2395
|
committedValuesRef.current.state = state;
|
|
2407
2396
|
});
|
|
2408
|
-
useEffect(() => {
|
|
2397
|
+
React.useEffect(() => {
|
|
2409
2398
|
if (disabled) {
|
|
2410
2399
|
setResizeHandler(null);
|
|
2411
2400
|
} else {
|
|
@@ -2418,26 +2407,28 @@ function PanelResizeHandle({
|
|
|
2418
2407
|
// so that inline object values won't trigger re-renders
|
|
2419
2408
|
const coarseHitAreaMargins = (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15;
|
|
2420
2409
|
const fineHitAreaMargins = (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5;
|
|
2421
|
-
useEffect(() => {
|
|
2410
|
+
React.useEffect(() => {
|
|
2422
2411
|
if (disabled || resizeHandler == null) {
|
|
2423
2412
|
return;
|
|
2424
2413
|
}
|
|
2425
2414
|
const element = elementRef.current;
|
|
2426
2415
|
assert(element, "Element ref not attached");
|
|
2416
|
+
let didMove = false;
|
|
2427
2417
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2428
2418
|
if (isActive) {
|
|
2429
2419
|
switch (action) {
|
|
2430
2420
|
case "down":
|
|
2431
2421
|
{
|
|
2432
2422
|
setState("drag");
|
|
2423
|
+
didMove = false;
|
|
2433
2424
|
assert(event, 'Expected event to be defined for "down" action');
|
|
2434
2425
|
startDragging(resizeHandleId, event);
|
|
2435
2426
|
const {
|
|
2436
|
-
onDragging
|
|
2427
|
+
onDragging,
|
|
2428
|
+
onPointerDown
|
|
2437
2429
|
} = callbacksRef.current;
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
}
|
|
2430
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
|
|
2431
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
|
|
2441
2432
|
break;
|
|
2442
2433
|
}
|
|
2443
2434
|
case "move":
|
|
@@ -2445,6 +2436,7 @@ function PanelResizeHandle({
|
|
|
2445
2436
|
const {
|
|
2446
2437
|
state
|
|
2447
2438
|
} = committedValuesRef.current;
|
|
2439
|
+
didMove = true;
|
|
2448
2440
|
if (state !== "drag") {
|
|
2449
2441
|
setState("hover");
|
|
2450
2442
|
}
|
|
@@ -2457,10 +2449,14 @@ function PanelResizeHandle({
|
|
|
2457
2449
|
setState("hover");
|
|
2458
2450
|
stopDragging();
|
|
2459
2451
|
const {
|
|
2460
|
-
|
|
2452
|
+
onClick,
|
|
2453
|
+
onDragging,
|
|
2454
|
+
onPointerUp
|
|
2461
2455
|
} = callbacksRef.current;
|
|
2462
|
-
|
|
2463
|
-
|
|
2456
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
|
|
2457
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
2458
|
+
if (!didMove) {
|
|
2459
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
2464
2460
|
}
|
|
2465
2461
|
break;
|
|
2466
2462
|
}
|
|
@@ -2484,7 +2480,7 @@ function PanelResizeHandle({
|
|
|
2484
2480
|
touchAction: "none",
|
|
2485
2481
|
userSelect: "none"
|
|
2486
2482
|
};
|
|
2487
|
-
return createElement(Type, {
|
|
2483
|
+
return React.createElement(Type, {
|
|
2488
2484
|
...rest,
|
|
2489
2485
|
children,
|
|
2490
2486
|
className: classNameFromProps,
|