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