react-resizable-panels 2.0.16 → 2.0.18

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 CHANGED
@@ -1,8 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.18
4
+
5
+ - Inline object `hitAreaMargins` will not trigger re-initialization logic unless inner values change (#342)
6
+
7
+ ## 2.0.17
8
+
9
+ - Prevent pointer events handled by resize handles from triggering elements behind/underneath (#338)
10
+
3
11
  ## 2.0.16
4
12
 
5
- - Replaced `.toPrecision()` with `.toFixed()` to avoid undesirable layout shift (#323)
13
+ - Replaced .toPrecision() with .toFixed() to avoid undesirable layout shift (#323)
6
14
 
7
15
  ## 2.0.15
8
16
 
package/README.md CHANGED
@@ -6,7 +6,7 @@ React components for resizable panel groups/layouts
6
6
  import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
7
7
 
8
8
  <PanelGroup autoSaveId="example" direction="horizontal">
9
- <Panel defaultSizePercentage={25}>
9
+ <Panel defaultSize={25}>
10
10
  <SourcesExplorer />
11
11
  </Panel>
12
12
  <PanelResizeHandle />
@@ -14,7 +14,7 @@ import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
14
14
  <SourceViewer />
15
15
  </Panel>
16
16
  <PanelResizeHandle />
17
- <Panel defaultSizePercentage={25}>
17
+ <Panel defaultSize={25}>
18
18
  <Console />
19
19
  </Panel>
20
20
  </PanelGroup>;
@@ -74,7 +74,7 @@ import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
74
74
  `Panel` components also expose an imperative API for manual resizing:
75
75
  | method | description |
76
76
  | :----------------------- | :--------------------------------------------------------------------------------- |
77
- | `collapse()`v | If panel is `collapsible`, collapse it fully. |
77
+ | `collapse()` | If panel is `collapsible`, collapse it fully. |
78
78
  | `expand()` | If panel is currently _collapsed_, expand it to its most recent size. |
79
79
  | `getId(): string` | Gets the ID of the panel. |
80
80
  | `getSize(): number` | Gets the current size of the panel as a percentage (`1 - 100`). |
@@ -1,3 +1,3 @@
1
1
  export type Direction = "horizontal" | "vertical";
2
- export type ResizeEvent = KeyboardEvent | MouseEvent | TouchEvent;
2
+ export type ResizeEvent = KeyboardEvent | PointerEvent | MouseEvent;
3
3
  export type ResizeHandler = (event: ResizeEvent) => void;
@@ -47,6 +47,8 @@ const {
47
47
  const useId = React__namespace["useId".toString()];
48
48
  const useLayoutEffect_do_not_use_directly = useLayoutEffect;
49
49
 
50
+ // The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
51
+
50
52
  const PanelGroupContext = createContext(null);
51
53
  PanelGroupContext.displayName = "PanelGroupContext";
52
54
 
@@ -261,27 +263,26 @@ function setGlobalCursorStyle(state, constraintFlags) {
261
263
  function isKeyDown(event) {
262
264
  return event.type === "keydown";
263
265
  }
266
+ function isPointerEvent(event) {
267
+ return event.type.startsWith("pointer");
268
+ }
264
269
  function isMouseEvent(event) {
265
270
  return event.type.startsWith("mouse");
266
271
  }
267
- function isTouchEvent(event) {
268
- return event.type.startsWith("touch");
269
- }
270
272
 
271
273
  function getResizeEventCoordinates(event) {
272
- if (isMouseEvent(event)) {
274
+ if (isPointerEvent(event)) {
275
+ if (event.isPrimary) {
276
+ return {
277
+ x: event.clientX,
278
+ y: event.clientY
279
+ };
280
+ }
281
+ } else if (isMouseEvent(event)) {
273
282
  return {
274
283
  x: event.clientX,
275
284
  y: event.clientY
276
285
  };
277
- } else if (isTouchEvent(event)) {
278
- const touch = event.touches[0];
279
- if (touch && touch.clientX && touch.clientY) {
280
- return {
281
- x: touch.clientX,
282
- y: touch.clientY
283
- };
284
- }
285
286
  }
286
287
  return {
287
288
  x: Infinity,
@@ -473,6 +474,7 @@ function handlePointerDown(event) {
473
474
  if (intersectingHandles.length > 0) {
474
475
  updateResizeHandlerStates("down", event);
475
476
  event.preventDefault();
477
+ event.stopPropagation();
476
478
  }
477
479
  }
478
480
  function handlePointerMove(event) {
@@ -621,15 +623,12 @@ function updateListeners() {
621
623
  body
622
624
  } = ownerDocument;
623
625
  body.removeEventListener("contextmenu", handlePointerUp);
624
- body.removeEventListener("mousedown", handlePointerDown);
625
- body.removeEventListener("mouseleave", handlePointerMove);
626
- body.removeEventListener("mousemove", handlePointerMove);
627
- body.removeEventListener("touchmove", handlePointerMove);
628
- body.removeEventListener("touchstart", handlePointerDown);
626
+ body.removeEventListener("pointerdown", handlePointerDown);
627
+ body.removeEventListener("pointerleave", handlePointerMove);
628
+ body.removeEventListener("pointermove", handlePointerMove);
629
629
  });
630
- window.removeEventListener("mouseup", handlePointerUp);
631
- window.removeEventListener("touchcancel", handlePointerUp);
632
- window.removeEventListener("touchend", handlePointerUp);
630
+ window.removeEventListener("pointerup", handlePointerUp);
631
+ window.removeEventListener("pointercancel", handlePointerUp);
633
632
  if (registeredResizeHandlers.size > 0) {
634
633
  if (isPointerDown) {
635
634
  if (intersectingHandles.length > 0) {
@@ -639,29 +638,23 @@ function updateListeners() {
639
638
  } = ownerDocument;
640
639
  if (count > 0) {
641
640
  body.addEventListener("contextmenu", handlePointerUp);
642
- body.addEventListener("mouseleave", handlePointerMove);
643
- body.addEventListener("mousemove", handlePointerMove);
644
- body.addEventListener("touchmove", handlePointerMove, {
645
- passive: false
646
- });
641
+ body.addEventListener("pointerleave", handlePointerMove);
642
+ body.addEventListener("pointermove", handlePointerMove);
647
643
  }
648
644
  });
649
645
  }
650
- window.addEventListener("mouseup", handlePointerUp);
651
- window.addEventListener("touchcancel", handlePointerUp);
652
- window.addEventListener("touchend", handlePointerUp);
646
+ window.addEventListener("pointerup", handlePointerUp);
647
+ window.addEventListener("pointercancel", handlePointerUp);
653
648
  } else {
654
649
  ownerDocumentCounts.forEach((count, ownerDocument) => {
655
650
  const {
656
651
  body
657
652
  } = ownerDocument;
658
653
  if (count > 0) {
659
- body.addEventListener("mousedown", handlePointerDown);
660
- body.addEventListener("mousemove", handlePointerMove);
661
- body.addEventListener("touchmove", handlePointerMove, {
662
- passive: false
654
+ body.addEventListener("pointerdown", handlePointerDown, {
655
+ capture: true
663
656
  });
664
- body.addEventListener("touchstart", handlePointerDown);
657
+ body.addEventListener("pointermove", handlePointerMove);
665
658
  }
666
659
  });
667
660
  }
@@ -900,7 +893,7 @@ function adjustLayoutByDelta({
900
893
  if (!fuzzyNumbersEqual(prevSize, safeSize)) {
901
894
  deltaApplied += prevSize - safeSize;
902
895
  nextLayout[index] = safeSize;
903
- if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
896
+ if (deltaApplied.toPrecision(3).localeCompare(Math.abs(delta).toPrecision(3), undefined, {
904
897
  numeric: true
905
898
  }) >= 0) {
906
899
  break;
@@ -1380,12 +1373,12 @@ function computePanelFlexBoxStyle({
1380
1373
  if (size == null) {
1381
1374
  // Initial render (before panels have registered themselves)
1382
1375
  // In order to support server rendering, fall back to default size if provided
1383
- flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
1376
+ flexGrow = defaultSize != undefined ? defaultSize.toPrecision(precision) : "1";
1384
1377
  } else if (panelData.length === 1) {
1385
1378
  // Special case: Single panel group should always fill full width/height
1386
1379
  flexGrow = "1";
1387
1380
  } else {
1388
- flexGrow = size.toFixed(precision);
1381
+ flexGrow = size.toPrecision(precision);
1389
1382
  }
1390
1383
  return {
1391
1384
  flexBasis: 0,
@@ -1949,7 +1942,7 @@ function PanelGroupWithForwardedRef({
1949
1942
 
1950
1943
  // Only update the cursor for layout changes triggered by touch/mouse events (not keyboard)
1951
1944
  // Update the cursor even if the layout hasn't changed (we may need to show an invalid cursor state)
1952
- if (isMouseEvent(event) || isTouchEvent(event)) {
1945
+ if (isPointerEvent(event) || isMouseEvent(event)) {
1953
1946
  // Watch for multiple subsequent deltas; this might occur for tiny cursor movements.
1954
1947
  // In this case, Panel sizes might not change–
1955
1948
  // but updating cursor in this scenario would cause a flicker.
@@ -2215,6 +2208,7 @@ function PanelResizeHandle({
2215
2208
  tagName: Type = "div",
2216
2209
  ...rest
2217
2210
  }) {
2211
+ var _hitAreaMargins$coars, _hitAreaMargins$fine;
2218
2212
  const elementRef = useRef(null);
2219
2213
 
2220
2214
  // Use a ref to guard against users passing inline props
@@ -2254,8 +2248,12 @@ function PanelResizeHandle({
2254
2248
  setResizeHandler(() => resizeHandler);
2255
2249
  }
2256
2250
  }, [disabled, resizeHandleId, registerResizeHandleWithParentGroup]);
2251
+
2252
+ // Extract hit area margins before passing them to the effect's dependency array
2253
+ // so that inline object values won't trigger re-renders
2254
+ const coarseHitAreaMargins = (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15;
2255
+ const fineHitAreaMargins = (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5;
2257
2256
  useEffect(() => {
2258
- var _hitAreaMargins$coars, _hitAreaMargins$fine;
2259
2257
  if (disabled || resizeHandler == null) {
2260
2258
  return;
2261
2259
  }
@@ -2305,12 +2303,10 @@ function PanelResizeHandle({
2305
2303
  }
2306
2304
  };
2307
2305
  return registerResizeHandle(resizeHandleId, element, direction, {
2308
- // Coarse inputs (e.g. finger/touch)
2309
- coarse: (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15,
2310
- // Fine inputs (e.g. mouse)
2311
- fine: (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5
2306
+ coarse: coarseHitAreaMargins,
2307
+ fine: fineHitAreaMargins
2312
2308
  }, setResizeHandlerState);
2313
- }, [direction, disabled, hitAreaMargins, registerResizeHandleWithParentGroup, resizeHandleId, resizeHandler, startDragging, stopDragging]);
2309
+ }, [coarseHitAreaMargins, direction, disabled, fineHitAreaMargins, registerResizeHandleWithParentGroup, resizeHandleId, resizeHandler, startDragging, stopDragging]);
2314
2310
  useWindowSplitterResizeHandlerBehavior({
2315
2311
  disabled,
2316
2312
  handleId: resizeHandleId,
@@ -47,6 +47,8 @@ const {
47
47
  const useId = React__namespace["useId".toString()];
48
48
  const useLayoutEffect_do_not_use_directly = useLayoutEffect;
49
49
 
50
+ // The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
51
+
50
52
  const PanelGroupContext = createContext(null);
51
53
  PanelGroupContext.displayName = "PanelGroupContext";
52
54
 
@@ -267,27 +269,26 @@ function setGlobalCursorStyle(state, constraintFlags) {
267
269
  function isKeyDown(event) {
268
270
  return event.type === "keydown";
269
271
  }
272
+ function isPointerEvent(event) {
273
+ return event.type.startsWith("pointer");
274
+ }
270
275
  function isMouseEvent(event) {
271
276
  return event.type.startsWith("mouse");
272
277
  }
273
- function isTouchEvent(event) {
274
- return event.type.startsWith("touch");
275
- }
276
278
 
277
279
  function getResizeEventCoordinates(event) {
278
- if (isMouseEvent(event)) {
280
+ if (isPointerEvent(event)) {
281
+ if (event.isPrimary) {
282
+ return {
283
+ x: event.clientX,
284
+ y: event.clientY
285
+ };
286
+ }
287
+ } else if (isMouseEvent(event)) {
279
288
  return {
280
289
  x: event.clientX,
281
290
  y: event.clientY
282
291
  };
283
- } else if (isTouchEvent(event)) {
284
- const touch = event.touches[0];
285
- if (touch && touch.clientX && touch.clientY) {
286
- return {
287
- x: touch.clientX,
288
- y: touch.clientY
289
- };
290
- }
291
292
  }
292
293
  return {
293
294
  x: Infinity,
@@ -479,6 +480,7 @@ function handlePointerDown(event) {
479
480
  if (intersectingHandles.length > 0) {
480
481
  updateResizeHandlerStates("down", event);
481
482
  event.preventDefault();
483
+ event.stopPropagation();
482
484
  }
483
485
  }
484
486
  function handlePointerMove(event) {
@@ -627,15 +629,12 @@ function updateListeners() {
627
629
  body
628
630
  } = ownerDocument;
629
631
  body.removeEventListener("contextmenu", handlePointerUp);
630
- body.removeEventListener("mousedown", handlePointerDown);
631
- body.removeEventListener("mouseleave", handlePointerMove);
632
- body.removeEventListener("mousemove", handlePointerMove);
633
- body.removeEventListener("touchmove", handlePointerMove);
634
- body.removeEventListener("touchstart", handlePointerDown);
632
+ body.removeEventListener("pointerdown", handlePointerDown);
633
+ body.removeEventListener("pointerleave", handlePointerMove);
634
+ body.removeEventListener("pointermove", handlePointerMove);
635
635
  });
636
- window.removeEventListener("mouseup", handlePointerUp);
637
- window.removeEventListener("touchcancel", handlePointerUp);
638
- window.removeEventListener("touchend", handlePointerUp);
636
+ window.removeEventListener("pointerup", handlePointerUp);
637
+ window.removeEventListener("pointercancel", handlePointerUp);
639
638
  if (registeredResizeHandlers.size > 0) {
640
639
  if (isPointerDown) {
641
640
  if (intersectingHandles.length > 0) {
@@ -645,29 +644,23 @@ function updateListeners() {
645
644
  } = ownerDocument;
646
645
  if (count > 0) {
647
646
  body.addEventListener("contextmenu", handlePointerUp);
648
- body.addEventListener("mouseleave", handlePointerMove);
649
- body.addEventListener("mousemove", handlePointerMove);
650
- body.addEventListener("touchmove", handlePointerMove, {
651
- passive: false
652
- });
647
+ body.addEventListener("pointerleave", handlePointerMove);
648
+ body.addEventListener("pointermove", handlePointerMove);
653
649
  }
654
650
  });
655
651
  }
656
- window.addEventListener("mouseup", handlePointerUp);
657
- window.addEventListener("touchcancel", handlePointerUp);
658
- window.addEventListener("touchend", handlePointerUp);
652
+ window.addEventListener("pointerup", handlePointerUp);
653
+ window.addEventListener("pointercancel", handlePointerUp);
659
654
  } else {
660
655
  ownerDocumentCounts.forEach((count, ownerDocument) => {
661
656
  const {
662
657
  body
663
658
  } = ownerDocument;
664
659
  if (count > 0) {
665
- body.addEventListener("mousedown", handlePointerDown);
666
- body.addEventListener("mousemove", handlePointerMove);
667
- body.addEventListener("touchmove", handlePointerMove, {
668
- passive: false
660
+ body.addEventListener("pointerdown", handlePointerDown, {
661
+ capture: true
669
662
  });
670
- body.addEventListener("touchstart", handlePointerDown);
663
+ body.addEventListener("pointermove", handlePointerMove);
671
664
  }
672
665
  });
673
666
  }
@@ -906,7 +899,7 @@ function adjustLayoutByDelta({
906
899
  if (!fuzzyNumbersEqual(prevSize, safeSize)) {
907
900
  deltaApplied += prevSize - safeSize;
908
901
  nextLayout[index] = safeSize;
909
- if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
902
+ if (deltaApplied.toPrecision(3).localeCompare(Math.abs(delta).toPrecision(3), undefined, {
910
903
  numeric: true
911
904
  }) >= 0) {
912
905
  break;
@@ -1396,12 +1389,12 @@ function computePanelFlexBoxStyle({
1396
1389
  if (size == null) {
1397
1390
  // Initial render (before panels have registered themselves)
1398
1391
  // In order to support server rendering, fall back to default size if provided
1399
- flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
1392
+ flexGrow = defaultSize != undefined ? defaultSize.toPrecision(precision) : "1";
1400
1393
  } else if (panelData.length === 1) {
1401
1394
  // Special case: Single panel group should always fill full width/height
1402
1395
  flexGrow = "1";
1403
1396
  } else {
1404
- flexGrow = size.toFixed(precision);
1397
+ flexGrow = size.toPrecision(precision);
1405
1398
  }
1406
1399
  return {
1407
1400
  flexBasis: 0,
@@ -2055,7 +2048,7 @@ function PanelGroupWithForwardedRef({
2055
2048
 
2056
2049
  // Only update the cursor for layout changes triggered by touch/mouse events (not keyboard)
2057
2050
  // Update the cursor even if the layout hasn't changed (we may need to show an invalid cursor state)
2058
- if (isMouseEvent(event) || isTouchEvent(event)) {
2051
+ if (isPointerEvent(event) || isMouseEvent(event)) {
2059
2052
  // Watch for multiple subsequent deltas; this might occur for tiny cursor movements.
2060
2053
  // In this case, Panel sizes might not change–
2061
2054
  // but updating cursor in this scenario would cause a flicker.
@@ -2321,6 +2314,7 @@ function PanelResizeHandle({
2321
2314
  tagName: Type = "div",
2322
2315
  ...rest
2323
2316
  }) {
2317
+ var _hitAreaMargins$coars, _hitAreaMargins$fine;
2324
2318
  const elementRef = useRef(null);
2325
2319
 
2326
2320
  // Use a ref to guard against users passing inline props
@@ -2360,8 +2354,12 @@ function PanelResizeHandle({
2360
2354
  setResizeHandler(() => resizeHandler);
2361
2355
  }
2362
2356
  }, [disabled, resizeHandleId, registerResizeHandleWithParentGroup]);
2357
+
2358
+ // Extract hit area margins before passing them to the effect's dependency array
2359
+ // so that inline object values won't trigger re-renders
2360
+ const coarseHitAreaMargins = (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15;
2361
+ const fineHitAreaMargins = (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5;
2363
2362
  useEffect(() => {
2364
- var _hitAreaMargins$coars, _hitAreaMargins$fine;
2365
2363
  if (disabled || resizeHandler == null) {
2366
2364
  return;
2367
2365
  }
@@ -2411,12 +2409,10 @@ function PanelResizeHandle({
2411
2409
  }
2412
2410
  };
2413
2411
  return registerResizeHandle(resizeHandleId, element, direction, {
2414
- // Coarse inputs (e.g. finger/touch)
2415
- coarse: (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15,
2416
- // Fine inputs (e.g. mouse)
2417
- fine: (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5
2412
+ coarse: coarseHitAreaMargins,
2413
+ fine: fineHitAreaMargins
2418
2414
  }, setResizeHandlerState);
2419
- }, [direction, disabled, hitAreaMargins, registerResizeHandleWithParentGroup, resizeHandleId, resizeHandler, startDragging, stopDragging]);
2415
+ }, [coarseHitAreaMargins, direction, disabled, fineHitAreaMargins, registerResizeHandleWithParentGroup, resizeHandleId, resizeHandler, startDragging, stopDragging]);
2420
2416
  useWindowSplitterResizeHandlerBehavior({
2421
2417
  disabled,
2422
2418
  handleId: resizeHandleId,
@@ -23,6 +23,8 @@ const {
23
23
  const useId = React["useId".toString()];
24
24
  const useLayoutEffect_do_not_use_directly = useLayoutEffect;
25
25
 
26
+ // The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
27
+
26
28
  const PanelGroupContext = createContext(null);
27
29
  PanelGroupContext.displayName = "PanelGroupContext";
28
30
 
@@ -243,27 +245,26 @@ function setGlobalCursorStyle(state, constraintFlags) {
243
245
  function isKeyDown(event) {
244
246
  return event.type === "keydown";
245
247
  }
248
+ function isPointerEvent(event) {
249
+ return event.type.startsWith("pointer");
250
+ }
246
251
  function isMouseEvent(event) {
247
252
  return event.type.startsWith("mouse");
248
253
  }
249
- function isTouchEvent(event) {
250
- return event.type.startsWith("touch");
251
- }
252
254
 
253
255
  function getResizeEventCoordinates(event) {
254
- if (isMouseEvent(event)) {
256
+ if (isPointerEvent(event)) {
257
+ if (event.isPrimary) {
258
+ return {
259
+ x: event.clientX,
260
+ y: event.clientY
261
+ };
262
+ }
263
+ } else if (isMouseEvent(event)) {
255
264
  return {
256
265
  x: event.clientX,
257
266
  y: event.clientY
258
267
  };
259
- } else if (isTouchEvent(event)) {
260
- const touch = event.touches[0];
261
- if (touch && touch.clientX && touch.clientY) {
262
- return {
263
- x: touch.clientX,
264
- y: touch.clientY
265
- };
266
- }
267
268
  }
268
269
  return {
269
270
  x: Infinity,
@@ -455,6 +456,7 @@ function handlePointerDown(event) {
455
456
  if (intersectingHandles.length > 0) {
456
457
  updateResizeHandlerStates("down", event);
457
458
  event.preventDefault();
459
+ event.stopPropagation();
458
460
  }
459
461
  }
460
462
  function handlePointerMove(event) {
@@ -603,15 +605,12 @@ function updateListeners() {
603
605
  body
604
606
  } = ownerDocument;
605
607
  body.removeEventListener("contextmenu", handlePointerUp);
606
- body.removeEventListener("mousedown", handlePointerDown);
607
- body.removeEventListener("mouseleave", handlePointerMove);
608
- body.removeEventListener("mousemove", handlePointerMove);
609
- body.removeEventListener("touchmove", handlePointerMove);
610
- body.removeEventListener("touchstart", handlePointerDown);
608
+ body.removeEventListener("pointerdown", handlePointerDown);
609
+ body.removeEventListener("pointerleave", handlePointerMove);
610
+ body.removeEventListener("pointermove", handlePointerMove);
611
611
  });
612
- window.removeEventListener("mouseup", handlePointerUp);
613
- window.removeEventListener("touchcancel", handlePointerUp);
614
- window.removeEventListener("touchend", handlePointerUp);
612
+ window.removeEventListener("pointerup", handlePointerUp);
613
+ window.removeEventListener("pointercancel", handlePointerUp);
615
614
  if (registeredResizeHandlers.size > 0) {
616
615
  if (isPointerDown) {
617
616
  if (intersectingHandles.length > 0) {
@@ -621,29 +620,23 @@ function updateListeners() {
621
620
  } = ownerDocument;
622
621
  if (count > 0) {
623
622
  body.addEventListener("contextmenu", handlePointerUp);
624
- body.addEventListener("mouseleave", handlePointerMove);
625
- body.addEventListener("mousemove", handlePointerMove);
626
- body.addEventListener("touchmove", handlePointerMove, {
627
- passive: false
628
- });
623
+ body.addEventListener("pointerleave", handlePointerMove);
624
+ body.addEventListener("pointermove", handlePointerMove);
629
625
  }
630
626
  });
631
627
  }
632
- window.addEventListener("mouseup", handlePointerUp);
633
- window.addEventListener("touchcancel", handlePointerUp);
634
- window.addEventListener("touchend", handlePointerUp);
628
+ window.addEventListener("pointerup", handlePointerUp);
629
+ window.addEventListener("pointercancel", handlePointerUp);
635
630
  } else {
636
631
  ownerDocumentCounts.forEach((count, ownerDocument) => {
637
632
  const {
638
633
  body
639
634
  } = ownerDocument;
640
635
  if (count > 0) {
641
- body.addEventListener("mousedown", handlePointerDown);
642
- body.addEventListener("mousemove", handlePointerMove);
643
- body.addEventListener("touchmove", handlePointerMove, {
644
- passive: false
636
+ body.addEventListener("pointerdown", handlePointerDown, {
637
+ capture: true
645
638
  });
646
- body.addEventListener("touchstart", handlePointerDown);
639
+ body.addEventListener("pointermove", handlePointerMove);
647
640
  }
648
641
  });
649
642
  }
@@ -882,7 +875,7 @@ function adjustLayoutByDelta({
882
875
  if (!fuzzyNumbersEqual(prevSize, safeSize)) {
883
876
  deltaApplied += prevSize - safeSize;
884
877
  nextLayout[index] = safeSize;
885
- if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
878
+ if (deltaApplied.toPrecision(3).localeCompare(Math.abs(delta).toPrecision(3), undefined, {
886
879
  numeric: true
887
880
  }) >= 0) {
888
881
  break;
@@ -1372,12 +1365,12 @@ function computePanelFlexBoxStyle({
1372
1365
  if (size == null) {
1373
1366
  // Initial render (before panels have registered themselves)
1374
1367
  // In order to support server rendering, fall back to default size if provided
1375
- flexGrow = defaultSize != undefined ? defaultSize.toFixed(precision) : "1";
1368
+ flexGrow = defaultSize != undefined ? defaultSize.toPrecision(precision) : "1";
1376
1369
  } else if (panelData.length === 1) {
1377
1370
  // Special case: Single panel group should always fill full width/height
1378
1371
  flexGrow = "1";
1379
1372
  } else {
1380
- flexGrow = size.toFixed(precision);
1373
+ flexGrow = size.toPrecision(precision);
1381
1374
  }
1382
1375
  return {
1383
1376
  flexBasis: 0,
@@ -2031,7 +2024,7 @@ function PanelGroupWithForwardedRef({
2031
2024
 
2032
2025
  // Only update the cursor for layout changes triggered by touch/mouse events (not keyboard)
2033
2026
  // Update the cursor even if the layout hasn't changed (we may need to show an invalid cursor state)
2034
- if (isMouseEvent(event) || isTouchEvent(event)) {
2027
+ if (isPointerEvent(event) || isMouseEvent(event)) {
2035
2028
  // Watch for multiple subsequent deltas; this might occur for tiny cursor movements.
2036
2029
  // In this case, Panel sizes might not change–
2037
2030
  // but updating cursor in this scenario would cause a flicker.
@@ -2297,6 +2290,7 @@ function PanelResizeHandle({
2297
2290
  tagName: Type = "div",
2298
2291
  ...rest
2299
2292
  }) {
2293
+ var _hitAreaMargins$coars, _hitAreaMargins$fine;
2300
2294
  const elementRef = useRef(null);
2301
2295
 
2302
2296
  // Use a ref to guard against users passing inline props
@@ -2336,8 +2330,12 @@ function PanelResizeHandle({
2336
2330
  setResizeHandler(() => resizeHandler);
2337
2331
  }
2338
2332
  }, [disabled, resizeHandleId, registerResizeHandleWithParentGroup]);
2333
+
2334
+ // Extract hit area margins before passing them to the effect's dependency array
2335
+ // so that inline object values won't trigger re-renders
2336
+ const coarseHitAreaMargins = (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15;
2337
+ const fineHitAreaMargins = (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5;
2339
2338
  useEffect(() => {
2340
- var _hitAreaMargins$coars, _hitAreaMargins$fine;
2341
2339
  if (disabled || resizeHandler == null) {
2342
2340
  return;
2343
2341
  }
@@ -2387,12 +2385,10 @@ function PanelResizeHandle({
2387
2385
  }
2388
2386
  };
2389
2387
  return registerResizeHandle(resizeHandleId, element, direction, {
2390
- // Coarse inputs (e.g. finger/touch)
2391
- coarse: (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15,
2392
- // Fine inputs (e.g. mouse)
2393
- fine: (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5
2388
+ coarse: coarseHitAreaMargins,
2389
+ fine: fineHitAreaMargins
2394
2390
  }, setResizeHandlerState);
2395
- }, [direction, disabled, hitAreaMargins, registerResizeHandleWithParentGroup, resizeHandleId, resizeHandler, startDragging, stopDragging]);
2391
+ }, [coarseHitAreaMargins, direction, disabled, fineHitAreaMargins, registerResizeHandleWithParentGroup, resizeHandleId, resizeHandler, startDragging, stopDragging]);
2396
2392
  useWindowSplitterResizeHandlerBehavior({
2397
2393
  disabled,
2398
2394
  handleId: resizeHandleId,