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
@@ -37,7 +37,7 @@ function useUniqueId(idFromParams = null) {
37
37
  if (idRef.current === null) {
38
38
  idRef.current = "" + counter++;
39
39
  }
40
- return idFromParams ?? idRef.current;
40
+ return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
41
41
  }
42
42
 
43
43
  function PanelWithForwardedRef({
@@ -46,6 +46,7 @@ function PanelWithForwardedRef({
46
46
  collapsedSizePercentage,
47
47
  collapsedSizePixels,
48
48
  collapsible,
49
+ dataAttributes,
49
50
  defaultSizePercentage,
50
51
  defaultSizePixels,
51
52
  forwardedRef,
@@ -170,11 +171,12 @@ function PanelWithForwardedRef({
170
171
  ...style,
171
172
  ...styleFromProps
172
173
  },
174
+ ...dataAttributes,
173
175
  // CSS selectors
174
176
  "data-panel": "",
177
+ "data-panel-id": panelId,
175
178
  // e2e test attributes
176
179
  "data-panel-collapsible": collapsible || undefined ,
177
- "data-panel-id": panelId ,
178
180
  "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
179
181
  });
180
182
  }
@@ -202,6 +204,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
202
204
  minSizePercentage = 0,
203
205
  minSizePixels
204
206
  } = panelConstraints;
207
+ const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
208
+ if (hasPixelConstraints && groupSizePixels <= 0) {
209
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
210
+ return {
211
+ collapsedSizePercentage: 0,
212
+ defaultSizePercentage,
213
+ maxSizePercentage: 0,
214
+ minSizePercentage: 0
215
+ };
216
+ }
205
217
  if (collapsedSizePixels != null) {
206
218
  collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
207
219
  }
@@ -276,6 +288,16 @@ function resizePanel({
276
288
  panelIndex,
277
289
  size
278
290
  }) {
291
+ const hasPixelConstraints = panelConstraints.some(({
292
+ collapsedSizePixels,
293
+ defaultSizePixels,
294
+ minSizePixels,
295
+ maxSizePixels
296
+ }) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
297
+ if (hasPixelConstraints && groupSizePixels <= 0) {
298
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
299
+ return 0;
300
+ }
279
301
  let {
280
302
  collapsible
281
303
  } = panelConstraints[panelIndex];
@@ -287,7 +309,13 @@ function resizePanel({
287
309
  if (minSizePercentage != null) {
288
310
  if (fuzzyCompareNumbers(size, minSizePercentage) < 0) {
289
311
  if (collapsible) {
290
- size = collapsedSizePercentage;
312
+ // Collapsible panels should snap closed or open only once they cross the halfway point between collapsed and min size.
313
+ const halfwayPoint = (collapsedSizePercentage + minSizePercentage) / 2;
314
+ if (fuzzyCompareNumbers(size, halfwayPoint) < 0) {
315
+ size = collapsedSizePercentage;
316
+ } else {
317
+ size = minSizePercentage;
318
+ }
291
319
  } else {
292
320
  size = minSizePercentage;
293
321
  }
@@ -314,61 +342,123 @@ function adjustLayoutByDelta({
314
342
  const nextLayout = [...prevLayout];
315
343
  let deltaApplied = 0;
316
344
 
345
+ //const DEBUG = [];
346
+ //DEBUG.push(`adjustLayoutByDelta() ${prevLayout.join(", ")}`);
347
+ //DEBUG.push(` delta: ${delta}`);
348
+ //DEBUG.push(` pivotIndices: ${pivotIndices.join(", ")}`);
349
+ //DEBUG.push(` trigger: ${trigger}`);
350
+ //DEBUG.push("");
351
+
317
352
  // A resizing panel affects the panels before or after it.
318
353
  //
319
- // A negative delta means the panel immediately after the resizer should grow/expand by decreasing its offset.
354
+ // A negative delta means the panel(s) immediately after the resize handle should grow/expand by decreasing its offset.
320
355
  // Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
321
356
  //
322
- // A positive delta means the panel immediately before the resizer should "expand".
323
- // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resizer.
357
+ // A positive delta means the panel(s) immediately before the resize handle should "expand".
358
+ // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resize handle.
324
359
 
325
- // First, check the panel we're pivoting around;
326
- // We should only expand or contract by as much as its constraints allow
327
360
  {
328
- const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
329
- const initialSize = nextLayout[pivotIndex];
330
- const {
331
- collapsible
332
- } = panelConstraints[pivotIndex];
333
- const {
334
- collapsedSizePercentage,
335
- maxSizePercentage,
336
- minSizePercentage
337
- } = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
338
- const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
339
- let unsafeSize = initialSize + Math.abs(delta);
340
- if (isCollapsed) {
341
- switch (trigger) {
342
- case "keyboard":
343
- if (minSizePercentage > unsafeSize) {
344
- unsafeSize = minSizePercentage;
361
+ // If this is a resize triggered by a keyboard event, our logic for expanding/collapsing is different.
362
+ // We no longer check the halfway threshold because this may prevent the panel from expanding at all.
363
+ if (trigger === "keyboard") {
364
+ {
365
+ // Check if we should expand a collapsed panel
366
+ const index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
367
+ const constraints = panelConstraints[index];
368
+ //DEBUG.push(`edge case check 1: ${index}`);
369
+ //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
370
+ if (constraints.collapsible) {
371
+ const prevSize = prevLayout[index];
372
+ const {
373
+ collapsedSizePercentage,
374
+ minSizePercentage
375
+ } = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
376
+ if (fuzzyNumbersEqual(prevSize, collapsedSizePercentage)) {
377
+ const localDelta = minSizePercentage - prevSize;
378
+ //DEBUG.push(` -> expand delta: ${localDelta}`);
379
+
380
+ if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
381
+ delta = delta < 0 ? 0 - localDelta : localDelta;
382
+ //DEBUG.push(` -> delta: ${delta}`);
383
+ }
345
384
  }
385
+ }
386
+ }
387
+
388
+ {
389
+ // Check if we should collapse a panel at its minimum size
390
+ const index = delta < 0 ? pivotIndices[0] : pivotIndices[1];
391
+ const constraints = panelConstraints[index];
392
+ //DEBUG.push(`edge case check 2: ${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, minSizePercentage)) {
401
+ const localDelta = prevSize - collapsedSizePercentage;
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
+ }
408
+ }
409
+ }
346
410
  }
347
411
  }
348
- const safeSize = resizePanel({
349
- groupSizePixels,
350
- panelConstraints,
351
- panelIndex: pivotIndex,
352
- size: unsafeSize
353
- });
354
- if (fuzzyNumbersEqual(initialSize, safeSize)) {
355
- // If there's no room for the pivot panel to grow, we should ignore this change
356
- return nextLayout;
357
- } else {
358
- delta = delta < 0 ? initialSize - safeSize : safeSize - initialSize;
412
+ //DEBUG.push("");
413
+ }
414
+
415
+ {
416
+ // Pre-calculate max available delta in the opposite direction of our pivot.
417
+ // This will be the maximum amount we're allowed to expand/contract the panels in the primary direction.
418
+ // If this amount is less than the requested delta, adjust the requested delta.
419
+ // If this amount is greater than the requested delta, that's useful information too–
420
+ // as an expanding panel might change from collapsed to min size.
421
+
422
+ const increment = delta < 0 ? 1 : -1;
423
+ let index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
424
+ let maxAvailableDelta = 0;
425
+
426
+ //DEBUG.push("pre calc...");
427
+ while (true) {
428
+ const prevSize = prevLayout[index];
429
+ const maxSafeSize = resizePanel({
430
+ groupSizePixels,
431
+ panelConstraints,
432
+ panelIndex: index,
433
+ size: 100
434
+ });
435
+ const delta = maxSafeSize - prevSize;
436
+ //DEBUG.push(` ${index}: ${prevSize} -> ${maxSafeSize}`);
437
+
438
+ maxAvailableDelta += delta;
439
+ index += increment;
440
+ if (index < 0 || index >= panelConstraints.length) {
441
+ break;
442
+ }
359
443
  }
444
+
445
+ //DEBUG.push(` -> max available delta: ${maxAvailableDelta}`);
446
+ const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
447
+ delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
448
+ //DEBUG.push(` -> adjusted delta: ${delta}`);
449
+ //DEBUG.push("");
360
450
  }
361
451
 
362
- // Delta added to a panel needs to be subtracted from other panels
363
- // within the constraints that those panels allow
364
452
  {
453
+ // Delta added to a panel needs to be subtracted from other panels (within the constraints that those panels allow).
454
+
365
455
  const pivotIndex = delta < 0 ? pivotIndices[0] : pivotIndices[1];
366
456
  let index = pivotIndex;
367
457
  while (index >= 0 && index < panelConstraints.length) {
368
458
  const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
369
459
  const prevSize = prevLayout[index];
370
460
  const unsafeSize = prevSize - deltaRemaining;
371
- let safeSize = resizePanel({
461
+ const safeSize = resizePanel({
372
462
  groupSizePixels,
373
463
  panelConstraints,
374
464
  panelIndex: index,
@@ -390,13 +480,18 @@ function adjustLayoutByDelta({
390
480
  }
391
481
  }
392
482
  }
483
+ //DEBUG.push(`after 1: ${nextLayout.join(", ")}`);
484
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
485
+ //DEBUG.push("");
393
486
 
394
487
  // If we were unable to resize any of the panels panels, return the previous state.
395
488
  // This will essentially bailout and ignore e.g. drags past a panel's boundaries
396
489
  if (fuzzyNumbersEqual(deltaApplied, 0)) {
490
+ //console.log(DEBUG.join("\n"));
397
491
  return prevLayout;
398
492
  }
399
493
  {
494
+ // Now distribute the applied delta to the panels in the other direction
400
495
  const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
401
496
  const unsafeSize = prevLayout[pivotIndex] + deltaApplied;
402
497
  const safeSize = resizePanel({
@@ -436,29 +531,21 @@ function adjustLayoutByDelta({
436
531
  index++;
437
532
  }
438
533
  }
439
-
440
- // If we can't redistribute, this layout is invalid;
441
- // There may be an incremental layout that is valid though
442
- if (!fuzzyNumbersEqual(deltaRemaining, 0)) {
443
- try {
444
- return adjustLayoutByDelta({
445
- delta: delta < 0 ? delta + 1 : delta - 1,
446
- groupSizePixels,
447
- layout: prevLayout,
448
- panelConstraints,
449
- pivotIndices,
450
- trigger
451
- });
452
- } catch (error) {
453
- if (error instanceof RangeError) {
454
- console.error(`Could not apply delta ${delta} to layout`);
455
- return prevLayout;
456
- }
457
- } finally {
458
- }
459
- }
460
534
  }
461
535
  }
536
+ //DEBUG.push(`after 2: ${nextLayout.join(", ")}`);
537
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
538
+ //DEBUG.push("");
539
+
540
+ const totalSize = nextLayout.reduce((total, size) => size + total, 0);
541
+ deltaApplied = 100 - totalSize;
542
+ //DEBUG.push(`total size: ${totalSize}`);
543
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
544
+ //console.log(DEBUG.join("\n"));
545
+
546
+ if (!fuzzyNumbersEqual(totalSize, 100)) {
547
+ return prevLayout;
548
+ }
462
549
  return nextLayout;
463
550
  }
464
551
 
@@ -494,6 +581,7 @@ function calculateAriaValues({
494
581
 
495
582
  // A panel's effective min/max sizes also need to account for other panel's sizes.
496
583
  panelsArray.forEach((panelData, index) => {
584
+ var _getPercentageSizeFro, _getPercentageSizeFro2;
497
585
  const {
498
586
  constraints
499
587
  } = panelData;
@@ -503,14 +591,14 @@ function calculateAriaValues({
503
591
  minSizePercentage,
504
592
  minSizePixels
505
593
  } = constraints;
506
- const minSize = getPercentageSizeFromMixedSizes({
594
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
507
595
  sizePercentage: minSizePercentage,
508
596
  sizePixels: minSizePixels
509
- }, groupSizePixels) ?? 0;
510
- const maxSize = getPercentageSizeFromMixedSizes({
597
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
598
+ const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
511
599
  sizePercentage: maxSizePercentage,
512
600
  sizePixels: maxSizePixels
513
- }, groupSizePixels) ?? 100;
601
+ }, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
514
602
  if (index === pivotIndices[0]) {
515
603
  currentMinSize = minSize;
516
604
  currentMaxSize = maxSize;
@@ -536,7 +624,7 @@ function getResizeHandleElementsForGroup(groupId) {
536
624
  function getResizeHandleElementIndex(groupId, id) {
537
625
  const handles = getResizeHandleElementsForGroup(groupId);
538
626
  const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
539
- return index ?? null;
627
+ return index !== null && index !== void 0 ? index : null;
540
628
  }
541
629
 
542
630
  function determinePivotIndices(groupId, dragHandleId) {
@@ -545,7 +633,7 @@ function determinePivotIndices(groupId, dragHandleId) {
545
633
  }
546
634
 
547
635
  function getPanelGroupElement(id) {
548
- const element = document.querySelector(`[data-panel-group-id="${id}"]`);
636
+ const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
549
637
  if (element) {
550
638
  return element;
551
639
  }
@@ -597,11 +685,12 @@ function getResizeHandleElement(id) {
597
685
  }
598
686
 
599
687
  function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
688
+ var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
600
689
  const handle = getResizeHandleElement(handleId);
601
690
  const handles = getResizeHandleElementsForGroup(groupId);
602
691
  const index = handle ? handles.indexOf(handle) : -1;
603
- const idBefore = panelsArray[index]?.id ?? null;
604
- const idAfter = panelsArray[index + 1]?.id ?? null;
692
+ 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;
693
+ const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
605
694
  return [idBefore, idAfter];
606
695
  }
607
696
 
@@ -689,11 +778,12 @@ function useWindowSplitterPanelGroupBehavior({
689
778
  const panelData = panelDataArray[index];
690
779
  const size = layout[index];
691
780
  if (size != null) {
781
+ var _getPercentageSizeFro;
692
782
  const groupSizePixels = getAvailableGroupSizePixels(groupId);
693
- const minSize = getPercentageSizeFromMixedSizes({
783
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
694
784
  sizePercentage: panelData.constraints.minSizePercentage,
695
785
  sizePixels: panelData.constraints.minSizePixels
696
- }, groupSizePixels) ?? 0;
786
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
697
787
  let delta = 0;
698
788
  if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
699
789
  delta = direction === "horizontal" ? width : height;
@@ -898,10 +988,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
898
988
  onResize(mixedSizes, lastNotifiedMixedSizes);
899
989
  }
900
990
  if (collapsible && (onCollapse || onExpand)) {
901
- const collapsedSize = getPercentageSizeFromMixedSizes({
991
+ var _getPercentageSizeFro;
992
+ const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
902
993
  sizePercentage: constraints.collapsedSizePercentage,
903
994
  sizePixels: constraints.collapsedSizePixels
904
- }, groupSizePixels) ?? 0;
995
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
905
996
  const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
906
997
  if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
907
998
  onExpand();
@@ -1067,8 +1158,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
1067
1158
  function loadPanelLayout(autoSaveId, panels, storage) {
1068
1159
  const state = loadSerializedPanelGroupState(autoSaveId, storage);
1069
1160
  if (state) {
1161
+ var _state$key;
1070
1162
  const key = getSerializationKey(panels);
1071
- return state[key] ?? null;
1163
+ return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
1072
1164
  }
1073
1165
  return null;
1074
1166
  }
@@ -1237,6 +1329,7 @@ function PanelGroupWithForwardedRef({
1237
1329
  autoSaveId,
1238
1330
  children,
1239
1331
  className: classNameFromProps = "",
1332
+ dataAttributes,
1240
1333
  direction,
1241
1334
  forwardedRef,
1242
1335
  id: idFromProps,
@@ -1361,6 +1454,10 @@ function PanelGroupWithForwardedRef({
1361
1454
  unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
1362
1455
  }
1363
1456
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1457
+ if (groupSizePixels <= 0) {
1458
+ // Wait until the group has rendered a non-zero size before computing layout.
1459
+ return;
1460
+ }
1364
1461
  if (unsafeLayout == null) {
1365
1462
  unsafeLayout = calculateUnsafeDefaultLayout({
1366
1463
  groupSizePixels,
@@ -1646,7 +1743,7 @@ function PanelGroupWithForwardedRef({
1646
1743
  } = committedValuesRef.current;
1647
1744
  const {
1648
1745
  initialLayout
1649
- } = dragState ?? {};
1746
+ } = dragState !== null && dragState !== void 0 ? dragState : {};
1650
1747
  const pivotIndices = determinePivotIndices(groupId, dragHandleId);
1651
1748
  let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
1652
1749
  percentage: keyboardResizeByPercentage,
@@ -1666,7 +1763,7 @@ function PanelGroupWithForwardedRef({
1666
1763
  const nextLayout = adjustLayoutByDelta({
1667
1764
  delta,
1668
1765
  groupSizePixels,
1669
- layout: initialLayout ?? prevLayout,
1766
+ layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
1670
1767
  panelConstraints,
1671
1768
  pivotIndices,
1672
1769
  trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
@@ -1807,11 +1904,11 @@ function PanelGroupWithForwardedRef({
1807
1904
  ...style,
1808
1905
  ...styleFromProps
1809
1906
  },
1907
+ ...dataAttributes,
1810
1908
  // CSS selectors
1811
1909
  "data-panel-group": "",
1812
- // e2e test attributes
1813
- "data-panel-group-direction": direction ,
1814
- "data-panel-group-id": groupId
1910
+ "data-panel-group-direction": direction,
1911
+ "data-panel-group-id": groupId
1815
1912
  }));
1816
1913
  }
1817
1914
  const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
@@ -1895,6 +1992,7 @@ function useWindowSplitterResizeHandlerBehavior({
1895
1992
  function PanelResizeHandle({
1896
1993
  children = null,
1897
1994
  className: classNameFromProps = "",
1995
+ dataAttributes,
1898
1996
  disabled = false,
1899
1997
  id: idFromProps = null,
1900
1998
  onDragging,
@@ -1923,7 +2021,7 @@ function PanelResizeHandle({
1923
2021
  stopDragging
1924
2022
  } = panelGroupContext;
1925
2023
  const resizeHandleId = useUniqueId(idFromProps);
1926
- const isDragging = dragState?.dragHandleId === resizeHandleId;
2024
+ const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
1927
2025
  const [isFocused, setIsFocused] = useState(false);
1928
2026
  const [resizeHandler, setResizeHandler] = useState(null);
1929
2027
  const stopDraggingAndBlur = useCallback(() => {
@@ -1987,13 +2085,6 @@ function PanelResizeHandle({
1987
2085
  return createElement(Type, {
1988
2086
  children,
1989
2087
  className: classNameFromProps,
1990
- // CSS selectors
1991
- "data-resize-handle": "",
1992
- "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
1993
- "data-panel-group-direction": direction,
1994
- "data-panel-group-id": groupId,
1995
- "data-panel-resize-handle-enabled": !disabled,
1996
- "data-panel-resize-handle-id": resizeHandleId,
1997
2088
  onBlur: () => setIsFocused(false),
1998
2089
  onFocus: () => setIsFocused(true),
1999
2090
  onMouseDown: event => {
@@ -2023,7 +2114,15 @@ function PanelResizeHandle({
2023
2114
  ...style,
2024
2115
  ...styleFromProps
2025
2116
  },
2026
- tabIndex: 0
2117
+ tabIndex: 0,
2118
+ ...dataAttributes,
2119
+ // CSS selectors
2120
+ "data-panel-group-direction": direction,
2121
+ "data-panel-group-id": groupId,
2122
+ "data-resize-handle": "",
2123
+ "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
2124
+ "data-panel-resize-handle-enabled": !disabled,
2125
+ "data-panel-resize-handle-id": resizeHandleId
2027
2126
  });
2028
2127
  }
2029
2128
  PanelResizeHandle.displayName = "PanelResizeHandle";