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
@@ -59,7 +59,7 @@ function useUniqueId(idFromParams = null) {
59
59
  if (idRef.current === null) {
60
60
  idRef.current = "" + counter++;
61
61
  }
62
- return idFromParams ?? idRef.current;
62
+ return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
63
63
  }
64
64
 
65
65
  function PanelWithForwardedRef({
@@ -68,6 +68,7 @@ function PanelWithForwardedRef({
68
68
  collapsedSizePercentage,
69
69
  collapsedSizePixels,
70
70
  collapsible,
71
+ dataAttributes,
71
72
  defaultSizePercentage,
72
73
  defaultSizePixels,
73
74
  forwardedRef,
@@ -187,11 +188,12 @@ function PanelWithForwardedRef({
187
188
  ...style,
188
189
  ...styleFromProps
189
190
  },
191
+ ...dataAttributes,
190
192
  // CSS selectors
191
193
  "data-panel": "",
194
+ "data-panel-id": panelId,
192
195
  // e2e test attributes
193
196
  "data-panel-collapsible": collapsible || undefined ,
194
- "data-panel-id": panelId ,
195
197
  "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
196
198
  });
197
199
  }
@@ -219,6 +221,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
219
221
  minSizePercentage = 0,
220
222
  minSizePixels
221
223
  } = panelConstraints;
224
+ const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
225
+ if (hasPixelConstraints && groupSizePixels <= 0) {
226
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
227
+ return {
228
+ collapsedSizePercentage: 0,
229
+ defaultSizePercentage,
230
+ maxSizePercentage: 0,
231
+ minSizePercentage: 0
232
+ };
233
+ }
222
234
  if (collapsedSizePixels != null) {
223
235
  collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
224
236
  }
@@ -293,6 +305,16 @@ function resizePanel({
293
305
  panelIndex,
294
306
  size
295
307
  }) {
308
+ const hasPixelConstraints = panelConstraints.some(({
309
+ collapsedSizePixels,
310
+ defaultSizePixels,
311
+ minSizePixels,
312
+ maxSizePixels
313
+ }) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
314
+ if (hasPixelConstraints && groupSizePixels <= 0) {
315
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
316
+ return 0;
317
+ }
296
318
  let {
297
319
  collapsible
298
320
  } = panelConstraints[panelIndex];
@@ -304,7 +326,13 @@ function resizePanel({
304
326
  if (minSizePercentage != null) {
305
327
  if (fuzzyCompareNumbers(size, minSizePercentage) < 0) {
306
328
  if (collapsible) {
307
- size = collapsedSizePercentage;
329
+ // Collapsible panels should snap closed or open only once they cross the halfway point between collapsed and min size.
330
+ const halfwayPoint = (collapsedSizePercentage + minSizePercentage) / 2;
331
+ if (fuzzyCompareNumbers(size, halfwayPoint) < 0) {
332
+ size = collapsedSizePercentage;
333
+ } else {
334
+ size = minSizePercentage;
335
+ }
308
336
  } else {
309
337
  size = minSizePercentage;
310
338
  }
@@ -331,61 +359,123 @@ function adjustLayoutByDelta({
331
359
  const nextLayout = [...prevLayout];
332
360
  let deltaApplied = 0;
333
361
 
362
+ //const DEBUG = [];
363
+ //DEBUG.push(`adjustLayoutByDelta() ${prevLayout.join(", ")}`);
364
+ //DEBUG.push(` delta: ${delta}`);
365
+ //DEBUG.push(` pivotIndices: ${pivotIndices.join(", ")}`);
366
+ //DEBUG.push(` trigger: ${trigger}`);
367
+ //DEBUG.push("");
368
+
334
369
  // A resizing panel affects the panels before or after it.
335
370
  //
336
- // A negative delta means the panel immediately after the resizer should grow/expand by decreasing its offset.
371
+ // A negative delta means the panel(s) immediately after the resize handle should grow/expand by decreasing its offset.
337
372
  // Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
338
373
  //
339
- // A positive delta means the panel immediately before the resizer should "expand".
340
- // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resizer.
374
+ // A positive delta means the panel(s) immediately before the resize handle should "expand".
375
+ // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resize handle.
341
376
 
342
- // First, check the panel we're pivoting around;
343
- // We should only expand or contract by as much as its constraints allow
344
377
  {
345
- const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
346
- const initialSize = nextLayout[pivotIndex];
347
- const {
348
- collapsible
349
- } = panelConstraints[pivotIndex];
350
- const {
351
- collapsedSizePercentage,
352
- maxSizePercentage,
353
- minSizePercentage
354
- } = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
355
- const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
356
- let unsafeSize = initialSize + Math.abs(delta);
357
- if (isCollapsed) {
358
- switch (trigger) {
359
- case "keyboard":
360
- if (minSizePercentage > unsafeSize) {
361
- unsafeSize = minSizePercentage;
378
+ // If this is a resize triggered by a keyboard event, our logic for expanding/collapsing is different.
379
+ // We no longer check the halfway threshold because this may prevent the panel from expanding at all.
380
+ if (trigger === "keyboard") {
381
+ {
382
+ // Check if we should expand a collapsed panel
383
+ const index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
384
+ const constraints = panelConstraints[index];
385
+ //DEBUG.push(`edge case check 1: ${index}`);
386
+ //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
387
+ if (constraints.collapsible) {
388
+ const prevSize = prevLayout[index];
389
+ const {
390
+ collapsedSizePercentage,
391
+ minSizePercentage
392
+ } = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
393
+ if (fuzzyNumbersEqual(prevSize, collapsedSizePercentage)) {
394
+ const localDelta = minSizePercentage - prevSize;
395
+ //DEBUG.push(` -> expand delta: ${localDelta}`);
396
+
397
+ if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
398
+ delta = delta < 0 ? 0 - localDelta : localDelta;
399
+ //DEBUG.push(` -> delta: ${delta}`);
400
+ }
362
401
  }
402
+ }
403
+ }
404
+
405
+ {
406
+ // Check if we should collapse a panel at its minimum size
407
+ const index = delta < 0 ? pivotIndices[0] : pivotIndices[1];
408
+ const constraints = panelConstraints[index];
409
+ //DEBUG.push(`edge case check 2: ${index}`);
410
+ //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
411
+ if (constraints.collapsible) {
412
+ const prevSize = prevLayout[index];
413
+ const {
414
+ collapsedSizePercentage,
415
+ minSizePercentage
416
+ } = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
417
+ if (fuzzyNumbersEqual(prevSize, minSizePercentage)) {
418
+ const localDelta = prevSize - collapsedSizePercentage;
419
+ //DEBUG.push(` -> expand delta: ${localDelta}`);
420
+
421
+ if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
422
+ delta = delta < 0 ? 0 - localDelta : localDelta;
423
+ //DEBUG.push(` -> delta: ${delta}`);
424
+ }
425
+ }
426
+ }
363
427
  }
364
428
  }
365
- const safeSize = resizePanel({
366
- groupSizePixels,
367
- panelConstraints,
368
- panelIndex: pivotIndex,
369
- size: unsafeSize
370
- });
371
- if (fuzzyNumbersEqual(initialSize, safeSize)) {
372
- // If there's no room for the pivot panel to grow, we should ignore this change
373
- return nextLayout;
374
- } else {
375
- delta = delta < 0 ? initialSize - safeSize : safeSize - initialSize;
429
+ //DEBUG.push("");
430
+ }
431
+
432
+ {
433
+ // Pre-calculate max available delta in the opposite direction of our pivot.
434
+ // This will be the maximum amount we're allowed to expand/contract the panels in the primary direction.
435
+ // If this amount is less than the requested delta, adjust the requested delta.
436
+ // If this amount is greater than the requested delta, that's useful information too–
437
+ // as an expanding panel might change from collapsed to min size.
438
+
439
+ const increment = delta < 0 ? 1 : -1;
440
+ let index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
441
+ let maxAvailableDelta = 0;
442
+
443
+ //DEBUG.push("pre calc...");
444
+ while (true) {
445
+ const prevSize = prevLayout[index];
446
+ const maxSafeSize = resizePanel({
447
+ groupSizePixels,
448
+ panelConstraints,
449
+ panelIndex: index,
450
+ size: 100
451
+ });
452
+ const delta = maxSafeSize - prevSize;
453
+ //DEBUG.push(` ${index}: ${prevSize} -> ${maxSafeSize}`);
454
+
455
+ maxAvailableDelta += delta;
456
+ index += increment;
457
+ if (index < 0 || index >= panelConstraints.length) {
458
+ break;
459
+ }
376
460
  }
461
+
462
+ //DEBUG.push(` -> max available delta: ${maxAvailableDelta}`);
463
+ const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
464
+ delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
465
+ //DEBUG.push(` -> adjusted delta: ${delta}`);
466
+ //DEBUG.push("");
377
467
  }
378
468
 
379
- // Delta added to a panel needs to be subtracted from other panels
380
- // within the constraints that those panels allow
381
469
  {
470
+ // Delta added to a panel needs to be subtracted from other panels (within the constraints that those panels allow).
471
+
382
472
  const pivotIndex = delta < 0 ? pivotIndices[0] : pivotIndices[1];
383
473
  let index = pivotIndex;
384
474
  while (index >= 0 && index < panelConstraints.length) {
385
475
  const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
386
476
  const prevSize = prevLayout[index];
387
477
  const unsafeSize = prevSize - deltaRemaining;
388
- let safeSize = resizePanel({
478
+ const safeSize = resizePanel({
389
479
  groupSizePixels,
390
480
  panelConstraints,
391
481
  panelIndex: index,
@@ -407,13 +497,18 @@ function adjustLayoutByDelta({
407
497
  }
408
498
  }
409
499
  }
500
+ //DEBUG.push(`after 1: ${nextLayout.join(", ")}`);
501
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
502
+ //DEBUG.push("");
410
503
 
411
504
  // If we were unable to resize any of the panels panels, return the previous state.
412
505
  // This will essentially bailout and ignore e.g. drags past a panel's boundaries
413
506
  if (fuzzyNumbersEqual(deltaApplied, 0)) {
507
+ //console.log(DEBUG.join("\n"));
414
508
  return prevLayout;
415
509
  }
416
510
  {
511
+ // Now distribute the applied delta to the panels in the other direction
417
512
  const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
418
513
  const unsafeSize = prevLayout[pivotIndex] + deltaApplied;
419
514
  const safeSize = resizePanel({
@@ -453,29 +548,21 @@ function adjustLayoutByDelta({
453
548
  index++;
454
549
  }
455
550
  }
456
-
457
- // If we can't redistribute, this layout is invalid;
458
- // There may be an incremental layout that is valid though
459
- if (!fuzzyNumbersEqual(deltaRemaining, 0)) {
460
- try {
461
- return adjustLayoutByDelta({
462
- delta: delta < 0 ? delta + 1 : delta - 1,
463
- groupSizePixels,
464
- layout: prevLayout,
465
- panelConstraints,
466
- pivotIndices,
467
- trigger
468
- });
469
- } catch (error) {
470
- if (error instanceof RangeError) {
471
- console.error(`Could not apply delta ${delta} to layout`);
472
- return prevLayout;
473
- }
474
- } finally {
475
- }
476
- }
477
551
  }
478
552
  }
553
+ //DEBUG.push(`after 2: ${nextLayout.join(", ")}`);
554
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
555
+ //DEBUG.push("");
556
+
557
+ const totalSize = nextLayout.reduce((total, size) => size + total, 0);
558
+ deltaApplied = 100 - totalSize;
559
+ //DEBUG.push(`total size: ${totalSize}`);
560
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
561
+ //console.log(DEBUG.join("\n"));
562
+
563
+ if (!fuzzyNumbersEqual(totalSize, 100)) {
564
+ return prevLayout;
565
+ }
479
566
  return nextLayout;
480
567
  }
481
568
 
@@ -511,6 +598,7 @@ function calculateAriaValues({
511
598
 
512
599
  // A panel's effective min/max sizes also need to account for other panel's sizes.
513
600
  panelsArray.forEach((panelData, index) => {
601
+ var _getPercentageSizeFro, _getPercentageSizeFro2;
514
602
  const {
515
603
  constraints
516
604
  } = panelData;
@@ -520,14 +608,14 @@ function calculateAriaValues({
520
608
  minSizePercentage,
521
609
  minSizePixels
522
610
  } = constraints;
523
- const minSize = getPercentageSizeFromMixedSizes({
611
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
524
612
  sizePercentage: minSizePercentage,
525
613
  sizePixels: minSizePixels
526
- }, groupSizePixels) ?? 0;
527
- const maxSize = getPercentageSizeFromMixedSizes({
614
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
615
+ const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
528
616
  sizePercentage: maxSizePercentage,
529
617
  sizePixels: maxSizePixels
530
- }, groupSizePixels) ?? 100;
618
+ }, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
531
619
  if (index === pivotIndices[0]) {
532
620
  currentMinSize = minSize;
533
621
  currentMaxSize = maxSize;
@@ -553,7 +641,7 @@ function getResizeHandleElementsForGroup(groupId) {
553
641
  function getResizeHandleElementIndex(groupId, id) {
554
642
  const handles = getResizeHandleElementsForGroup(groupId);
555
643
  const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
556
- return index ?? null;
644
+ return index !== null && index !== void 0 ? index : null;
557
645
  }
558
646
 
559
647
  function determinePivotIndices(groupId, dragHandleId) {
@@ -562,7 +650,7 @@ function determinePivotIndices(groupId, dragHandleId) {
562
650
  }
563
651
 
564
652
  function getPanelGroupElement(id) {
565
- const element = document.querySelector(`[data-panel-group-id="${id}"]`);
653
+ const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
566
654
  if (element) {
567
655
  return element;
568
656
  }
@@ -614,11 +702,12 @@ function getResizeHandleElement(id) {
614
702
  }
615
703
 
616
704
  function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
705
+ var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
617
706
  const handle = getResizeHandleElement(handleId);
618
707
  const handles = getResizeHandleElementsForGroup(groupId);
619
708
  const index = handle ? handles.indexOf(handle) : -1;
620
- const idBefore = panelsArray[index]?.id ?? null;
621
- const idAfter = panelsArray[index + 1]?.id ?? null;
709
+ 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;
710
+ const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
622
711
  return [idBefore, idAfter];
623
712
  }
624
713
 
@@ -706,11 +795,12 @@ function useWindowSplitterPanelGroupBehavior({
706
795
  const panelData = panelDataArray[index];
707
796
  const size = layout[index];
708
797
  if (size != null) {
798
+ var _getPercentageSizeFro;
709
799
  const groupSizePixels = getAvailableGroupSizePixels(groupId);
710
- const minSize = getPercentageSizeFromMixedSizes({
800
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
711
801
  sizePercentage: panelData.constraints.minSizePercentage,
712
802
  sizePixels: panelData.constraints.minSizePixels
713
- }, groupSizePixels) ?? 0;
803
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
714
804
  let delta = 0;
715
805
  if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
716
806
  delta = direction === "horizontal" ? width : height;
@@ -915,10 +1005,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
915
1005
  onResize(mixedSizes, lastNotifiedMixedSizes);
916
1006
  }
917
1007
  if (collapsible && (onCollapse || onExpand)) {
918
- const collapsedSize = getPercentageSizeFromMixedSizes({
1008
+ var _getPercentageSizeFro;
1009
+ const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
919
1010
  sizePercentage: constraints.collapsedSizePercentage,
920
1011
  sizePixels: constraints.collapsedSizePixels
921
- }, groupSizePixels) ?? 0;
1012
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
922
1013
  const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
923
1014
  if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
924
1015
  onExpand();
@@ -1084,8 +1175,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
1084
1175
  function loadPanelLayout(autoSaveId, panels, storage) {
1085
1176
  const state = loadSerializedPanelGroupState(autoSaveId, storage);
1086
1177
  if (state) {
1178
+ var _state$key;
1087
1179
  const key = getSerializationKey(panels);
1088
- return state[key] ?? null;
1180
+ return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
1089
1181
  }
1090
1182
  return null;
1091
1183
  }
@@ -1254,6 +1346,7 @@ function PanelGroupWithForwardedRef({
1254
1346
  autoSaveId,
1255
1347
  children,
1256
1348
  className: classNameFromProps = "",
1349
+ dataAttributes,
1257
1350
  direction,
1258
1351
  forwardedRef,
1259
1352
  id: idFromProps,
@@ -1378,6 +1471,10 @@ function PanelGroupWithForwardedRef({
1378
1471
  unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
1379
1472
  }
1380
1473
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1474
+ if (groupSizePixels <= 0) {
1475
+ // Wait until the group has rendered a non-zero size before computing layout.
1476
+ return;
1477
+ }
1381
1478
  if (unsafeLayout == null) {
1382
1479
  unsafeLayout = calculateUnsafeDefaultLayout({
1383
1480
  groupSizePixels,
@@ -1663,7 +1760,7 @@ function PanelGroupWithForwardedRef({
1663
1760
  } = committedValuesRef.current;
1664
1761
  const {
1665
1762
  initialLayout
1666
- } = dragState ?? {};
1763
+ } = dragState !== null && dragState !== void 0 ? dragState : {};
1667
1764
  const pivotIndices = determinePivotIndices(groupId, dragHandleId);
1668
1765
  let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
1669
1766
  percentage: keyboardResizeByPercentage,
@@ -1683,7 +1780,7 @@ function PanelGroupWithForwardedRef({
1683
1780
  const nextLayout = adjustLayoutByDelta({
1684
1781
  delta,
1685
1782
  groupSizePixels,
1686
- layout: initialLayout ?? prevLayout,
1783
+ layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
1687
1784
  panelConstraints,
1688
1785
  pivotIndices,
1689
1786
  trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
@@ -1824,11 +1921,11 @@ function PanelGroupWithForwardedRef({
1824
1921
  ...style,
1825
1922
  ...styleFromProps
1826
1923
  },
1924
+ ...dataAttributes,
1827
1925
  // CSS selectors
1828
1926
  "data-panel-group": "",
1829
- // e2e test attributes
1830
- "data-panel-group-direction": direction ,
1831
- "data-panel-group-id": groupId
1927
+ "data-panel-group-direction": direction,
1928
+ "data-panel-group-id": groupId
1832
1929
  }));
1833
1930
  }
1834
1931
  const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
@@ -1912,6 +2009,7 @@ function useWindowSplitterResizeHandlerBehavior({
1912
2009
  function PanelResizeHandle({
1913
2010
  children = null,
1914
2011
  className: classNameFromProps = "",
2012
+ dataAttributes,
1915
2013
  disabled = false,
1916
2014
  id: idFromProps = null,
1917
2015
  onDragging,
@@ -1940,7 +2038,7 @@ function PanelResizeHandle({
1940
2038
  stopDragging
1941
2039
  } = panelGroupContext;
1942
2040
  const resizeHandleId = useUniqueId(idFromProps);
1943
- const isDragging = dragState?.dragHandleId === resizeHandleId;
2041
+ const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
1944
2042
  const [isFocused, setIsFocused] = useState(false);
1945
2043
  const [resizeHandler, setResizeHandler] = useState(null);
1946
2044
  const stopDraggingAndBlur = useCallback(() => {
@@ -2004,13 +2102,6 @@ function PanelResizeHandle({
2004
2102
  return createElement(Type, {
2005
2103
  children,
2006
2104
  className: classNameFromProps,
2007
- // CSS selectors
2008
- "data-resize-handle": "",
2009
- "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
2010
- "data-panel-group-direction": direction,
2011
- "data-panel-group-id": groupId,
2012
- "data-panel-resize-handle-enabled": !disabled,
2013
- "data-panel-resize-handle-id": resizeHandleId,
2014
2105
  onBlur: () => setIsFocused(false),
2015
2106
  onFocus: () => setIsFocused(true),
2016
2107
  onMouseDown: event => {
@@ -2040,7 +2131,15 @@ function PanelResizeHandle({
2040
2131
  ...style,
2041
2132
  ...styleFromProps
2042
2133
  },
2043
- tabIndex: 0
2134
+ tabIndex: 0,
2135
+ ...dataAttributes,
2136
+ // CSS selectors
2137
+ "data-panel-group-direction": direction,
2138
+ "data-panel-group-id": groupId,
2139
+ "data-resize-handle": "",
2140
+ "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
2141
+ "data-panel-resize-handle-enabled": !disabled,
2142
+ "data-panel-resize-handle-id": resizeHandleId
2044
2143
  });
2045
2144
  }
2046
2145
  PanelResizeHandle.displayName = "PanelResizeHandle";