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.
@@ -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 useIsomorphicLayoutEffect from "./hooks/useIsomorphicEffect";
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: () => setIsFocused(false),
212
- onFocus: () => setIsFocused(true),
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,