react-resizable-panels 2.0.18 → 2.0.20
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/CHANGELOG.md +9 -0
- package/README.md +3 -0
- package/dist/declarations/src/Panel.d.ts +1 -1
- package/dist/declarations/src/PanelResizeHandle.d.ts +5 -3
- package/dist/declarations/src/index.d.ts +2 -1
- package/dist/react-resizable-panels.browser.cjs.js +25 -6
- package/dist/react-resizable-panels.browser.development.cjs.js +25 -6
- package/dist/react-resizable-panels.browser.development.esm.js +25 -6
- package/dist/react-resizable-panels.browser.esm.js +25 -6
- package/dist/react-resizable-panels.cjs.js +25 -6
- package/dist/react-resizable-panels.development.cjs.js +25 -6
- package/dist/react-resizable-panels.development.esm.js +25 -6
- package/dist/react-resizable-panels.development.node.cjs.js +25 -6
- package/dist/react-resizable-panels.development.node.esm.js +25 -6
- package/dist/react-resizable-panels.esm.js +25 -6
- package/dist/react-resizable-panels.node.cjs.js +25 -6
- package/dist/react-resizable-panels.node.esm.js +25 -6
- package/package.json +1 -1
- package/src/Panel.test.tsx +105 -0
- package/src/Panel.ts +3 -3
- package/src/PanelGroup.ts +54 -47
- package/src/PanelGroupContext.ts +1 -1
- package/src/PanelResizeHandle.test.tsx +42 -2
- package/src/PanelResizeHandle.ts +25 -16
- package/src/PanelResizeHandleRegistry.ts +11 -0
- package/src/index.ts +2 -0
package/src/PanelResizeHandle.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
+
import useIsomorphicLayoutEffect from "./hooks/useIsomorphicEffect";
|
|
1
2
|
import useUniqueId from "./hooks/useUniqueId";
|
|
2
|
-
import {
|
|
3
|
-
createElement,
|
|
4
|
-
CSSProperties,
|
|
5
|
-
HTMLAttributes,
|
|
6
|
-
PropsWithChildren,
|
|
7
|
-
ReactElement,
|
|
8
|
-
useContext,
|
|
9
|
-
useEffect,
|
|
10
|
-
useRef,
|
|
11
|
-
useState,
|
|
12
|
-
} from "./vendor/react";
|
|
13
|
-
|
|
14
3
|
import { useWindowSplitterResizeHandlerBehavior } from "./hooks/useWindowSplitterBehavior";
|
|
15
4
|
import {
|
|
16
5
|
PanelGroupContext,
|
|
@@ -23,21 +12,33 @@ import {
|
|
|
23
12
|
ResizeHandlerAction,
|
|
24
13
|
} from "./PanelResizeHandleRegistry";
|
|
25
14
|
import { assert } from "./utils/assert";
|
|
26
|
-
import
|
|
15
|
+
import {
|
|
16
|
+
createElement,
|
|
17
|
+
CSSProperties,
|
|
18
|
+
HTMLAttributes,
|
|
19
|
+
PropsWithChildren,
|
|
20
|
+
ReactElement,
|
|
21
|
+
useContext,
|
|
22
|
+
useEffect,
|
|
23
|
+
useRef,
|
|
24
|
+
useState,
|
|
25
|
+
} from "./vendor/react";
|
|
27
26
|
|
|
28
27
|
export type PanelResizeHandleOnDragging = (isDragging: boolean) => void;
|
|
29
28
|
export type ResizeHandlerState = "drag" | "hover" | "inactive";
|
|
30
29
|
|
|
31
30
|
export type PanelResizeHandleProps = Omit<
|
|
32
31
|
HTMLAttributes<keyof HTMLElementTagNameMap>,
|
|
33
|
-
"id"
|
|
32
|
+
"id" | "onBlur" | "onFocus"
|
|
34
33
|
> &
|
|
35
34
|
PropsWithChildren<{
|
|
36
35
|
className?: string;
|
|
37
36
|
disabled?: boolean;
|
|
38
37
|
hitAreaMargins?: PointerHitAreaMargins;
|
|
39
38
|
id?: string | null;
|
|
39
|
+
onBlur?: () => void;
|
|
40
40
|
onDragging?: PanelResizeHandleOnDragging;
|
|
41
|
+
onFocus?: () => void;
|
|
41
42
|
style?: CSSProperties;
|
|
42
43
|
tabIndex?: number;
|
|
43
44
|
tagName?: keyof HTMLElementTagNameMap;
|
|
@@ -49,7 +50,9 @@ export function PanelResizeHandle({
|
|
|
49
50
|
disabled = false,
|
|
50
51
|
hitAreaMargins,
|
|
51
52
|
id: idFromProps,
|
|
53
|
+
onBlur,
|
|
52
54
|
onDragging,
|
|
55
|
+
onFocus,
|
|
53
56
|
style: styleFromProps = {},
|
|
54
57
|
tabIndex = 0,
|
|
55
58
|
tagName: Type = "div",
|
|
@@ -208,8 +211,14 @@ export function PanelResizeHandle({
|
|
|
208
211
|
children,
|
|
209
212
|
className: classNameFromProps,
|
|
210
213
|
id: idFromProps,
|
|
211
|
-
onBlur: () =>
|
|
212
|
-
|
|
214
|
+
onBlur: () => {
|
|
215
|
+
setIsFocused(false);
|
|
216
|
+
onBlur?.();
|
|
217
|
+
},
|
|
218
|
+
onFocus: () => {
|
|
219
|
+
setIsFocused(true);
|
|
220
|
+
onFocus?.();
|
|
221
|
+
},
|
|
213
222
|
ref: elementRef,
|
|
214
223
|
role: "separator",
|
|
215
224
|
style: {
|
|
@@ -73,6 +73,17 @@ export function registerResizeHandle(
|
|
|
73
73
|
if (count === 1) {
|
|
74
74
|
ownerDocumentCounts.delete(ownerDocument);
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
// If the resize handle that is currently unmounting is intersecting with the pointer,
|
|
78
|
+
// update the global pointer to account for the change
|
|
79
|
+
if (intersectingHandles.includes(data)) {
|
|
80
|
+
const index = intersectingHandles.indexOf(data);
|
|
81
|
+
if (index >= 0) {
|
|
82
|
+
intersectingHandles.splice(index, 1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
updateCursor();
|
|
86
|
+
}
|
|
76
87
|
};
|
|
77
88
|
}
|
|
78
89
|
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import type {
|
|
|
29
29
|
PanelResizeHandleOnDragging,
|
|
30
30
|
PanelResizeHandleProps,
|
|
31
31
|
} from "./PanelResizeHandle";
|
|
32
|
+
import type { PointerHitAreaMargins } from "./PanelResizeHandleRegistry";
|
|
32
33
|
|
|
33
34
|
export {
|
|
34
35
|
// TypeScript types
|
|
@@ -43,6 +44,7 @@ export {
|
|
|
43
44
|
PanelProps,
|
|
44
45
|
PanelResizeHandleOnDragging,
|
|
45
46
|
PanelResizeHandleProps,
|
|
47
|
+
PointerHitAreaMargins,
|
|
46
48
|
|
|
47
49
|
// React components
|
|
48
50
|
Panel,
|