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
package/README.md
CHANGED
|
@@ -175,6 +175,10 @@ This likely means that you haven't applied any CSS to style the resize handles.
|
|
|
175
175
|
<PanelResizeHandle className="w-2 bg-blue-800" />
|
|
176
176
|
```
|
|
177
177
|
|
|
178
|
+
### Can panel sizes be persistent?
|
|
179
|
+
|
|
180
|
+
Yes. Panel groups with an `autoSaveId` prop will automatically save and restore their layouts on mount.
|
|
181
|
+
|
|
178
182
|
### How can I use persistent layouts with SSR?
|
|
179
183
|
|
|
180
184
|
By default, this library uses `localStorage` to persist layouts. With server rendering, this can cause a flicker when the default layout (rendered on the server) is replaced with the persisted layout (in `localStorage`). The way to avoid this flicker is to also persist the layout with a cookie like so:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ForwardedRef, HTMLAttributes, PropsWithChildren, ReactElement } from "
|
|
1
|
+
import { ForwardedRef, HTMLAttributes, PropsWithChildren, ReactElement } from "react";
|
|
2
2
|
export type PanelOnCollapse = () => void;
|
|
3
3
|
export type PanelOnExpand = () => void;
|
|
4
4
|
export type PanelOnResize = (size: number, prevSize: number | undefined) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Direction } from "./types.js";
|
|
2
|
-
import { CSSProperties, HTMLAttributes, PropsWithChildren } from "
|
|
2
|
+
import { CSSProperties, HTMLAttributes, PropsWithChildren } from "react";
|
|
3
3
|
export type ImperativePanelGroupHandle = {
|
|
4
4
|
getId: () => string;
|
|
5
5
|
getLayout: () => number[];
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { PointerHitAreaMargins } from "./PanelResizeHandleRegistry.js";
|
|
2
|
-
import { CSSProperties, HTMLAttributes, PropsWithChildren, ReactElement } from "
|
|
2
|
+
import { CSSProperties, HTMLAttributes, PropsWithChildren, ReactElement } from "react";
|
|
3
3
|
export type PanelResizeHandleOnDragging = (isDragging: boolean) => void;
|
|
4
4
|
export type ResizeHandlerState = "drag" | "hover" | "inactive";
|
|
5
|
-
export type PanelResizeHandleProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id" | "onBlur" | "onFocus"> & PropsWithChildren<{
|
|
5
|
+
export type PanelResizeHandleProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id" | "onBlur" | "onClick" | "onFocus" | "onPointerDown" | "onPointerUp"> & PropsWithChildren<{
|
|
6
6
|
className?: string;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
hitAreaMargins?: PointerHitAreaMargins;
|
|
9
9
|
id?: string | null;
|
|
10
10
|
onBlur?: () => void;
|
|
11
|
+
onClick?: () => void;
|
|
11
12
|
onDragging?: PanelResizeHandleOnDragging;
|
|
12
13
|
onFocus?: () => void;
|
|
14
|
+
onPointerDown?: () => void;
|
|
15
|
+
onPointerUp?: () => void;
|
|
13
16
|
style?: CSSProperties;
|
|
14
17
|
tabIndex?: number;
|
|
15
18
|
tagName?: keyof HTMLElementTagNameMap;
|
|
16
19
|
}>;
|
|
17
|
-
export declare function PanelResizeHandle({ children, className: classNameFromProps, disabled, hitAreaMargins, id: idFromProps, onBlur, onDragging, onFocus, style: styleFromProps, tabIndex, tagName: Type, ...rest }: PanelResizeHandleProps): ReactElement;
|
|
20
|
+
export declare function PanelResizeHandle({ children, className: classNameFromProps, disabled, hitAreaMargins, id: idFromProps, onBlur, onClick, onDragging, onFocus, onPointerDown, onPointerUp, style: styleFromProps, tabIndex, tagName: Type, ...rest }: PanelResizeHandleProps): ReactElement;
|
|
18
21
|
export declare namespace PanelResizeHandle {
|
|
19
22
|
var displayName: string;
|
|
20
23
|
}
|
|
@@ -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
|
-
useRef({
|
|
98
|
+
React.useRef({
|
|
121
99
|
didLogMissingDefaultSizeWarning: false
|
|
122
100
|
});
|
|
123
101
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -153,7 +131,7 @@ function PanelWithForwardedRef({
|
|
|
153
131
|
unregisterPanel(panelData);
|
|
154
132
|
};
|
|
155
133
|
}, [order, panelId, registerPanel, unregisterPanel]);
|
|
156
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
134
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
157
135
|
collapse: () => {
|
|
158
136
|
collapsePanel(panelDataRef.current);
|
|
159
137
|
},
|
|
@@ -177,11 +155,11 @@ function PanelWithForwardedRef({
|
|
|
177
155
|
}
|
|
178
156
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
179
157
|
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
180
|
-
return createElement(Type, {
|
|
158
|
+
return React.createElement(Type, {
|
|
181
159
|
...rest,
|
|
182
160
|
children,
|
|
183
161
|
className: classNameFromProps,
|
|
184
|
-
id:
|
|
162
|
+
id: panelId,
|
|
185
163
|
style: {
|
|
186
164
|
...style,
|
|
187
165
|
...styleFromProps
|
|
@@ -194,7 +172,7 @@ function PanelWithForwardedRef({
|
|
|
194
172
|
"data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
|
|
195
173
|
});
|
|
196
174
|
}
|
|
197
|
-
const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
175
|
+
const Panel = React.forwardRef((props, ref) => React.createElement(PanelWithForwardedRef, {
|
|
198
176
|
...props,
|
|
199
177
|
forwardedRef: ref
|
|
200
178
|
}));
|
|
@@ -666,7 +644,9 @@ function updateListeners() {
|
|
|
666
644
|
body
|
|
667
645
|
} = ownerDocument;
|
|
668
646
|
body.removeEventListener("contextmenu", handlePointerUp);
|
|
669
|
-
body.removeEventListener("pointerdown", handlePointerDown
|
|
647
|
+
body.removeEventListener("pointerdown", handlePointerDown, {
|
|
648
|
+
capture: true
|
|
649
|
+
});
|
|
670
650
|
body.removeEventListener("pointerleave", handlePointerMove);
|
|
671
651
|
body.removeEventListener("pointermove", handlePointerMove);
|
|
672
652
|
});
|
|
@@ -714,8 +694,8 @@ function updateResizeHandlerStates(action, event) {
|
|
|
714
694
|
}
|
|
715
695
|
|
|
716
696
|
function useForceUpdate() {
|
|
717
|
-
const [_, setCount] = useState(0);
|
|
718
|
-
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
697
|
+
const [_, setCount] = React.useState(0);
|
|
698
|
+
return React.useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
719
699
|
}
|
|
720
700
|
|
|
721
701
|
function assert(expectedCondition, message) {
|
|
@@ -1128,7 +1108,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1128
1108
|
panelGroupElement,
|
|
1129
1109
|
setLayout
|
|
1130
1110
|
}) {
|
|
1131
|
-
useRef({
|
|
1111
|
+
React.useRef({
|
|
1132
1112
|
didWarnAboutMissingResizeHandle: false
|
|
1133
1113
|
});
|
|
1134
1114
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -1165,7 +1145,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1165
1145
|
});
|
|
1166
1146
|
};
|
|
1167
1147
|
}, [groupId, layout, panelDataArray, panelGroupElement]);
|
|
1168
|
-
useEffect(() => {
|
|
1148
|
+
React.useEffect(() => {
|
|
1169
1149
|
if (!panelGroupElement) {
|
|
1170
1150
|
return;
|
|
1171
1151
|
}
|
|
@@ -1624,14 +1604,14 @@ function PanelGroupWithForwardedRef({
|
|
|
1624
1604
|
...rest
|
|
1625
1605
|
}) {
|
|
1626
1606
|
const groupId = useUniqueId(idFromProps);
|
|
1627
|
-
const panelGroupElementRef = useRef(null);
|
|
1628
|
-
const [dragState, setDragState] = useState(null);
|
|
1629
|
-
const [layout, setLayout] = useState([]);
|
|
1607
|
+
const panelGroupElementRef = React.useRef(null);
|
|
1608
|
+
const [dragState, setDragState] = React.useState(null);
|
|
1609
|
+
const [layout, setLayout] = React.useState([]);
|
|
1630
1610
|
const forceUpdate = useForceUpdate();
|
|
1631
|
-
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1632
|
-
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1633
|
-
const prevDeltaRef = useRef(0);
|
|
1634
|
-
const committedValuesRef = useRef({
|
|
1611
|
+
const panelIdToLastNotifiedSizeMapRef = React.useRef({});
|
|
1612
|
+
const panelSizeBeforeCollapseRef = React.useRef(new Map());
|
|
1613
|
+
const prevDeltaRef = React.useRef(0);
|
|
1614
|
+
const committedValuesRef = React.useRef({
|
|
1635
1615
|
autoSaveId,
|
|
1636
1616
|
direction,
|
|
1637
1617
|
dragState,
|
|
@@ -1640,17 +1620,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1640
1620
|
onLayout,
|
|
1641
1621
|
storage
|
|
1642
1622
|
});
|
|
1643
|
-
const eagerValuesRef = useRef({
|
|
1623
|
+
const eagerValuesRef = React.useRef({
|
|
1644
1624
|
layout,
|
|
1645
1625
|
panelDataArray: [],
|
|
1646
1626
|
panelDataArrayChanged: false
|
|
1647
1627
|
});
|
|
1648
|
-
useRef({
|
|
1628
|
+
React.useRef({
|
|
1649
1629
|
didLogIdAndOrderWarning: false,
|
|
1650
1630
|
didLogPanelConstraintsWarning: false,
|
|
1651
1631
|
prevPanelIds: []
|
|
1652
1632
|
});
|
|
1653
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
1633
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
1654
1634
|
getId: () => committedValuesRef.current.id,
|
|
1655
1635
|
getLayout: () => {
|
|
1656
1636
|
const {
|
|
@@ -1697,7 +1677,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1697
1677
|
setLayout,
|
|
1698
1678
|
panelGroupElement: panelGroupElementRef.current
|
|
1699
1679
|
});
|
|
1700
|
-
useEffect(() => {
|
|
1680
|
+
React.useEffect(() => {
|
|
1701
1681
|
const {
|
|
1702
1682
|
panelDataArray
|
|
1703
1683
|
} = eagerValuesRef.current;
|
|
@@ -1724,11 +1704,11 @@ function PanelGroupWithForwardedRef({
|
|
|
1724
1704
|
}, [autoSaveId, layout, storage]);
|
|
1725
1705
|
|
|
1726
1706
|
// DEV warnings
|
|
1727
|
-
useEffect(() => {
|
|
1707
|
+
React.useEffect(() => {
|
|
1728
1708
|
});
|
|
1729
1709
|
|
|
1730
1710
|
// External APIs are safe to memoize via committed values ref
|
|
1731
|
-
const collapsePanel = useCallback(panelData => {
|
|
1711
|
+
const collapsePanel = React.useCallback(panelData => {
|
|
1732
1712
|
const {
|
|
1733
1713
|
onLayout
|
|
1734
1714
|
} = committedValuesRef.current;
|
|
@@ -1771,7 +1751,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1771
1751
|
}, []);
|
|
1772
1752
|
|
|
1773
1753
|
// External APIs are safe to memoize via committed values ref
|
|
1774
|
-
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1754
|
+
const expandPanel = React.useCallback((panelData, minSizeOverride) => {
|
|
1775
1755
|
const {
|
|
1776
1756
|
onLayout
|
|
1777
1757
|
} = committedValuesRef.current;
|
|
@@ -1815,7 +1795,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1815
1795
|
}, []);
|
|
1816
1796
|
|
|
1817
1797
|
// External APIs are safe to memoize via committed values ref
|
|
1818
|
-
const getPanelSize = useCallback(panelData => {
|
|
1798
|
+
const getPanelSize = React.useCallback(panelData => {
|
|
1819
1799
|
const {
|
|
1820
1800
|
layout,
|
|
1821
1801
|
panelDataArray
|
|
@@ -1828,7 +1808,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1828
1808
|
}, []);
|
|
1829
1809
|
|
|
1830
1810
|
// This API should never read from committedValuesRef
|
|
1831
|
-
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1811
|
+
const getPanelStyle = React.useCallback((panelData, defaultSize) => {
|
|
1832
1812
|
const {
|
|
1833
1813
|
panelDataArray
|
|
1834
1814
|
} = eagerValuesRef.current;
|
|
@@ -1843,7 +1823,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1843
1823
|
}, [dragState, layout]);
|
|
1844
1824
|
|
|
1845
1825
|
// External APIs are safe to memoize via committed values ref
|
|
1846
|
-
const isPanelCollapsed = useCallback(panelData => {
|
|
1826
|
+
const isPanelCollapsed = React.useCallback(panelData => {
|
|
1847
1827
|
const {
|
|
1848
1828
|
layout,
|
|
1849
1829
|
panelDataArray
|
|
@@ -1858,7 +1838,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1858
1838
|
}, []);
|
|
1859
1839
|
|
|
1860
1840
|
// External APIs are safe to memoize via committed values ref
|
|
1861
|
-
const isPanelExpanded = useCallback(panelData => {
|
|
1841
|
+
const isPanelExpanded = React.useCallback(panelData => {
|
|
1862
1842
|
const {
|
|
1863
1843
|
layout,
|
|
1864
1844
|
panelDataArray
|
|
@@ -1871,7 +1851,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1871
1851
|
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1872
1852
|
return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
|
|
1873
1853
|
}, []);
|
|
1874
|
-
const registerPanel = useCallback(panelData => {
|
|
1854
|
+
const registerPanel = React.useCallback(panelData => {
|
|
1875
1855
|
const {
|
|
1876
1856
|
panelDataArray
|
|
1877
1857
|
} = eagerValuesRef.current;
|
|
@@ -1948,7 +1928,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1948
1928
|
eagerValues.layout = [];
|
|
1949
1929
|
};
|
|
1950
1930
|
}, []);
|
|
1951
|
-
const registerResizeHandle = useCallback(dragHandleId => {
|
|
1931
|
+
const registerResizeHandle = React.useCallback(dragHandleId => {
|
|
1952
1932
|
let isRTL = false;
|
|
1953
1933
|
const panelGroupElement = panelGroupElementRef.current;
|
|
1954
1934
|
if (panelGroupElement) {
|
|
@@ -2027,7 +2007,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2027
2007
|
}, []);
|
|
2028
2008
|
|
|
2029
2009
|
// External APIs are safe to memoize via committed values ref
|
|
2030
|
-
const resizePanel = useCallback((panelData, unsafePanelSize) => {
|
|
2010
|
+
const resizePanel = React.useCallback((panelData, unsafePanelSize) => {
|
|
2031
2011
|
const {
|
|
2032
2012
|
onLayout
|
|
2033
2013
|
} = committedValuesRef.current;
|
|
@@ -2060,7 +2040,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2060
2040
|
callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
2061
2041
|
}
|
|
2062
2042
|
}, []);
|
|
2063
|
-
const reevaluatePanelConstraints = useCallback((panelData, prevConstraints) => {
|
|
2043
|
+
const reevaluatePanelConstraints = React.useCallback((panelData, prevConstraints) => {
|
|
2064
2044
|
const {
|
|
2065
2045
|
layout,
|
|
2066
2046
|
panelDataArray
|
|
@@ -2094,7 +2074,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2094
2074
|
}, [resizePanel]);
|
|
2095
2075
|
|
|
2096
2076
|
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2097
|
-
const startDragging = useCallback((dragHandleId, event) => {
|
|
2077
|
+
const startDragging = React.useCallback((dragHandleId, event) => {
|
|
2098
2078
|
const {
|
|
2099
2079
|
direction
|
|
2100
2080
|
} = committedValuesRef.current;
|
|
@@ -2114,10 +2094,10 @@ function PanelGroupWithForwardedRef({
|
|
|
2114
2094
|
initialLayout: layout
|
|
2115
2095
|
});
|
|
2116
2096
|
}, []);
|
|
2117
|
-
const stopDragging = useCallback(() => {
|
|
2097
|
+
const stopDragging = React.useCallback(() => {
|
|
2118
2098
|
setDragState(null);
|
|
2119
2099
|
}, []);
|
|
2120
|
-
const unregisterPanel = useCallback(panelData => {
|
|
2100
|
+
const unregisterPanel = React.useCallback(panelData => {
|
|
2121
2101
|
const {
|
|
2122
2102
|
panelDataArray
|
|
2123
2103
|
} = eagerValuesRef.current;
|
|
@@ -2134,7 +2114,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2134
2114
|
forceUpdate();
|
|
2135
2115
|
}
|
|
2136
2116
|
}, [forceUpdate]);
|
|
2137
|
-
const context = useMemo(() => ({
|
|
2117
|
+
const context = React.useMemo(() => ({
|
|
2138
2118
|
collapsePanel,
|
|
2139
2119
|
direction,
|
|
2140
2120
|
dragState,
|
|
@@ -2160,9 +2140,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2160
2140
|
overflow: "hidden",
|
|
2161
2141
|
width: "100%"
|
|
2162
2142
|
};
|
|
2163
|
-
return createElement(PanelGroupContext.Provider, {
|
|
2143
|
+
return React.createElement(PanelGroupContext.Provider, {
|
|
2164
2144
|
value: context
|
|
2165
|
-
}, createElement(Type, {
|
|
2145
|
+
}, React.createElement(Type, {
|
|
2166
2146
|
...rest,
|
|
2167
2147
|
children,
|
|
2168
2148
|
className: classNameFromProps,
|
|
@@ -2178,7 +2158,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2178
2158
|
"data-panel-group-id": groupId
|
|
2179
2159
|
}));
|
|
2180
2160
|
}
|
|
2181
|
-
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
2161
|
+
const PanelGroup = React.forwardRef((props, ref) => React.createElement(PanelGroupWithForwardedRef, {
|
|
2182
2162
|
...props,
|
|
2183
2163
|
forwardedRef: ref
|
|
2184
2164
|
}));
|
|
@@ -2207,7 +2187,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
2207
2187
|
resizeHandler,
|
|
2208
2188
|
panelGroupElement
|
|
2209
2189
|
}) {
|
|
2210
|
-
useEffect(() => {
|
|
2190
|
+
React.useEffect(() => {
|
|
2211
2191
|
if (disabled || resizeHandler == null || panelGroupElement == null) {
|
|
2212
2192
|
return;
|
|
2213
2193
|
}
|
|
@@ -2260,24 +2240,33 @@ function PanelResizeHandle({
|
|
|
2260
2240
|
hitAreaMargins,
|
|
2261
2241
|
id: idFromProps,
|
|
2262
2242
|
onBlur,
|
|
2243
|
+
onClick,
|
|
2263
2244
|
onDragging,
|
|
2264
2245
|
onFocus,
|
|
2246
|
+
onPointerDown,
|
|
2247
|
+
onPointerUp,
|
|
2265
2248
|
style: styleFromProps = {},
|
|
2266
2249
|
tabIndex = 0,
|
|
2267
2250
|
tagName: Type = "div",
|
|
2268
2251
|
...rest
|
|
2269
2252
|
}) {
|
|
2270
2253
|
var _hitAreaMargins$coars, _hitAreaMargins$fine;
|
|
2271
|
-
const elementRef = useRef(null);
|
|
2254
|
+
const elementRef = React.useRef(null);
|
|
2272
2255
|
|
|
2273
2256
|
// Use a ref to guard against users passing inline props
|
|
2274
|
-
const callbacksRef = useRef({
|
|
2275
|
-
|
|
2257
|
+
const callbacksRef = React.useRef({
|
|
2258
|
+
onClick,
|
|
2259
|
+
onDragging,
|
|
2260
|
+
onPointerDown,
|
|
2261
|
+
onPointerUp
|
|
2276
2262
|
});
|
|
2277
|
-
useEffect(() => {
|
|
2263
|
+
React.useEffect(() => {
|
|
2264
|
+
callbacksRef.current.onClick = onClick;
|
|
2278
2265
|
callbacksRef.current.onDragging = onDragging;
|
|
2266
|
+
callbacksRef.current.onPointerDown = onPointerDown;
|
|
2267
|
+
callbacksRef.current.onPointerUp = onPointerUp;
|
|
2279
2268
|
});
|
|
2280
|
-
const panelGroupContext = useContext(PanelGroupContext);
|
|
2269
|
+
const panelGroupContext = React.useContext(PanelGroupContext);
|
|
2281
2270
|
if (panelGroupContext === null) {
|
|
2282
2271
|
throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
|
|
2283
2272
|
}
|
|
@@ -2290,16 +2279,16 @@ function PanelResizeHandle({
|
|
|
2290
2279
|
panelGroupElement
|
|
2291
2280
|
} = panelGroupContext;
|
|
2292
2281
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
2293
|
-
const [state, setState] = useState("inactive");
|
|
2294
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
2295
|
-
const [resizeHandler, setResizeHandler] = useState(null);
|
|
2296
|
-
const committedValuesRef = useRef({
|
|
2282
|
+
const [state, setState] = React.useState("inactive");
|
|
2283
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
2284
|
+
const [resizeHandler, setResizeHandler] = React.useState(null);
|
|
2285
|
+
const committedValuesRef = React.useRef({
|
|
2297
2286
|
state
|
|
2298
2287
|
});
|
|
2299
2288
|
useIsomorphicLayoutEffect(() => {
|
|
2300
2289
|
committedValuesRef.current.state = state;
|
|
2301
2290
|
});
|
|
2302
|
-
useEffect(() => {
|
|
2291
|
+
React.useEffect(() => {
|
|
2303
2292
|
if (disabled) {
|
|
2304
2293
|
setResizeHandler(null);
|
|
2305
2294
|
} else {
|
|
@@ -2312,26 +2301,28 @@ function PanelResizeHandle({
|
|
|
2312
2301
|
// so that inline object values won't trigger re-renders
|
|
2313
2302
|
const coarseHitAreaMargins = (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15;
|
|
2314
2303
|
const fineHitAreaMargins = (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5;
|
|
2315
|
-
useEffect(() => {
|
|
2304
|
+
React.useEffect(() => {
|
|
2316
2305
|
if (disabled || resizeHandler == null) {
|
|
2317
2306
|
return;
|
|
2318
2307
|
}
|
|
2319
2308
|
const element = elementRef.current;
|
|
2320
2309
|
assert(element, "Element ref not attached");
|
|
2310
|
+
let didMove = false;
|
|
2321
2311
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2322
2312
|
if (isActive) {
|
|
2323
2313
|
switch (action) {
|
|
2324
2314
|
case "down":
|
|
2325
2315
|
{
|
|
2326
2316
|
setState("drag");
|
|
2317
|
+
didMove = false;
|
|
2327
2318
|
assert(event, 'Expected event to be defined for "down" action');
|
|
2328
2319
|
startDragging(resizeHandleId, event);
|
|
2329
2320
|
const {
|
|
2330
|
-
onDragging
|
|
2321
|
+
onDragging,
|
|
2322
|
+
onPointerDown
|
|
2331
2323
|
} = callbacksRef.current;
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
}
|
|
2324
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
|
|
2325
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
|
|
2335
2326
|
break;
|
|
2336
2327
|
}
|
|
2337
2328
|
case "move":
|
|
@@ -2339,6 +2330,7 @@ function PanelResizeHandle({
|
|
|
2339
2330
|
const {
|
|
2340
2331
|
state
|
|
2341
2332
|
} = committedValuesRef.current;
|
|
2333
|
+
didMove = true;
|
|
2342
2334
|
if (state !== "drag") {
|
|
2343
2335
|
setState("hover");
|
|
2344
2336
|
}
|
|
@@ -2351,10 +2343,14 @@ function PanelResizeHandle({
|
|
|
2351
2343
|
setState("hover");
|
|
2352
2344
|
stopDragging();
|
|
2353
2345
|
const {
|
|
2354
|
-
|
|
2346
|
+
onClick,
|
|
2347
|
+
onDragging,
|
|
2348
|
+
onPointerUp
|
|
2355
2349
|
} = callbacksRef.current;
|
|
2356
|
-
|
|
2357
|
-
|
|
2350
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
|
|
2351
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
2352
|
+
if (!didMove) {
|
|
2353
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
2358
2354
|
}
|
|
2359
2355
|
break;
|
|
2360
2356
|
}
|
|
@@ -2378,7 +2374,7 @@ function PanelResizeHandle({
|
|
|
2378
2374
|
touchAction: "none",
|
|
2379
2375
|
userSelect: "none"
|
|
2380
2376
|
};
|
|
2381
|
-
return createElement(Type, {
|
|
2377
|
+
return React.createElement(Type, {
|
|
2382
2378
|
...rest,
|
|
2383
2379
|
children,
|
|
2384
2380
|
className: classNameFromProps,
|