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
|
@@ -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
|
}));
|
|
@@ -344,8 +322,8 @@ function intersects(rectOne, rectTwo, strict) {
|
|
|
344
322
|
/**
|
|
345
323
|
* Determine which of two nodes appears in front of the other —
|
|
346
324
|
* if `a` is in front, returns 1, otherwise returns -1
|
|
347
|
-
* @param {HTMLElement} a
|
|
348
|
-
* @param {HTMLElement} b
|
|
325
|
+
* @param {HTMLElement | SVGElement} a
|
|
326
|
+
* @param {HTMLElement | SVGElement} b
|
|
349
327
|
*/
|
|
350
328
|
function compare(a, b) {
|
|
351
329
|
if (a === b) throw new Error("Cannot compare node with itself");
|
|
@@ -383,7 +361,7 @@ function compare(a, b) {
|
|
|
383
361
|
}
|
|
384
362
|
const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
385
363
|
|
|
386
|
-
/** @param {HTMLElement} node */
|
|
364
|
+
/** @param {HTMLElement | SVGElement} node */
|
|
387
365
|
function is_flex_item(node) {
|
|
388
366
|
var _get_parent;
|
|
389
367
|
// @ts-ignore
|
|
@@ -391,7 +369,7 @@ function is_flex_item(node) {
|
|
|
391
369
|
return display === "flex" || display === "inline-flex";
|
|
392
370
|
}
|
|
393
371
|
|
|
394
|
-
/** @param {HTMLElement} node */
|
|
372
|
+
/** @param {HTMLElement | SVGElement} node */
|
|
395
373
|
function creates_stacking_context(node) {
|
|
396
374
|
const style = getComputedStyle(node);
|
|
397
375
|
|
|
@@ -416,7 +394,7 @@ function creates_stacking_context(node) {
|
|
|
416
394
|
return false;
|
|
417
395
|
}
|
|
418
396
|
|
|
419
|
-
/** @param {HTMLElement[]} nodes */
|
|
397
|
+
/** @param {(HTMLElement| SVGElement)[]} nodes */
|
|
420
398
|
function find_stacking_context(nodes) {
|
|
421
399
|
let i = nodes.length;
|
|
422
400
|
while (i--) {
|
|
@@ -427,7 +405,7 @@ function find_stacking_context(nodes) {
|
|
|
427
405
|
return null;
|
|
428
406
|
}
|
|
429
407
|
|
|
430
|
-
/** @param {HTMLElement} node */
|
|
408
|
+
/** @param {HTMLElement | SVGElement} node */
|
|
431
409
|
function get_z_index(node) {
|
|
432
410
|
return node && Number(getComputedStyle(node).zIndex) || 0;
|
|
433
411
|
}
|
|
@@ -589,7 +567,7 @@ function recalculateIntersectingHandles({
|
|
|
589
567
|
}) {
|
|
590
568
|
intersectingHandles.splice(0);
|
|
591
569
|
let targetElement = null;
|
|
592
|
-
if (target instanceof HTMLElement) {
|
|
570
|
+
if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
593
571
|
targetElement = target;
|
|
594
572
|
}
|
|
595
573
|
registeredResizeHandlers.forEach(data => {
|
|
@@ -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,
|