react-resizable-panels 0.0.56 → 0.0.58

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/declarations/src/Panel.d.ts +7 -3
  3. package/dist/declarations/src/PanelGroup.d.ts +3 -1
  4. package/dist/declarations/src/PanelResizeHandle.d.ts +3 -1
  5. package/dist/declarations/src/types.d.ts +3 -0
  6. package/dist/react-resizable-panels.browser.cjs.js +186 -87
  7. package/dist/react-resizable-panels.browser.development.cjs.js +186 -87
  8. package/dist/react-resizable-panels.browser.development.esm.js +186 -87
  9. package/dist/react-resizable-panels.browser.esm.js +186 -87
  10. package/dist/react-resizable-panels.cjs.js +186 -87
  11. package/dist/react-resizable-panels.cjs.js.map +1 -1
  12. package/dist/react-resizable-panels.development.cjs.js +186 -87
  13. package/dist/react-resizable-panels.development.esm.js +186 -87
  14. package/dist/react-resizable-panels.development.node.cjs.js +175 -82
  15. package/dist/react-resizable-panels.development.node.esm.js +175 -82
  16. package/dist/react-resizable-panels.esm.js +186 -87
  17. package/dist/react-resizable-panels.esm.js.map +1 -1
  18. package/dist/react-resizable-panels.node.cjs.js +175 -82
  19. package/dist/react-resizable-panels.node.esm.js +175 -82
  20. package/package.json +3 -1
  21. package/src/Panel.ts +9 -3
  22. package/src/PanelGroup.ts +11 -5
  23. package/src/PanelResizeHandle.ts +17 -13
  24. package/src/types.ts +4 -0
  25. package/src/utils/adjustLayoutByDelta.test.ts +238 -8
  26. package/src/utils/adjustLayoutByDelta.ts +122 -72
  27. package/src/utils/computePercentagePanelConstraints.test.ts +27 -0
  28. package/src/utils/convertPixelConstraintsToPercentages.test.ts +47 -0
  29. package/src/utils/convertPixelConstraintsToPercentages.ts +17 -0
  30. package/src/utils/dom/getPanelGroupElement.ts +3 -1
  31. package/src/utils/resizePanel.test.ts +105 -0
  32. package/src/utils/resizePanel.ts +26 -1
  33. package/src/utils/validatePanelGroupLayout.test.ts +36 -6
@@ -61,7 +61,7 @@ function useUniqueId(idFromParams = null) {
61
61
  if (idRef.current === null) {
62
62
  idRef.current = "" + counter++;
63
63
  }
64
- return idFromParams ?? idRef.current;
64
+ return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
65
65
  }
66
66
 
67
67
  function PanelWithForwardedRef({
@@ -70,6 +70,7 @@ function PanelWithForwardedRef({
70
70
  collapsedSizePercentage,
71
71
  collapsedSizePixels,
72
72
  collapsible,
73
+ dataAttributes,
73
74
  defaultSizePercentage,
74
75
  defaultSizePixels,
75
76
  forwardedRef,
@@ -194,11 +195,12 @@ function PanelWithForwardedRef({
194
195
  ...style,
195
196
  ...styleFromProps
196
197
  },
198
+ ...dataAttributes,
197
199
  // CSS selectors
198
200
  "data-panel": "",
201
+ "data-panel-id": panelId,
199
202
  // e2e test attributes
200
203
  "data-panel-collapsible": collapsible || undefined ,
201
- "data-panel-id": panelId ,
202
204
  "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
203
205
  });
204
206
  }
@@ -226,6 +228,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
226
228
  minSizePercentage = 0,
227
229
  minSizePixels
228
230
  } = panelConstraints;
231
+ const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
232
+ if (hasPixelConstraints && groupSizePixels <= 0) {
233
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
234
+ return {
235
+ collapsedSizePercentage: 0,
236
+ defaultSizePercentage,
237
+ maxSizePercentage: 0,
238
+ minSizePercentage: 0
239
+ };
240
+ }
229
241
  if (collapsedSizePixels != null) {
230
242
  collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
231
243
  }
@@ -300,6 +312,16 @@ function resizePanel({
300
312
  panelIndex,
301
313
  size
302
314
  }) {
315
+ const hasPixelConstraints = panelConstraints.some(({
316
+ collapsedSizePixels,
317
+ defaultSizePixels,
318
+ minSizePixels,
319
+ maxSizePixels
320
+ }) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
321
+ if (hasPixelConstraints && groupSizePixels <= 0) {
322
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
323
+ return 0;
324
+ }
303
325
  let {
304
326
  collapsible
305
327
  } = panelConstraints[panelIndex];
@@ -311,7 +333,13 @@ function resizePanel({
311
333
  if (minSizePercentage != null) {
312
334
  if (fuzzyCompareNumbers(size, minSizePercentage) < 0) {
313
335
  if (collapsible) {
314
- size = collapsedSizePercentage;
336
+ // Collapsible panels should snap closed or open only once they cross the halfway point between collapsed and min size.
337
+ const halfwayPoint = (collapsedSizePercentage + minSizePercentage) / 2;
338
+ if (fuzzyCompareNumbers(size, halfwayPoint) < 0) {
339
+ size = collapsedSizePercentage;
340
+ } else {
341
+ size = minSizePercentage;
342
+ }
315
343
  } else {
316
344
  size = minSizePercentage;
317
345
  }
@@ -338,61 +366,123 @@ function adjustLayoutByDelta({
338
366
  const nextLayout = [...prevLayout];
339
367
  let deltaApplied = 0;
340
368
 
369
+ //const DEBUG = [];
370
+ //DEBUG.push(`adjustLayoutByDelta() ${prevLayout.join(", ")}`);
371
+ //DEBUG.push(` delta: ${delta}`);
372
+ //DEBUG.push(` pivotIndices: ${pivotIndices.join(", ")}`);
373
+ //DEBUG.push(` trigger: ${trigger}`);
374
+ //DEBUG.push("");
375
+
341
376
  // A resizing panel affects the panels before or after it.
342
377
  //
343
- // A negative delta means the panel immediately after the resizer should grow/expand by decreasing its offset.
378
+ // A negative delta means the panel(s) immediately after the resize handle should grow/expand by decreasing its offset.
344
379
  // Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
345
380
  //
346
- // A positive delta means the panel immediately before the resizer should "expand".
347
- // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resizer.
381
+ // A positive delta means the panel(s) immediately before the resize handle should "expand".
382
+ // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resize handle.
348
383
 
349
- // First, check the panel we're pivoting around;
350
- // We should only expand or contract by as much as its constraints allow
351
384
  {
352
- const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
353
- const initialSize = nextLayout[pivotIndex];
354
- const {
355
- collapsible
356
- } = panelConstraints[pivotIndex];
357
- const {
358
- collapsedSizePercentage,
359
- maxSizePercentage,
360
- minSizePercentage
361
- } = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
362
- const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
363
- let unsafeSize = initialSize + Math.abs(delta);
364
- if (isCollapsed) {
365
- switch (trigger) {
366
- case "keyboard":
367
- if (minSizePercentage > unsafeSize) {
368
- unsafeSize = minSizePercentage;
385
+ // If this is a resize triggered by a keyboard event, our logic for expanding/collapsing is different.
386
+ // We no longer check the halfway threshold because this may prevent the panel from expanding at all.
387
+ if (trigger === "keyboard") {
388
+ {
389
+ // Check if we should expand a collapsed panel
390
+ const index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
391
+ const constraints = panelConstraints[index];
392
+ //DEBUG.push(`edge case check 1: ${index}`);
393
+ //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
394
+ if (constraints.collapsible) {
395
+ const prevSize = prevLayout[index];
396
+ const {
397
+ collapsedSizePercentage,
398
+ minSizePercentage
399
+ } = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
400
+ if (fuzzyNumbersEqual(prevSize, collapsedSizePercentage)) {
401
+ const localDelta = minSizePercentage - prevSize;
402
+ //DEBUG.push(` -> expand delta: ${localDelta}`);
403
+
404
+ if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
405
+ delta = delta < 0 ? 0 - localDelta : localDelta;
406
+ //DEBUG.push(` -> delta: ${delta}`);
407
+ }
369
408
  }
409
+ }
410
+ }
411
+
412
+ {
413
+ // Check if we should collapse a panel at its minimum size
414
+ const index = delta < 0 ? pivotIndices[0] : pivotIndices[1];
415
+ const constraints = panelConstraints[index];
416
+ //DEBUG.push(`edge case check 2: ${index}`);
417
+ //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
418
+ if (constraints.collapsible) {
419
+ const prevSize = prevLayout[index];
420
+ const {
421
+ collapsedSizePercentage,
422
+ minSizePercentage
423
+ } = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
424
+ if (fuzzyNumbersEqual(prevSize, minSizePercentage)) {
425
+ const localDelta = prevSize - collapsedSizePercentage;
426
+ //DEBUG.push(` -> expand delta: ${localDelta}`);
427
+
428
+ if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
429
+ delta = delta < 0 ? 0 - localDelta : localDelta;
430
+ //DEBUG.push(` -> delta: ${delta}`);
431
+ }
432
+ }
433
+ }
370
434
  }
371
435
  }
372
- const safeSize = resizePanel({
373
- groupSizePixels,
374
- panelConstraints,
375
- panelIndex: pivotIndex,
376
- size: unsafeSize
377
- });
378
- if (fuzzyNumbersEqual(initialSize, safeSize)) {
379
- // If there's no room for the pivot panel to grow, we should ignore this change
380
- return nextLayout;
381
- } else {
382
- delta = delta < 0 ? initialSize - safeSize : safeSize - initialSize;
436
+ //DEBUG.push("");
437
+ }
438
+
439
+ {
440
+ // Pre-calculate max available delta in the opposite direction of our pivot.
441
+ // This will be the maximum amount we're allowed to expand/contract the panels in the primary direction.
442
+ // If this amount is less than the requested delta, adjust the requested delta.
443
+ // If this amount is greater than the requested delta, that's useful information too–
444
+ // as an expanding panel might change from collapsed to min size.
445
+
446
+ const increment = delta < 0 ? 1 : -1;
447
+ let index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
448
+ let maxAvailableDelta = 0;
449
+
450
+ //DEBUG.push("pre calc...");
451
+ while (true) {
452
+ const prevSize = prevLayout[index];
453
+ const maxSafeSize = resizePanel({
454
+ groupSizePixels,
455
+ panelConstraints,
456
+ panelIndex: index,
457
+ size: 100
458
+ });
459
+ const delta = maxSafeSize - prevSize;
460
+ //DEBUG.push(` ${index}: ${prevSize} -> ${maxSafeSize}`);
461
+
462
+ maxAvailableDelta += delta;
463
+ index += increment;
464
+ if (index < 0 || index >= panelConstraints.length) {
465
+ break;
466
+ }
383
467
  }
468
+
469
+ //DEBUG.push(` -> max available delta: ${maxAvailableDelta}`);
470
+ const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
471
+ delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
472
+ //DEBUG.push(` -> adjusted delta: ${delta}`);
473
+ //DEBUG.push("");
384
474
  }
385
475
 
386
- // Delta added to a panel needs to be subtracted from other panels
387
- // within the constraints that those panels allow
388
476
  {
477
+ // Delta added to a panel needs to be subtracted from other panels (within the constraints that those panels allow).
478
+
389
479
  const pivotIndex = delta < 0 ? pivotIndices[0] : pivotIndices[1];
390
480
  let index = pivotIndex;
391
481
  while (index >= 0 && index < panelConstraints.length) {
392
482
  const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
393
483
  const prevSize = prevLayout[index];
394
484
  const unsafeSize = prevSize - deltaRemaining;
395
- let safeSize = resizePanel({
485
+ const safeSize = resizePanel({
396
486
  groupSizePixels,
397
487
  panelConstraints,
398
488
  panelIndex: index,
@@ -414,13 +504,18 @@ function adjustLayoutByDelta({
414
504
  }
415
505
  }
416
506
  }
507
+ //DEBUG.push(`after 1: ${nextLayout.join(", ")}`);
508
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
509
+ //DEBUG.push("");
417
510
 
418
511
  // If we were unable to resize any of the panels panels, return the previous state.
419
512
  // This will essentially bailout and ignore e.g. drags past a panel's boundaries
420
513
  if (fuzzyNumbersEqual(deltaApplied, 0)) {
514
+ //console.log(DEBUG.join("\n"));
421
515
  return prevLayout;
422
516
  }
423
517
  {
518
+ // Now distribute the applied delta to the panels in the other direction
424
519
  const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
425
520
  const unsafeSize = prevLayout[pivotIndex] + deltaApplied;
426
521
  const safeSize = resizePanel({
@@ -460,29 +555,21 @@ function adjustLayoutByDelta({
460
555
  index++;
461
556
  }
462
557
  }
463
-
464
- // If we can't redistribute, this layout is invalid;
465
- // There may be an incremental layout that is valid though
466
- if (!fuzzyNumbersEqual(deltaRemaining, 0)) {
467
- try {
468
- return adjustLayoutByDelta({
469
- delta: delta < 0 ? delta + 1 : delta - 1,
470
- groupSizePixels,
471
- layout: prevLayout,
472
- panelConstraints,
473
- pivotIndices,
474
- trigger
475
- });
476
- } catch (error) {
477
- if (error instanceof RangeError) {
478
- console.error(`Could not apply delta ${delta} to layout`);
479
- return prevLayout;
480
- }
481
- } finally {
482
- }
483
- }
484
558
  }
485
559
  }
560
+ //DEBUG.push(`after 2: ${nextLayout.join(", ")}`);
561
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
562
+ //DEBUG.push("");
563
+
564
+ const totalSize = nextLayout.reduce((total, size) => size + total, 0);
565
+ deltaApplied = 100 - totalSize;
566
+ //DEBUG.push(`total size: ${totalSize}`);
567
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
568
+ //console.log(DEBUG.join("\n"));
569
+
570
+ if (!fuzzyNumbersEqual(totalSize, 100)) {
571
+ return prevLayout;
572
+ }
486
573
  return nextLayout;
487
574
  }
488
575
 
@@ -518,6 +605,7 @@ function calculateAriaValues({
518
605
 
519
606
  // A panel's effective min/max sizes also need to account for other panel's sizes.
520
607
  panelsArray.forEach((panelData, index) => {
608
+ var _getPercentageSizeFro, _getPercentageSizeFro2;
521
609
  const {
522
610
  constraints
523
611
  } = panelData;
@@ -527,14 +615,14 @@ function calculateAriaValues({
527
615
  minSizePercentage,
528
616
  minSizePixels
529
617
  } = constraints;
530
- const minSize = getPercentageSizeFromMixedSizes({
618
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
531
619
  sizePercentage: minSizePercentage,
532
620
  sizePixels: minSizePixels
533
- }, groupSizePixels) ?? 0;
534
- const maxSize = getPercentageSizeFromMixedSizes({
621
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
622
+ const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
535
623
  sizePercentage: maxSizePercentage,
536
624
  sizePixels: maxSizePixels
537
- }, groupSizePixels) ?? 100;
625
+ }, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
538
626
  if (index === pivotIndices[0]) {
539
627
  currentMinSize = minSize;
540
628
  currentMaxSize = maxSize;
@@ -560,7 +648,7 @@ function getResizeHandleElementsForGroup(groupId) {
560
648
  function getResizeHandleElementIndex(groupId, id) {
561
649
  const handles = getResizeHandleElementsForGroup(groupId);
562
650
  const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
563
- return index ?? null;
651
+ return index !== null && index !== void 0 ? index : null;
564
652
  }
565
653
 
566
654
  function determinePivotIndices(groupId, dragHandleId) {
@@ -569,7 +657,7 @@ function determinePivotIndices(groupId, dragHandleId) {
569
657
  }
570
658
 
571
659
  function getPanelGroupElement(id) {
572
- const element = document.querySelector(`[data-panel-group-id="${id}"]`);
660
+ const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
573
661
  if (element) {
574
662
  return element;
575
663
  }
@@ -621,11 +709,12 @@ function getResizeHandleElement(id) {
621
709
  }
622
710
 
623
711
  function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
712
+ var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
624
713
  const handle = getResizeHandleElement(handleId);
625
714
  const handles = getResizeHandleElementsForGroup(groupId);
626
715
  const index = handle ? handles.indexOf(handle) : -1;
627
- const idBefore = panelsArray[index]?.id ?? null;
628
- const idAfter = panelsArray[index + 1]?.id ?? null;
716
+ const idBefore = (_panelsArray$index$id = (_panelsArray$index = panelsArray[index]) === null || _panelsArray$index === void 0 ? void 0 : _panelsArray$index.id) !== null && _panelsArray$index$id !== void 0 ? _panelsArray$index$id : null;
717
+ const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
629
718
  return [idBefore, idAfter];
630
719
  }
631
720
 
@@ -713,11 +802,12 @@ function useWindowSplitterPanelGroupBehavior({
713
802
  const panelData = panelDataArray[index];
714
803
  const size = layout[index];
715
804
  if (size != null) {
805
+ var _getPercentageSizeFro;
716
806
  const groupSizePixels = getAvailableGroupSizePixels(groupId);
717
- const minSize = getPercentageSizeFromMixedSizes({
807
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
718
808
  sizePercentage: panelData.constraints.minSizePercentage,
719
809
  sizePixels: panelData.constraints.minSizePixels
720
- }, groupSizePixels) ?? 0;
810
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
721
811
  let delta = 0;
722
812
  if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
723
813
  delta = direction === "horizontal" ? width : height;
@@ -922,10 +1012,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
922
1012
  onResize(mixedSizes, lastNotifiedMixedSizes);
923
1013
  }
924
1014
  if (collapsible && (onCollapse || onExpand)) {
925
- const collapsedSize = getPercentageSizeFromMixedSizes({
1015
+ var _getPercentageSizeFro;
1016
+ const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
926
1017
  sizePercentage: constraints.collapsedSizePercentage,
927
1018
  sizePixels: constraints.collapsedSizePixels
928
- }, groupSizePixels) ?? 0;
1019
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
929
1020
  const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
930
1021
  if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
931
1022
  onExpand();
@@ -1091,8 +1182,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
1091
1182
  function loadPanelLayout(autoSaveId, panels, storage) {
1092
1183
  const state = loadSerializedPanelGroupState(autoSaveId, storage);
1093
1184
  if (state) {
1185
+ var _state$key;
1094
1186
  const key = getSerializationKey(panels);
1095
- return state[key] ?? null;
1187
+ return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
1096
1188
  }
1097
1189
  return null;
1098
1190
  }
@@ -1261,6 +1353,7 @@ function PanelGroupWithForwardedRef({
1261
1353
  autoSaveId,
1262
1354
  children,
1263
1355
  className: classNameFromProps = "",
1356
+ dataAttributes,
1264
1357
  direction,
1265
1358
  forwardedRef,
1266
1359
  id: idFromProps,
@@ -1385,6 +1478,10 @@ function PanelGroupWithForwardedRef({
1385
1478
  unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
1386
1479
  }
1387
1480
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1481
+ if (groupSizePixels <= 0) {
1482
+ // Wait until the group has rendered a non-zero size before computing layout.
1483
+ return;
1484
+ }
1388
1485
  if (unsafeLayout == null) {
1389
1486
  unsafeLayout = calculateUnsafeDefaultLayout({
1390
1487
  groupSizePixels,
@@ -1670,7 +1767,7 @@ function PanelGroupWithForwardedRef({
1670
1767
  } = committedValuesRef.current;
1671
1768
  const {
1672
1769
  initialLayout
1673
- } = dragState ?? {};
1770
+ } = dragState !== null && dragState !== void 0 ? dragState : {};
1674
1771
  const pivotIndices = determinePivotIndices(groupId, dragHandleId);
1675
1772
  let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
1676
1773
  percentage: keyboardResizeByPercentage,
@@ -1690,7 +1787,7 @@ function PanelGroupWithForwardedRef({
1690
1787
  const nextLayout = adjustLayoutByDelta({
1691
1788
  delta,
1692
1789
  groupSizePixels,
1693
- layout: initialLayout ?? prevLayout,
1790
+ layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
1694
1791
  panelConstraints,
1695
1792
  pivotIndices,
1696
1793
  trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
@@ -1831,11 +1928,11 @@ function PanelGroupWithForwardedRef({
1831
1928
  ...style,
1832
1929
  ...styleFromProps
1833
1930
  },
1931
+ ...dataAttributes,
1834
1932
  // CSS selectors
1835
1933
  "data-panel-group": "",
1836
- // e2e test attributes
1837
- "data-panel-group-direction": direction ,
1838
- "data-panel-group-id": groupId
1934
+ "data-panel-group-direction": direction,
1935
+ "data-panel-group-id": groupId
1839
1936
  }));
1840
1937
  }
1841
1938
  const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
@@ -1919,6 +2016,7 @@ function useWindowSplitterResizeHandlerBehavior({
1919
2016
  function PanelResizeHandle({
1920
2017
  children = null,
1921
2018
  className: classNameFromProps = "",
2019
+ dataAttributes,
1922
2020
  disabled = false,
1923
2021
  id: idFromProps = null,
1924
2022
  onDragging,
@@ -1947,7 +2045,7 @@ function PanelResizeHandle({
1947
2045
  stopDragging
1948
2046
  } = panelGroupContext;
1949
2047
  const resizeHandleId = useUniqueId(idFromProps);
1950
- const isDragging = dragState?.dragHandleId === resizeHandleId;
2048
+ const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
1951
2049
  const [isFocused, setIsFocused] = useState(false);
1952
2050
  const [resizeHandler, setResizeHandler] = useState(null);
1953
2051
  const stopDraggingAndBlur = useCallback(() => {
@@ -2011,13 +2109,6 @@ function PanelResizeHandle({
2011
2109
  return createElement(Type, {
2012
2110
  children,
2013
2111
  className: classNameFromProps,
2014
- // CSS selectors
2015
- "data-resize-handle": "",
2016
- "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
2017
- "data-panel-group-direction": direction,
2018
- "data-panel-group-id": groupId,
2019
- "data-panel-resize-handle-enabled": !disabled,
2020
- "data-panel-resize-handle-id": resizeHandleId,
2021
2112
  onBlur: () => setIsFocused(false),
2022
2113
  onFocus: () => setIsFocused(true),
2023
2114
  onMouseDown: event => {
@@ -2047,7 +2138,15 @@ function PanelResizeHandle({
2047
2138
  ...style,
2048
2139
  ...styleFromProps
2049
2140
  },
2050
- tabIndex: 0
2141
+ tabIndex: 0,
2142
+ ...dataAttributes,
2143
+ // CSS selectors
2144
+ "data-panel-group-direction": direction,
2145
+ "data-panel-group-id": groupId,
2146
+ "data-resize-handle": "",
2147
+ "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
2148
+ "data-panel-resize-handle-enabled": !disabled,
2149
+ "data-panel-resize-handle-id": resizeHandleId
2051
2150
  });
2052
2151
  }
2053
2152
  PanelResizeHandle.displayName = "PanelResizeHandle";