react-resizable-panels 1.0.7 → 1.0.9

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 (60) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +16 -15
  3. package/dist/declarations/src/Panel.d.ts +3 -3
  4. package/dist/declarations/src/PanelGroup.d.ts +2 -2
  5. package/dist/declarations/src/PanelResizeHandle.d.ts +2 -2
  6. package/dist/declarations/src/index.d.ts +1 -3
  7. package/dist/declarations/src/utils/dom/getPanelElement.d.ts +1 -1
  8. package/dist/declarations/src/utils/dom/getPanelElementsForGroup.d.ts +1 -1
  9. package/dist/declarations/src/utils/dom/getPanelGroupElement.d.ts +1 -1
  10. package/dist/declarations/src/utils/dom/getResizeHandleElement.d.ts +1 -1
  11. package/dist/declarations/src/utils/dom/getResizeHandleElementIndex.d.ts +1 -1
  12. package/dist/declarations/src/utils/dom/getResizeHandleElementsForGroup.d.ts +1 -1
  13. package/dist/declarations/src/utils/dom/getResizeHandlePanelIds.d.ts +1 -1
  14. package/dist/declarations/src/vendor/react.d.ts +2 -2
  15. package/dist/react-resizable-panels.browser.cjs.js +114 -84
  16. package/dist/react-resizable-panels.browser.cjs.mjs +0 -2
  17. package/dist/react-resizable-panels.browser.development.cjs.js +116 -85
  18. package/dist/react-resizable-panels.browser.development.cjs.mjs +0 -2
  19. package/dist/react-resizable-panels.browser.development.esm.js +117 -84
  20. package/dist/react-resizable-panels.browser.esm.js +115 -83
  21. package/dist/react-resizable-panels.cjs.js +114 -84
  22. package/dist/react-resizable-panels.cjs.mjs +0 -2
  23. package/dist/react-resizable-panels.development.cjs.js +116 -85
  24. package/dist/react-resizable-panels.development.cjs.mjs +0 -2
  25. package/dist/react-resizable-panels.development.esm.js +117 -84
  26. package/dist/react-resizable-panels.development.node.cjs.js +102 -83
  27. package/dist/react-resizable-panels.development.node.cjs.mjs +0 -2
  28. package/dist/react-resizable-panels.development.node.esm.js +103 -82
  29. package/dist/react-resizable-panels.esm.js +115 -83
  30. package/dist/react-resizable-panels.node.cjs.js +100 -82
  31. package/dist/react-resizable-panels.node.cjs.mjs +0 -2
  32. package/dist/react-resizable-panels.node.esm.js +101 -81
  33. package/package.json +1 -1
  34. package/src/Panel.test.tsx +137 -2
  35. package/src/Panel.ts +16 -2
  36. package/src/PanelGroup.test.tsx +3 -2
  37. package/src/PanelGroup.ts +95 -35
  38. package/src/PanelGroupContext.ts +9 -3
  39. package/src/PanelResizeHandle.test.tsx +3 -3
  40. package/src/PanelResizeHandle.ts +4 -2
  41. package/src/hooks/useWindowSplitterBehavior.ts +14 -5
  42. package/src/hooks/useWindowSplitterPanelGroupBehavior.ts +23 -7
  43. package/src/index.ts +0 -4
  44. package/src/utils/calculateDeltaPercentage.ts +4 -2
  45. package/src/utils/calculateDragOffsetPercentage.ts +4 -3
  46. package/src/utils/determinePivotIndices.ts +7 -2
  47. package/src/utils/dom/getPanelElement.ts +5 -2
  48. package/src/utils/dom/getPanelElementsForGroup.ts +5 -2
  49. package/src/utils/dom/getPanelGroupElement.ts +14 -2
  50. package/src/utils/dom/getResizeHandleElement.ts +5 -4
  51. package/src/utils/dom/getResizeHandleElementIndex.ts +3 -2
  52. package/src/utils/dom/getResizeHandleElementsForGroup.ts +3 -2
  53. package/src/utils/dom/getResizeHandlePanelIds.ts +4 -3
  54. package/src/utils/validatePanelConstraints.test.ts +45 -0
  55. package/src/utils/validatePanelConstraints.ts +5 -1
  56. package/src/vendor/react.ts +2 -0
  57. package/dist/declarations/src/utils/dom/calculateAvailablePanelSizeInPixels.d.ts +0 -1
  58. package/dist/declarations/src/utils/dom/getAvailableGroupSizePixels.d.ts +0 -1
  59. package/src/utils/dom/calculateAvailablePanelSizeInPixels.ts +0 -29
  60. package/src/utils/dom/getAvailableGroupSizePixels.ts +0 -29
@@ -89,6 +89,7 @@ function PanelWithForwardedRef({
89
89
  getPanelStyle,
90
90
  groupId,
91
91
  isPanelCollapsed,
92
+ reevaluatePanelConstraints,
92
93
  registerPanel,
93
94
  resizePanel,
94
95
  unregisterPanel
@@ -465,41 +466,48 @@ function adjustLayoutByDelta({
465
466
  return nextLayout;
466
467
  }
467
468
 
468
- function getResizeHandleElementsForGroup(groupId) {
469
- return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
469
+ function getResizeHandleElementsForGroup(groupId, scope = document) {
470
+ return Array.from(scope.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
470
471
  }
471
472
 
472
- function getResizeHandleElementIndex(groupId, id) {
473
- const handles = getResizeHandleElementsForGroup(groupId);
473
+ function getResizeHandleElementIndex(groupId, id, scope = document) {
474
+ const handles = getResizeHandleElementsForGroup(groupId, scope);
474
475
  const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
475
476
  return index !== null && index !== void 0 ? index : null;
476
477
  }
477
478
 
478
- function determinePivotIndices(groupId, dragHandleId) {
479
- const index = getResizeHandleElementIndex(groupId, dragHandleId);
479
+ function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
480
+ const index = getResizeHandleElementIndex(groupId, dragHandleId, panelGroupElement);
480
481
  return index != null ? [index, index + 1] : [-1, -1];
481
482
  }
482
483
 
483
- function getPanelGroupElement(id) {
484
- const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
484
+ function getPanelGroupElement(id, rootElement = document) {
485
+ var _dataset;
486
+ //If the root element is the PanelGroup
487
+ if (rootElement instanceof HTMLElement && (rootElement === null || rootElement === void 0 ? void 0 : (_dataset = rootElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.panelGroupId) == id) {
488
+ return rootElement;
489
+ }
490
+
491
+ //Else query children
492
+ const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
485
493
  if (element) {
486
494
  return element;
487
495
  }
488
496
  return null;
489
497
  }
490
498
 
491
- function getResizeHandleElement(id) {
492
- const element = document.querySelector(`[data-panel-resize-handle-id="${id}"]`);
499
+ function getResizeHandleElement(id, scope = document) {
500
+ const element = scope.querySelector(`[data-panel-resize-handle-id="${id}"]`);
493
501
  if (element) {
494
502
  return element;
495
503
  }
496
504
  return null;
497
505
  }
498
506
 
499
- function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
507
+ function getResizeHandlePanelIds(groupId, handleId, panelsArray, scope = document) {
500
508
  var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
501
- const handle = getResizeHandleElement(handleId);
502
- const handles = getResizeHandleElementsForGroup(groupId);
509
+ const handle = getResizeHandleElement(handleId, scope);
510
+ const handles = getResizeHandleElementsForGroup(groupId, scope);
503
511
  const index = handle ? handles.indexOf(handle) : -1;
504
512
  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;
505
513
  const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
@@ -514,25 +522,29 @@ function useWindowSplitterPanelGroupBehavior({
514
522
  groupId,
515
523
  layout,
516
524
  panelDataArray,
525
+ panelGroupElement,
517
526
  setLayout
518
527
  }) {
519
528
  useRef({
520
529
  didWarnAboutMissingResizeHandle: false
521
530
  });
522
531
  useEffect(() => {
532
+ if (!panelGroupElement) {
533
+ return;
534
+ }
523
535
  const eagerValues = eagerValuesRef.current;
524
536
  assert(eagerValues);
525
537
  const {
526
538
  panelDataArray
527
539
  } = eagerValues;
528
- const groupElement = getPanelGroupElement(groupId);
540
+ const groupElement = getPanelGroupElement(groupId, panelGroupElement);
529
541
  assert(groupElement != null, `No group found for id "${groupId}"`);
530
- const handles = getResizeHandleElementsForGroup(groupId);
542
+ const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
531
543
  assert(handles);
532
544
  const cleanupFunctions = handles.map(handle => {
533
545
  const handleId = handle.getAttribute("data-panel-resize-handle-id");
534
546
  assert(handleId);
535
- const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray);
547
+ const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
536
548
  if (idBefore == null || idAfter == null) {
537
549
  return () => {};
538
550
  }
@@ -559,7 +571,7 @@ function useWindowSplitterPanelGroupBehavior({
559
571
  delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
560
572
  layout,
561
573
  panelConstraints: panelDataArray.map(panelData => panelData.constraints),
562
- pivotIndices: determinePivotIndices(groupId, handleId),
574
+ pivotIndices: determinePivotIndices(groupId, handleId, panelGroupElement),
563
575
  trigger: "keyboard"
564
576
  });
565
577
  if (layout !== nextLayout) {
@@ -579,7 +591,7 @@ function useWindowSplitterPanelGroupBehavior({
579
591
  return () => {
580
592
  cleanupFunctions.forEach(cleanupFunction => cleanupFunction());
581
593
  };
582
- }, [committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
594
+ }, [panelGroupElement, committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
583
595
  }
584
596
 
585
597
  function areEqual(arrayA, arrayB) {
@@ -617,9 +629,9 @@ function getResizeEventCursorPosition(direction, event) {
617
629
  }
618
630
  }
619
631
 
620
- function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState) {
632
+ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement) {
621
633
  const isHorizontal = direction === "horizontal";
622
- const handleElement = getResizeHandleElement(dragHandleId);
634
+ const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
623
635
  assert(handleElement);
624
636
  const groupId = handleElement.getAttribute("data-panel-group-id");
625
637
  assert(groupId);
@@ -627,7 +639,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
627
639
  initialCursorPosition
628
640
  } = initialDragState;
629
641
  const cursorPosition = getResizeEventCursorPosition(direction, event);
630
- const groupElement = getPanelGroupElement(groupId);
642
+ const groupElement = getPanelGroupElement(groupId, panelGroupElement);
631
643
  assert(groupElement);
632
644
  const groupRect = groupElement.getBoundingClientRect();
633
645
  const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
@@ -637,7 +649,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
637
649
  }
638
650
 
639
651
  // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX
640
- function calculateDeltaPercentage(event, dragHandleId, direction, initialDragState, keyboardResizeBy) {
652
+ function calculateDeltaPercentage(event, dragHandleId, direction, initialDragState, keyboardResizeBy, panelGroupElement) {
641
653
  if (isKeyDown(event)) {
642
654
  const isHorizontal = direction === "horizontal";
643
655
  let delta = 0;
@@ -674,7 +686,7 @@ function calculateDeltaPercentage(event, dragHandleId, direction, initialDragSta
674
686
  if (initialDragState == null) {
675
687
  return 0;
676
688
  }
677
- return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState);
689
+ return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement);
678
690
  }
679
691
  }
680
692
 
@@ -901,6 +913,7 @@ function validatePanelConstraints({
901
913
  assert(panelConstraints);
902
914
  const {
903
915
  collapsedSize = 0,
916
+ collapsible = false,
904
917
  defaultSize,
905
918
  maxSize = 100,
906
919
  minSize = 0
@@ -911,7 +924,7 @@ function validatePanelConstraints({
911
924
  if (defaultSize != null) {
912
925
  if (defaultSize < 0) {
913
926
  warnings.push("default size should not be less than 0");
914
- } else if (defaultSize < minSize) {
927
+ } else if (defaultSize < minSize && (!collapsible || defaultSize !== collapsedSize)) {
915
928
  warnings.push("default size should not be less than min size");
916
929
  }
917
930
  if (defaultSize > 100) {
@@ -1026,6 +1039,7 @@ function PanelGroupWithForwardedRef({
1026
1039
  ...rest
1027
1040
  }) {
1028
1041
  const groupId = useUniqueId(idFromProps);
1042
+ const panelGroupElementRef = useRef(null);
1029
1043
  const [dragState, setDragState] = useState(null);
1030
1044
  const [layout, setLayout] = useState([]);
1031
1045
  const panelIdToLastNotifiedSizeMapRef = useRef({});
@@ -1086,7 +1100,8 @@ function PanelGroupWithForwardedRef({
1086
1100
  groupId,
1087
1101
  layout,
1088
1102
  panelDataArray: eagerValuesRef.current.panelDataArray,
1089
- setLayout
1103
+ setLayout,
1104
+ panelGroupElement: panelGroupElementRef.current
1090
1105
  });
1091
1106
  useEffect(() => {
1092
1107
  const {
@@ -1323,6 +1338,10 @@ function PanelGroupWithForwardedRef({
1323
1338
  const registerResizeHandle = useCallback(dragHandleId => {
1324
1339
  return function resizeHandler(event) {
1325
1340
  event.preventDefault();
1341
+ const panelGroupElement = panelGroupElementRef.current;
1342
+ if (!panelGroupElement) {
1343
+ return () => null;
1344
+ }
1326
1345
  const {
1327
1346
  direction,
1328
1347
  dragState,
@@ -1337,8 +1356,8 @@ function PanelGroupWithForwardedRef({
1337
1356
  const {
1338
1357
  initialLayout
1339
1358
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1340
- const pivotIndices = determinePivotIndices(groupId, dragHandleId);
1341
- let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy);
1359
+ const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1360
+ let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1342
1361
  if (delta === 0) {
1343
1362
  return;
1344
1363
  }
@@ -1426,6 +1445,37 @@ function PanelGroupWithForwardedRef({
1426
1445
  callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
1427
1446
  }
1428
1447
  }, []);
1448
+ const reevaluatePanelConstraints = useCallback((panelData, prevConstraints) => {
1449
+ const {
1450
+ layout,
1451
+ panelDataArray
1452
+ } = eagerValuesRef.current;
1453
+ const {
1454
+ collapsedSize: prevCollapsedSize = 0,
1455
+ collapsible: prevCollapsible,
1456
+ defaultSize: prevDefaultSize,
1457
+ maxSize: prevMaxSize = 100,
1458
+ minSize: prevMinSize = 0
1459
+ } = prevConstraints;
1460
+ const {
1461
+ collapsedSize: nextCollapsedSize = 0,
1462
+ collapsible: nextCollapsible,
1463
+ defaultSize: nextDefaultSize,
1464
+ maxSize: nextMaxSize = 100,
1465
+ minSize: nextMinSize = 0
1466
+ } = panelData.constraints;
1467
+ const {
1468
+ panelSize: prevPanelSize
1469
+ } = panelDataHelper(panelDataArray, panelData, layout);
1470
+ assert(prevPanelSize != null);
1471
+ if (prevCollapsible && nextCollapsible && prevCollapsedSize !== nextCollapsedSize && prevPanelSize === prevCollapsedSize) {
1472
+ resizePanel(panelData, nextCollapsedSize);
1473
+ } else if (prevPanelSize < nextMinSize) {
1474
+ resizePanel(panelData, nextMinSize);
1475
+ } else if (prevPanelSize > nextMaxSize) {
1476
+ resizePanel(panelData, nextMaxSize);
1477
+ }
1478
+ }, [resizePanel]);
1429
1479
  const startDragging = useCallback((dragHandleId, event) => {
1430
1480
  const {
1431
1481
  direction
@@ -1433,7 +1483,10 @@ function PanelGroupWithForwardedRef({
1433
1483
  const {
1434
1484
  layout
1435
1485
  } = eagerValuesRef.current;
1436
- const handleElement = getResizeHandleElement(dragHandleId);
1486
+ if (!panelGroupElementRef.current) {
1487
+ return;
1488
+ }
1489
+ const handleElement = getResizeHandleElement(dragHandleId, panelGroupElementRef.current);
1437
1490
  assert(handleElement);
1438
1491
  const initialCursorPosition = getResizeEventCursorPosition(direction, event);
1439
1492
  setDragState({
@@ -1473,13 +1526,15 @@ function PanelGroupWithForwardedRef({
1473
1526
  groupId,
1474
1527
  isPanelCollapsed,
1475
1528
  isPanelExpanded,
1529
+ reevaluatePanelConstraints,
1476
1530
  registerPanel,
1477
1531
  registerResizeHandle,
1478
1532
  resizePanel,
1479
1533
  startDragging,
1480
1534
  stopDragging,
1481
- unregisterPanel
1482
- }), [collapsePanel, dragState, direction, expandPanel, getPanelSize, getPanelStyle, groupId, isPanelCollapsed, isPanelExpanded, registerPanel, registerResizeHandle, resizePanel, startDragging, stopDragging, unregisterPanel]);
1535
+ unregisterPanel,
1536
+ panelGroupElement: panelGroupElementRef.current
1537
+ }), [collapsePanel, dragState, direction, expandPanel, getPanelSize, getPanelStyle, groupId, isPanelCollapsed, isPanelExpanded, reevaluatePanelConstraints, registerPanel, registerResizeHandle, resizePanel, startDragging, stopDragging, unregisterPanel]);
1483
1538
  const style = {
1484
1539
  display: "flex",
1485
1540
  flexDirection: direction === "horizontal" ? "row" : "column",
@@ -1497,6 +1552,7 @@ function PanelGroupWithForwardedRef({
1497
1552
  ...style,
1498
1553
  ...styleFromProps
1499
1554
  },
1555
+ ref: panelGroupElementRef,
1500
1556
  // CSS selectors
1501
1557
  "data-panel-group": "",
1502
1558
  "data-panel-group-direction": direction,
@@ -1513,14 +1569,12 @@ function findPanelDataIndex(panelDataArray, panelData) {
1513
1569
  return panelDataArray.findIndex(prevPanelData => prevPanelData === panelData || prevPanelData.id === panelData.id);
1514
1570
  }
1515
1571
  function panelDataHelper(panelDataArray, panelData, layout) {
1516
- const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1517
1572
  const panelIndex = findPanelDataIndex(panelDataArray, panelData);
1518
- const panelConstraints = panelConstraintsArray[panelIndex];
1519
1573
  const isLastPanel = panelIndex === panelDataArray.length - 1;
1520
1574
  const pivotIndices = isLastPanel ? [panelIndex - 1, panelIndex] : [panelIndex, panelIndex + 1];
1521
1575
  const panelSize = layout[panelIndex];
1522
1576
  return {
1523
- ...panelConstraints,
1577
+ ...panelData.constraints,
1524
1578
  panelSize,
1525
1579
  pivotIndices
1526
1580
  };
@@ -1531,13 +1585,14 @@ function panelDataHelper(panelDataArray, panelData, layout) {
1531
1585
  function useWindowSplitterResizeHandlerBehavior({
1532
1586
  disabled,
1533
1587
  handleId,
1534
- resizeHandler
1588
+ resizeHandler,
1589
+ panelGroupElement
1535
1590
  }) {
1536
1591
  useEffect(() => {
1537
- if (disabled || resizeHandler == null) {
1592
+ if (disabled || resizeHandler == null || panelGroupElement == null) {
1538
1593
  return;
1539
1594
  }
1540
- const handleElement = getResizeHandleElement(handleId);
1595
+ const handleElement = getResizeHandleElement(handleId, panelGroupElement);
1541
1596
  if (handleElement == null) {
1542
1597
  return;
1543
1598
  }
@@ -1562,8 +1617,8 @@ function useWindowSplitterResizeHandlerBehavior({
1562
1617
  event.preventDefault();
1563
1618
  const groupId = handleElement.getAttribute("data-panel-group-id");
1564
1619
  assert(groupId);
1565
- const handles = getResizeHandleElementsForGroup(groupId);
1566
- const index = getResizeHandleElementIndex(groupId, handleId);
1620
+ const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
1621
+ const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
1567
1622
  assert(index !== null);
1568
1623
  const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
1569
1624
  const nextHandle = handles[nextIndex];
@@ -1576,7 +1631,7 @@ function useWindowSplitterResizeHandlerBehavior({
1576
1631
  return () => {
1577
1632
  handleElement.removeEventListener("keydown", onKeyDown);
1578
1633
  };
1579
- }, [disabled, handleId, resizeHandler]);
1634
+ }, [panelGroupElement, disabled, handleId, resizeHandler]);
1580
1635
  }
1581
1636
 
1582
1637
  function PanelResizeHandle({
@@ -1609,7 +1664,8 @@ function PanelResizeHandle({
1609
1664
  groupId,
1610
1665
  registerResizeHandle,
1611
1666
  startDragging,
1612
- stopDragging
1667
+ stopDragging,
1668
+ panelGroupElement
1613
1669
  } = panelGroupContext;
1614
1670
  const resizeHandleId = useUniqueId(idFromProps);
1615
1671
  const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
@@ -1668,7 +1724,8 @@ function PanelResizeHandle({
1668
1724
  useWindowSplitterResizeHandlerBehavior({
1669
1725
  disabled,
1670
1726
  handleId: resizeHandleId,
1671
- resizeHandler
1727
+ resizeHandler,
1728
+ panelGroupElement
1672
1729
  });
1673
1730
  const style = {
1674
1731
  cursor: getCursorStyle(direction),
@@ -1724,60 +1781,22 @@ function PanelResizeHandle({
1724
1781
  }
1725
1782
  PanelResizeHandle.displayName = "PanelResizeHandle";
1726
1783
 
1727
- function calculateAvailablePanelSizeInPixels(groupId) {
1728
- const panelGroupElement = getPanelGroupElement(groupId);
1729
- if (panelGroupElement == null) {
1730
- return NaN;
1731
- }
1732
- const direction = panelGroupElement.getAttribute("data-panel-group-direction");
1733
- const resizeHandles = getResizeHandleElementsForGroup(groupId);
1734
- if (direction === "horizontal") {
1735
- return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
1736
- return accumulated + handle.offsetWidth;
1737
- }, 0);
1738
- } else {
1739
- return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
1740
- return accumulated + handle.offsetHeight;
1741
- }, 0);
1742
- }
1743
- }
1744
-
1745
- function getAvailableGroupSizePixels(groupId) {
1746
- const panelGroupElement = getPanelGroupElement(groupId);
1747
- if (panelGroupElement == null) {
1748
- return NaN;
1749
- }
1750
- const direction = panelGroupElement.getAttribute("data-panel-group-direction");
1751
- const resizeHandles = getResizeHandleElementsForGroup(groupId);
1752
- if (direction === "horizontal") {
1753
- return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
1754
- return accumulated + handle.offsetWidth;
1755
- }, 0);
1756
- } else {
1757
- return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
1758
- return accumulated + handle.offsetHeight;
1759
- }, 0);
1760
- }
1761
- }
1762
-
1763
- function getPanelElement(id) {
1764
- const element = document.querySelector(`[data-panel-id="${id}"]`);
1784
+ function getPanelElement(id, scope = document) {
1785
+ const element = scope.querySelector(`[data-panel-id="${id}"]`);
1765
1786
  if (element) {
1766
1787
  return element;
1767
1788
  }
1768
1789
  return null;
1769
1790
  }
1770
1791
 
1771
- function getPanelElementsForGroup(groupId) {
1772
- return Array.from(document.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
1792
+ function getPanelElementsForGroup(groupId, scope = document) {
1793
+ return Array.from(scope.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
1773
1794
  }
1774
1795
 
1775
1796
  exports.Panel = Panel;
1776
1797
  exports.PanelGroup = PanelGroup;
1777
1798
  exports.PanelResizeHandle = PanelResizeHandle;
1778
1799
  exports.assert = assert;
1779
- exports.calculateAvailablePanelSizeInPixels = calculateAvailablePanelSizeInPixels;
1780
- exports.getAvailableGroupSizePixels = getAvailableGroupSizePixels;
1781
1800
  exports.getPanelElement = getPanelElement;
1782
1801
  exports.getPanelElementsForGroup = getPanelElementsForGroup;
1783
1802
  exports.getPanelGroupElement = getPanelGroupElement;
@@ -3,8 +3,6 @@ export {
3
3
  PanelGroup,
4
4
  PanelResizeHandle,
5
5
  assert,
6
- calculateAvailablePanelSizeInPixels,
7
- getAvailableGroupSizePixels,
8
6
  getPanelElement,
9
7
  getPanelElementsForGroup,
10
8
  getPanelGroupElement,