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,
@@ -159,11 +160,12 @@ function PanelWithForwardedRef({
159
160
  ...style,
160
161
  ...styleFromProps
161
162
  },
163
+ ...dataAttributes,
162
164
  // CSS selectors
163
165
  "data-panel": "",
166
+ "data-panel-id": panelId,
164
167
  // e2e test attributes
165
168
  "data-panel-collapsible": undefined,
166
- "data-panel-id": undefined,
167
169
  "data-panel-size": undefined
168
170
  });
169
171
  }
@@ -191,6 +193,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
191
193
  minSizePercentage = 0,
192
194
  minSizePixels
193
195
  } = panelConstraints;
196
+ const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
197
+ if (hasPixelConstraints && groupSizePixels <= 0) {
198
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
199
+ return {
200
+ collapsedSizePercentage: 0,
201
+ defaultSizePercentage,
202
+ maxSizePercentage: 0,
203
+ minSizePercentage: 0
204
+ };
205
+ }
194
206
  if (collapsedSizePixels != null) {
195
207
  collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
196
208
  }
@@ -265,6 +277,16 @@ function resizePanel({
265
277
  panelIndex,
266
278
  size
267
279
  }) {
280
+ const hasPixelConstraints = panelConstraints.some(({
281
+ collapsedSizePixels,
282
+ defaultSizePixels,
283
+ minSizePixels,
284
+ maxSizePixels
285
+ }) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
286
+ if (hasPixelConstraints && groupSizePixels <= 0) {
287
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
288
+ return 0;
289
+ }
268
290
  let {
269
291
  collapsible
270
292
  } = panelConstraints[panelIndex];
@@ -276,7 +298,13 @@ function resizePanel({
276
298
  if (minSizePercentage != null) {
277
299
  if (fuzzyCompareNumbers(size, minSizePercentage) < 0) {
278
300
  if (collapsible) {
279
- size = collapsedSizePercentage;
301
+ // Collapsible panels should snap closed or open only once they cross the halfway point between collapsed and min size.
302
+ const halfwayPoint = (collapsedSizePercentage + minSizePercentage) / 2;
303
+ if (fuzzyCompareNumbers(size, halfwayPoint) < 0) {
304
+ size = collapsedSizePercentage;
305
+ } else {
306
+ size = minSizePercentage;
307
+ }
280
308
  } else {
281
309
  size = minSizePercentage;
282
310
  }
@@ -303,61 +331,123 @@ function adjustLayoutByDelta({
303
331
  const nextLayout = [...prevLayout];
304
332
  let deltaApplied = 0;
305
333
 
334
+ //const DEBUG = [];
335
+ //DEBUG.push(`adjustLayoutByDelta() ${prevLayout.join(", ")}`);
336
+ //DEBUG.push(` delta: ${delta}`);
337
+ //DEBUG.push(` pivotIndices: ${pivotIndices.join(", ")}`);
338
+ //DEBUG.push(` trigger: ${trigger}`);
339
+ //DEBUG.push("");
340
+
306
341
  // A resizing panel affects the panels before or after it.
307
342
  //
308
- // A negative delta means the panel immediately after the resizer should grow/expand by decreasing its offset.
343
+ // A negative delta means the panel(s) immediately after the resize handle should grow/expand by decreasing its offset.
309
344
  // Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
310
345
  //
311
- // A positive delta means the panel immediately before the resizer should "expand".
312
- // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resizer.
346
+ // A positive delta means the panel(s) immediately before the resize handle should "expand".
347
+ // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resize handle.
313
348
 
314
- // First, check the panel we're pivoting around;
315
- // We should only expand or contract by as much as its constraints allow
316
349
  {
317
- const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
318
- const initialSize = nextLayout[pivotIndex];
319
- const {
320
- collapsible
321
- } = panelConstraints[pivotIndex];
322
- const {
323
- collapsedSizePercentage,
324
- maxSizePercentage,
325
- minSizePercentage
326
- } = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
327
- const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
328
- let unsafeSize = initialSize + Math.abs(delta);
329
- if (isCollapsed) {
330
- switch (trigger) {
331
- case "keyboard":
332
- if (minSizePercentage > unsafeSize) {
333
- unsafeSize = minSizePercentage;
350
+ // If this is a resize triggered by a keyboard event, our logic for expanding/collapsing is different.
351
+ // We no longer check the halfway threshold because this may prevent the panel from expanding at all.
352
+ if (trigger === "keyboard") {
353
+ {
354
+ // Check if we should expand a collapsed panel
355
+ const index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
356
+ const constraints = panelConstraints[index];
357
+ //DEBUG.push(`edge case check 1: ${index}`);
358
+ //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
359
+ if (constraints.collapsible) {
360
+ const prevSize = prevLayout[index];
361
+ const {
362
+ collapsedSizePercentage,
363
+ minSizePercentage
364
+ } = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
365
+ if (fuzzyNumbersEqual(prevSize, collapsedSizePercentage)) {
366
+ const localDelta = minSizePercentage - prevSize;
367
+ //DEBUG.push(` -> expand delta: ${localDelta}`);
368
+
369
+ if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
370
+ delta = delta < 0 ? 0 - localDelta : localDelta;
371
+ //DEBUG.push(` -> delta: ${delta}`);
372
+ }
334
373
  }
374
+ }
375
+ }
376
+
377
+ {
378
+ // Check if we should collapse a panel at its minimum size
379
+ const index = delta < 0 ? pivotIndices[0] : pivotIndices[1];
380
+ const constraints = panelConstraints[index];
381
+ //DEBUG.push(`edge case check 2: ${index}`);
382
+ //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
383
+ if (constraints.collapsible) {
384
+ const prevSize = prevLayout[index];
385
+ const {
386
+ collapsedSizePercentage,
387
+ minSizePercentage
388
+ } = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
389
+ if (fuzzyNumbersEqual(prevSize, minSizePercentage)) {
390
+ const localDelta = prevSize - collapsedSizePercentage;
391
+ //DEBUG.push(` -> expand delta: ${localDelta}`);
392
+
393
+ if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
394
+ delta = delta < 0 ? 0 - localDelta : localDelta;
395
+ //DEBUG.push(` -> delta: ${delta}`);
396
+ }
397
+ }
398
+ }
335
399
  }
336
400
  }
337
- const safeSize = resizePanel({
338
- groupSizePixels,
339
- panelConstraints,
340
- panelIndex: pivotIndex,
341
- size: unsafeSize
342
- });
343
- if (fuzzyNumbersEqual(initialSize, safeSize)) {
344
- // If there's no room for the pivot panel to grow, we should ignore this change
345
- return nextLayout;
346
- } else {
347
- delta = delta < 0 ? initialSize - safeSize : safeSize - initialSize;
401
+ //DEBUG.push("");
402
+ }
403
+
404
+ {
405
+ // Pre-calculate max available delta in the opposite direction of our pivot.
406
+ // This will be the maximum amount we're allowed to expand/contract the panels in the primary direction.
407
+ // If this amount is less than the requested delta, adjust the requested delta.
408
+ // If this amount is greater than the requested delta, that's useful information too–
409
+ // as an expanding panel might change from collapsed to min size.
410
+
411
+ const increment = delta < 0 ? 1 : -1;
412
+ let index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
413
+ let maxAvailableDelta = 0;
414
+
415
+ //DEBUG.push("pre calc...");
416
+ while (true) {
417
+ const prevSize = prevLayout[index];
418
+ const maxSafeSize = resizePanel({
419
+ groupSizePixels,
420
+ panelConstraints,
421
+ panelIndex: index,
422
+ size: 100
423
+ });
424
+ const delta = maxSafeSize - prevSize;
425
+ //DEBUG.push(` ${index}: ${prevSize} -> ${maxSafeSize}`);
426
+
427
+ maxAvailableDelta += delta;
428
+ index += increment;
429
+ if (index < 0 || index >= panelConstraints.length) {
430
+ break;
431
+ }
348
432
  }
433
+
434
+ //DEBUG.push(` -> max available delta: ${maxAvailableDelta}`);
435
+ const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
436
+ delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
437
+ //DEBUG.push(` -> adjusted delta: ${delta}`);
438
+ //DEBUG.push("");
349
439
  }
350
440
 
351
- // Delta added to a panel needs to be subtracted from other panels
352
- // within the constraints that those panels allow
353
441
  {
442
+ // Delta added to a panel needs to be subtracted from other panels (within the constraints that those panels allow).
443
+
354
444
  const pivotIndex = delta < 0 ? pivotIndices[0] : pivotIndices[1];
355
445
  let index = pivotIndex;
356
446
  while (index >= 0 && index < panelConstraints.length) {
357
447
  const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
358
448
  const prevSize = prevLayout[index];
359
449
  const unsafeSize = prevSize - deltaRemaining;
360
- let safeSize = resizePanel({
450
+ const safeSize = resizePanel({
361
451
  groupSizePixels,
362
452
  panelConstraints,
363
453
  panelIndex: index,
@@ -379,13 +469,18 @@ function adjustLayoutByDelta({
379
469
  }
380
470
  }
381
471
  }
472
+ //DEBUG.push(`after 1: ${nextLayout.join(", ")}`);
473
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
474
+ //DEBUG.push("");
382
475
 
383
476
  // If we were unable to resize any of the panels panels, return the previous state.
384
477
  // This will essentially bailout and ignore e.g. drags past a panel's boundaries
385
478
  if (fuzzyNumbersEqual(deltaApplied, 0)) {
479
+ //console.log(DEBUG.join("\n"));
386
480
  return prevLayout;
387
481
  }
388
482
  {
483
+ // Now distribute the applied delta to the panels in the other direction
389
484
  const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
390
485
  const unsafeSize = prevLayout[pivotIndex] + deltaApplied;
391
486
  const safeSize = resizePanel({
@@ -425,29 +520,21 @@ function adjustLayoutByDelta({
425
520
  index++;
426
521
  }
427
522
  }
428
-
429
- // If we can't redistribute, this layout is invalid;
430
- // There may be an incremental layout that is valid though
431
- if (!fuzzyNumbersEqual(deltaRemaining, 0)) {
432
- try {
433
- return adjustLayoutByDelta({
434
- delta: delta < 0 ? delta + 1 : delta - 1,
435
- groupSizePixels,
436
- layout: prevLayout,
437
- panelConstraints,
438
- pivotIndices,
439
- trigger
440
- });
441
- } catch (error) {
442
- if (error instanceof RangeError) {
443
- console.error(`Could not apply delta ${delta} to layout`);
444
- return prevLayout;
445
- }
446
- } finally {
447
- }
448
- }
449
523
  }
450
524
  }
525
+ //DEBUG.push(`after 2: ${nextLayout.join(", ")}`);
526
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
527
+ //DEBUG.push("");
528
+
529
+ const totalSize = nextLayout.reduce((total, size) => size + total, 0);
530
+ deltaApplied = 100 - totalSize;
531
+ //DEBUG.push(`total size: ${totalSize}`);
532
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
533
+ //console.log(DEBUG.join("\n"));
534
+
535
+ if (!fuzzyNumbersEqual(totalSize, 100)) {
536
+ return prevLayout;
537
+ }
451
538
  return nextLayout;
452
539
  }
453
540
 
@@ -483,6 +570,7 @@ function calculateAriaValues({
483
570
 
484
571
  // A panel's effective min/max sizes also need to account for other panel's sizes.
485
572
  panelsArray.forEach((panelData, index) => {
573
+ var _getPercentageSizeFro, _getPercentageSizeFro2;
486
574
  const {
487
575
  constraints
488
576
  } = panelData;
@@ -492,14 +580,14 @@ function calculateAriaValues({
492
580
  minSizePercentage,
493
581
  minSizePixels
494
582
  } = constraints;
495
- const minSize = getPercentageSizeFromMixedSizes({
583
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
496
584
  sizePercentage: minSizePercentage,
497
585
  sizePixels: minSizePixels
498
- }, groupSizePixels) ?? 0;
499
- const maxSize = getPercentageSizeFromMixedSizes({
586
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
587
+ const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
500
588
  sizePercentage: maxSizePercentage,
501
589
  sizePixels: maxSizePixels
502
- }, groupSizePixels) ?? 100;
590
+ }, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
503
591
  if (index === pivotIndices[0]) {
504
592
  currentMinSize = minSize;
505
593
  currentMaxSize = maxSize;
@@ -525,7 +613,7 @@ function getResizeHandleElementsForGroup(groupId) {
525
613
  function getResizeHandleElementIndex(groupId, id) {
526
614
  const handles = getResizeHandleElementsForGroup(groupId);
527
615
  const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
528
- return index ?? null;
616
+ return index !== null && index !== void 0 ? index : null;
529
617
  }
530
618
 
531
619
  function determinePivotIndices(groupId, dragHandleId) {
@@ -534,7 +622,7 @@ function determinePivotIndices(groupId, dragHandleId) {
534
622
  }
535
623
 
536
624
  function getPanelGroupElement(id) {
537
- const element = document.querySelector(`[data-panel-group-id="${id}"]`);
625
+ const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
538
626
  if (element) {
539
627
  return element;
540
628
  }
@@ -586,11 +674,12 @@ function getResizeHandleElement(id) {
586
674
  }
587
675
 
588
676
  function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
677
+ var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
589
678
  const handle = getResizeHandleElement(handleId);
590
679
  const handles = getResizeHandleElementsForGroup(groupId);
591
680
  const index = handle ? handles.indexOf(handle) : -1;
592
- const idBefore = panelsArray[index]?.id ?? null;
593
- const idAfter = panelsArray[index + 1]?.id ?? null;
681
+ 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;
682
+ const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
594
683
  return [idBefore, idAfter];
595
684
  }
596
685
 
@@ -668,11 +757,12 @@ function useWindowSplitterPanelGroupBehavior({
668
757
  const panelData = panelDataArray[index];
669
758
  const size = layout[index];
670
759
  if (size != null) {
760
+ var _getPercentageSizeFro;
671
761
  const groupSizePixels = getAvailableGroupSizePixels(groupId);
672
- const minSize = getPercentageSizeFromMixedSizes({
762
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
673
763
  sizePercentage: panelData.constraints.minSizePercentage,
674
764
  sizePixels: panelData.constraints.minSizePixels
675
- }, groupSizePixels) ?? 0;
765
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
676
766
  let delta = 0;
677
767
  if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
678
768
  delta = direction === "horizontal" ? width : height;
@@ -877,10 +967,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
877
967
  onResize(mixedSizes, lastNotifiedMixedSizes);
878
968
  }
879
969
  if (collapsible && (onCollapse || onExpand)) {
880
- const collapsedSize = getPercentageSizeFromMixedSizes({
970
+ var _getPercentageSizeFro;
971
+ const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
881
972
  sizePercentage: constraints.collapsedSizePercentage,
882
973
  sizePixels: constraints.collapsedSizePixels
883
- }, groupSizePixels) ?? 0;
974
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
884
975
  const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
885
976
  if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
886
977
  onExpand();
@@ -1046,8 +1137,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
1046
1137
  function loadPanelLayout(autoSaveId, panels, storage) {
1047
1138
  const state = loadSerializedPanelGroupState(autoSaveId, storage);
1048
1139
  if (state) {
1140
+ var _state$key;
1049
1141
  const key = getSerializationKey(panels);
1050
- return state[key] ?? null;
1142
+ return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
1051
1143
  }
1052
1144
  return null;
1053
1145
  }
@@ -1139,6 +1231,7 @@ function PanelGroupWithForwardedRef({
1139
1231
  autoSaveId,
1140
1232
  children,
1141
1233
  className: classNameFromProps = "",
1234
+ dataAttributes,
1142
1235
  direction,
1143
1236
  forwardedRef,
1144
1237
  id: idFromProps,
@@ -1263,6 +1356,10 @@ function PanelGroupWithForwardedRef({
1263
1356
  unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
1264
1357
  }
1265
1358
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1359
+ if (groupSizePixels <= 0) {
1360
+ // Wait until the group has rendered a non-zero size before computing layout.
1361
+ return;
1362
+ }
1266
1363
  if (unsafeLayout == null) {
1267
1364
  unsafeLayout = calculateUnsafeDefaultLayout({
1268
1365
  groupSizePixels,
@@ -1506,7 +1603,7 @@ function PanelGroupWithForwardedRef({
1506
1603
  } = committedValuesRef.current;
1507
1604
  const {
1508
1605
  initialLayout
1509
- } = dragState ?? {};
1606
+ } = dragState !== null && dragState !== void 0 ? dragState : {};
1510
1607
  const pivotIndices = determinePivotIndices(groupId, dragHandleId);
1511
1608
  let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
1512
1609
  percentage: keyboardResizeByPercentage,
@@ -1526,7 +1623,7 @@ function PanelGroupWithForwardedRef({
1526
1623
  const nextLayout = adjustLayoutByDelta({
1527
1624
  delta,
1528
1625
  groupSizePixels,
1529
- layout: initialLayout ?? prevLayout,
1626
+ layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
1530
1627
  panelConstraints,
1531
1628
  pivotIndices,
1532
1629
  trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
@@ -1667,11 +1764,11 @@ function PanelGroupWithForwardedRef({
1667
1764
  ...style,
1668
1765
  ...styleFromProps
1669
1766
  },
1767
+ ...dataAttributes,
1670
1768
  // CSS selectors
1671
1769
  "data-panel-group": "",
1672
- // e2e test attributes
1673
- "data-panel-group-direction": undefined,
1674
- "data-panel-group-id": undefined
1770
+ "data-panel-group-direction": direction,
1771
+ "data-panel-group-id": groupId
1675
1772
  }));
1676
1773
  }
1677
1774
  const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
@@ -1755,6 +1852,7 @@ function useWindowSplitterResizeHandlerBehavior({
1755
1852
  function PanelResizeHandle({
1756
1853
  children = null,
1757
1854
  className: classNameFromProps = "",
1855
+ dataAttributes,
1758
1856
  disabled = false,
1759
1857
  id: idFromProps = null,
1760
1858
  onDragging,
@@ -1783,7 +1881,7 @@ function PanelResizeHandle({
1783
1881
  stopDragging
1784
1882
  } = panelGroupContext;
1785
1883
  const resizeHandleId = useUniqueId(idFromProps);
1786
- const isDragging = dragState?.dragHandleId === resizeHandleId;
1884
+ const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
1787
1885
  const [isFocused, setIsFocused] = useState(false);
1788
1886
  const [resizeHandler, setResizeHandler] = useState(null);
1789
1887
  const stopDraggingAndBlur = useCallback(() => {
@@ -1847,13 +1945,6 @@ function PanelResizeHandle({
1847
1945
  return createElement(Type, {
1848
1946
  children,
1849
1947
  className: classNameFromProps,
1850
- // CSS selectors
1851
- "data-resize-handle": "",
1852
- "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
1853
- "data-panel-group-direction": direction,
1854
- "data-panel-group-id": groupId,
1855
- "data-panel-resize-handle-enabled": !disabled,
1856
- "data-panel-resize-handle-id": resizeHandleId,
1857
1948
  onBlur: () => setIsFocused(false),
1858
1949
  onFocus: () => setIsFocused(true),
1859
1950
  onMouseDown: event => {
@@ -1883,7 +1974,15 @@ function PanelResizeHandle({
1883
1974
  ...style,
1884
1975
  ...styleFromProps
1885
1976
  },
1886
- tabIndex: 0
1977
+ tabIndex: 0,
1978
+ ...dataAttributes,
1979
+ // CSS selectors
1980
+ "data-panel-group-direction": direction,
1981
+ "data-panel-group-id": groupId,
1982
+ "data-resize-handle": "",
1983
+ "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
1984
+ "data-panel-resize-handle-enabled": !disabled,
1985
+ "data-panel-resize-handle-id": resizeHandleId
1887
1986
  });
1888
1987
  }
1889
1988
  PanelResizeHandle.displayName = "PanelResizeHandle";