react-resizable-panels 1.0.7 → 1.0.8
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.
- package/CHANGELOG.md +6 -0
- package/dist/declarations/src/Panel.d.ts +3 -3
- package/dist/declarations/src/PanelGroup.d.ts +2 -2
- package/dist/declarations/src/PanelResizeHandle.d.ts +2 -2
- package/dist/declarations/src/utils/dom/calculateAvailablePanelSizeInPixels.d.ts +1 -1
- package/dist/declarations/src/utils/dom/getAvailableGroupSizePixels.d.ts +1 -1
- package/dist/declarations/src/utils/dom/getPanelElement.d.ts +1 -1
- package/dist/declarations/src/utils/dom/getPanelElementsForGroup.d.ts +1 -1
- package/dist/declarations/src/utils/dom/getPanelGroupElement.d.ts +1 -1
- package/dist/declarations/src/utils/dom/getResizeHandleElement.d.ts +1 -1
- package/dist/declarations/src/utils/dom/getResizeHandleElementIndex.d.ts +1 -1
- package/dist/declarations/src/utils/dom/getResizeHandleElementsForGroup.d.ts +1 -1
- package/dist/declarations/src/utils/dom/getResizeHandlePanelIds.d.ts +1 -1
- package/dist/declarations/src/vendor/react.d.ts +2 -2
- package/dist/react-resizable-panels.browser.cjs.js +74 -51
- package/dist/react-resizable-panels.browser.development.cjs.js +76 -52
- package/dist/react-resizable-panels.browser.development.esm.js +76 -52
- package/dist/react-resizable-panels.browser.esm.js +74 -51
- package/dist/react-resizable-panels.cjs.js +74 -51
- package/dist/react-resizable-panels.development.cjs.js +76 -52
- package/dist/react-resizable-panels.development.esm.js +76 -52
- package/dist/react-resizable-panels.development.node.cjs.js +71 -50
- package/dist/react-resizable-panels.development.node.esm.js +71 -50
- package/dist/react-resizable-panels.esm.js +74 -51
- package/dist/react-resizable-panels.node.cjs.js +69 -49
- package/dist/react-resizable-panels.node.esm.js +69 -49
- package/package.json +1 -1
- package/src/Panel.test.tsx +3 -2
- package/src/Panel.ts +2 -2
- package/src/PanelGroup.test.tsx +3 -2
- package/src/PanelGroup.ts +48 -28
- package/src/PanelGroupContext.ts +4 -2
- package/src/PanelResizeHandle.test.tsx +3 -3
- package/src/PanelResizeHandle.ts +4 -2
- package/src/hooks/useWindowSplitterBehavior.ts +14 -5
- package/src/hooks/useWindowSplitterPanelGroupBehavior.ts +23 -7
- package/src/utils/calculateDeltaPercentage.ts +4 -2
- package/src/utils/calculateDragOffsetPercentage.ts +4 -3
- package/src/utils/determinePivotIndices.ts +7 -2
- package/src/utils/dom/calculateAvailablePanelSizeInPixels.ts +8 -3
- package/src/utils/dom/getAvailableGroupSizePixels.ts +8 -7
- package/src/utils/dom/getPanelElement.ts +5 -2
- package/src/utils/dom/getPanelElementsForGroup.ts +7 -2
- package/src/utils/dom/getPanelGroupElement.ts +14 -2
- package/src/utils/dom/getResizeHandleElement.ts +5 -2
- package/src/utils/dom/getResizeHandleElementIndex.ts +3 -2
- package/src/utils/dom/getResizeHandleElementsForGroup.ts +3 -2
- package/src/utils/dom/getResizeHandlePanelIds.ts +4 -3
- package/src/utils/validatePanelConstraints.test.ts +45 -0
- package/src/utils/validatePanelConstraints.ts +5 -1
- package/src/vendor/react.ts +2 -0
|
@@ -501,41 +501,48 @@ function calculateAriaValues({
|
|
|
501
501
|
};
|
|
502
502
|
}
|
|
503
503
|
|
|
504
|
-
function getResizeHandleElementsForGroup(groupId) {
|
|
505
|
-
return Array.from(
|
|
504
|
+
function getResizeHandleElementsForGroup(groupId, panelGroupElement) {
|
|
505
|
+
return Array.from(panelGroupElement.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
|
|
506
506
|
}
|
|
507
507
|
|
|
508
|
-
function getResizeHandleElementIndex(groupId, id) {
|
|
509
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
508
|
+
function getResizeHandleElementIndex(groupId, id, panelGroupElement) {
|
|
509
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
510
510
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
511
511
|
return index !== null && index !== void 0 ? index : null;
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
-
function determinePivotIndices(groupId, dragHandleId) {
|
|
515
|
-
const index = getResizeHandleElementIndex(groupId, dragHandleId);
|
|
514
|
+
function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
|
|
515
|
+
const index = getResizeHandleElementIndex(groupId, dragHandleId, panelGroupElement);
|
|
516
516
|
return index != null ? [index, index + 1] : [-1, -1];
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
-
function getPanelGroupElement(id) {
|
|
520
|
-
|
|
519
|
+
function getPanelGroupElement(id, rootElement) {
|
|
520
|
+
var _dataset;
|
|
521
|
+
//If the root element is the PanelGroup
|
|
522
|
+
if (rootElement instanceof HTMLElement && (rootElement === null || rootElement === void 0 ? void 0 : (_dataset = rootElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.panelGroupId) == id) {
|
|
523
|
+
return rootElement;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
//Else query children
|
|
527
|
+
const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
521
528
|
if (element) {
|
|
522
529
|
return element;
|
|
523
530
|
}
|
|
524
531
|
return null;
|
|
525
532
|
}
|
|
526
533
|
|
|
527
|
-
function getResizeHandleElement(id) {
|
|
528
|
-
const element =
|
|
534
|
+
function getResizeHandleElement(id, panelGroupElement) {
|
|
535
|
+
const element = panelGroupElement.querySelector(`[data-panel-resize-handle-id="${id}"]`);
|
|
529
536
|
if (element) {
|
|
530
537
|
return element;
|
|
531
538
|
}
|
|
532
539
|
return null;
|
|
533
540
|
}
|
|
534
541
|
|
|
535
|
-
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
542
|
+
function getResizeHandlePanelIds(groupId, handleId, panelsArray, panelGroupElement) {
|
|
536
543
|
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
537
|
-
const handle = getResizeHandleElement(handleId);
|
|
538
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
544
|
+
const handle = getResizeHandleElement(handleId, panelGroupElement);
|
|
545
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
539
546
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
540
547
|
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;
|
|
541
548
|
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
@@ -550,13 +557,17 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
550
557
|
groupId,
|
|
551
558
|
layout,
|
|
552
559
|
panelDataArray,
|
|
560
|
+
panelGroupElement,
|
|
553
561
|
setLayout
|
|
554
562
|
}) {
|
|
555
563
|
const devWarningsRef = useRef({
|
|
556
564
|
didWarnAboutMissingResizeHandle: false
|
|
557
565
|
});
|
|
558
566
|
useIsomorphicLayoutEffect(() => {
|
|
559
|
-
|
|
567
|
+
if (!panelGroupElement) {
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
const resizeHandleElements = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
560
571
|
for (let index = 0; index < panelDataArray.length - 1; index++) {
|
|
561
572
|
const {
|
|
562
573
|
valueMax,
|
|
@@ -595,21 +606,24 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
595
606
|
resizeHandleElement.removeAttribute("aria-valuenow");
|
|
596
607
|
});
|
|
597
608
|
};
|
|
598
|
-
}, [groupId, layout, panelDataArray]);
|
|
609
|
+
}, [groupId, layout, panelDataArray, panelGroupElement]);
|
|
599
610
|
useEffect(() => {
|
|
611
|
+
if (!panelGroupElement) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
600
614
|
const eagerValues = eagerValuesRef.current;
|
|
601
615
|
assert(eagerValues);
|
|
602
616
|
const {
|
|
603
617
|
panelDataArray
|
|
604
618
|
} = eagerValues;
|
|
605
|
-
const groupElement = getPanelGroupElement(groupId);
|
|
619
|
+
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
606
620
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
607
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
621
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
608
622
|
assert(handles);
|
|
609
623
|
const cleanupFunctions = handles.map(handle => {
|
|
610
624
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
611
625
|
assert(handleId);
|
|
612
|
-
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray);
|
|
626
|
+
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
|
|
613
627
|
if (idBefore == null || idAfter == null) {
|
|
614
628
|
return () => {};
|
|
615
629
|
}
|
|
@@ -636,7 +650,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
636
650
|
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
637
651
|
layout,
|
|
638
652
|
panelConstraints: panelDataArray.map(panelData => panelData.constraints),
|
|
639
|
-
pivotIndices: determinePivotIndices(groupId, handleId),
|
|
653
|
+
pivotIndices: determinePivotIndices(groupId, handleId, panelGroupElement),
|
|
640
654
|
trigger: "keyboard"
|
|
641
655
|
});
|
|
642
656
|
if (layout !== nextLayout) {
|
|
@@ -656,7 +670,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
656
670
|
return () => {
|
|
657
671
|
cleanupFunctions.forEach(cleanupFunction => cleanupFunction());
|
|
658
672
|
};
|
|
659
|
-
}, [committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
|
|
673
|
+
}, [panelGroupElement, committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
|
|
660
674
|
}
|
|
661
675
|
|
|
662
676
|
function areEqual(arrayA, arrayB) {
|
|
@@ -694,9 +708,9 @@ function getResizeEventCursorPosition(direction, event) {
|
|
|
694
708
|
}
|
|
695
709
|
}
|
|
696
710
|
|
|
697
|
-
function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState) {
|
|
711
|
+
function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement) {
|
|
698
712
|
const isHorizontal = direction === "horizontal";
|
|
699
|
-
const handleElement = getResizeHandleElement(dragHandleId);
|
|
713
|
+
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
|
|
700
714
|
assert(handleElement);
|
|
701
715
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
702
716
|
assert(groupId);
|
|
@@ -704,7 +718,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
|
|
|
704
718
|
initialCursorPosition
|
|
705
719
|
} = initialDragState;
|
|
706
720
|
const cursorPosition = getResizeEventCursorPosition(direction, event);
|
|
707
|
-
const groupElement = getPanelGroupElement(groupId);
|
|
721
|
+
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
708
722
|
assert(groupElement);
|
|
709
723
|
const groupRect = groupElement.getBoundingClientRect();
|
|
710
724
|
const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
|
|
@@ -714,7 +728,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
|
|
|
714
728
|
}
|
|
715
729
|
|
|
716
730
|
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX
|
|
717
|
-
function calculateDeltaPercentage(event, dragHandleId, direction, initialDragState, keyboardResizeBy) {
|
|
731
|
+
function calculateDeltaPercentage(event, dragHandleId, direction, initialDragState, keyboardResizeBy, panelGroupElement) {
|
|
718
732
|
if (isKeyDown(event)) {
|
|
719
733
|
const isHorizontal = direction === "horizontal";
|
|
720
734
|
let delta = 0;
|
|
@@ -751,7 +765,7 @@ function calculateDeltaPercentage(event, dragHandleId, direction, initialDragSta
|
|
|
751
765
|
if (initialDragState == null) {
|
|
752
766
|
return 0;
|
|
753
767
|
}
|
|
754
|
-
return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState);
|
|
768
|
+
return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement);
|
|
755
769
|
}
|
|
756
770
|
}
|
|
757
771
|
|
|
@@ -1025,6 +1039,7 @@ function validatePanelConstraints({
|
|
|
1025
1039
|
assert(panelConstraints);
|
|
1026
1040
|
const {
|
|
1027
1041
|
collapsedSize = 0,
|
|
1042
|
+
collapsible = false,
|
|
1028
1043
|
defaultSize,
|
|
1029
1044
|
maxSize = 100,
|
|
1030
1045
|
minSize = 0
|
|
@@ -1035,7 +1050,7 @@ function validatePanelConstraints({
|
|
|
1035
1050
|
if (defaultSize != null) {
|
|
1036
1051
|
if (defaultSize < 0) {
|
|
1037
1052
|
warnings.push("default size should not be less than 0");
|
|
1038
|
-
} else if (defaultSize < minSize) {
|
|
1053
|
+
} else if (defaultSize < minSize && (!collapsible || defaultSize !== collapsedSize)) {
|
|
1039
1054
|
warnings.push("default size should not be less than min size");
|
|
1040
1055
|
}
|
|
1041
1056
|
if (defaultSize > 100) {
|
|
@@ -1150,6 +1165,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1150
1165
|
...rest
|
|
1151
1166
|
}) {
|
|
1152
1167
|
const groupId = useUniqueId(idFromProps);
|
|
1168
|
+
const panelGroupElementRef = useRef(null);
|
|
1153
1169
|
const [dragState, setDragState] = useState(null);
|
|
1154
1170
|
const [layout, setLayout] = useState([]);
|
|
1155
1171
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
@@ -1218,7 +1234,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1218
1234
|
groupId,
|
|
1219
1235
|
layout,
|
|
1220
1236
|
panelDataArray: eagerValuesRef.current.panelDataArray,
|
|
1221
|
-
setLayout
|
|
1237
|
+
setLayout,
|
|
1238
|
+
panelGroupElement: panelGroupElementRef.current
|
|
1222
1239
|
});
|
|
1223
1240
|
useEffect(() => {
|
|
1224
1241
|
const {
|
|
@@ -1503,6 +1520,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1503
1520
|
const registerResizeHandle = useCallback(dragHandleId => {
|
|
1504
1521
|
return function resizeHandler(event) {
|
|
1505
1522
|
event.preventDefault();
|
|
1523
|
+
const panelGroupElement = panelGroupElementRef.current;
|
|
1524
|
+
if (!panelGroupElement) {
|
|
1525
|
+
return () => null;
|
|
1526
|
+
}
|
|
1506
1527
|
const {
|
|
1507
1528
|
direction,
|
|
1508
1529
|
dragState,
|
|
@@ -1517,8 +1538,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1517
1538
|
const {
|
|
1518
1539
|
initialLayout
|
|
1519
1540
|
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1520
|
-
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1521
|
-
let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy);
|
|
1541
|
+
const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
|
|
1542
|
+
let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
|
|
1522
1543
|
if (delta === 0) {
|
|
1523
1544
|
return;
|
|
1524
1545
|
}
|
|
@@ -1613,7 +1634,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1613
1634
|
const {
|
|
1614
1635
|
layout
|
|
1615
1636
|
} = eagerValuesRef.current;
|
|
1616
|
-
|
|
1637
|
+
if (!panelGroupElementRef.current) {
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElementRef.current);
|
|
1617
1641
|
assert(handleElement);
|
|
1618
1642
|
const initialCursorPosition = getResizeEventCursorPosition(direction, event);
|
|
1619
1643
|
setDragState({
|
|
@@ -1658,7 +1682,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1658
1682
|
resizePanel,
|
|
1659
1683
|
startDragging,
|
|
1660
1684
|
stopDragging,
|
|
1661
|
-
unregisterPanel
|
|
1685
|
+
unregisterPanel,
|
|
1686
|
+
panelGroupElement: panelGroupElementRef.current
|
|
1662
1687
|
}), [collapsePanel, dragState, direction, expandPanel, getPanelSize, getPanelStyle, groupId, isPanelCollapsed, isPanelExpanded, registerPanel, registerResizeHandle, resizePanel, startDragging, stopDragging, unregisterPanel]);
|
|
1663
1688
|
const style = {
|
|
1664
1689
|
display: "flex",
|
|
@@ -1677,6 +1702,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1677
1702
|
...style,
|
|
1678
1703
|
...styleFromProps
|
|
1679
1704
|
},
|
|
1705
|
+
ref: panelGroupElementRef,
|
|
1680
1706
|
// CSS selectors
|
|
1681
1707
|
"data-panel-group": "",
|
|
1682
1708
|
"data-panel-group-direction": direction,
|
|
@@ -1711,13 +1737,14 @@ function panelDataHelper(panelDataArray, panelData, layout) {
|
|
|
1711
1737
|
function useWindowSplitterResizeHandlerBehavior({
|
|
1712
1738
|
disabled,
|
|
1713
1739
|
handleId,
|
|
1714
|
-
resizeHandler
|
|
1740
|
+
resizeHandler,
|
|
1741
|
+
panelGroupElement
|
|
1715
1742
|
}) {
|
|
1716
1743
|
useEffect(() => {
|
|
1717
|
-
if (disabled || resizeHandler == null) {
|
|
1744
|
+
if (disabled || resizeHandler == null || panelGroupElement == null) {
|
|
1718
1745
|
return;
|
|
1719
1746
|
}
|
|
1720
|
-
const handleElement = getResizeHandleElement(handleId);
|
|
1747
|
+
const handleElement = getResizeHandleElement(handleId, panelGroupElement);
|
|
1721
1748
|
if (handleElement == null) {
|
|
1722
1749
|
return;
|
|
1723
1750
|
}
|
|
@@ -1742,8 +1769,8 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1742
1769
|
event.preventDefault();
|
|
1743
1770
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
1744
1771
|
assert(groupId);
|
|
1745
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
1746
|
-
const index = getResizeHandleElementIndex(groupId, handleId);
|
|
1772
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1773
|
+
const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
|
|
1747
1774
|
assert(index !== null);
|
|
1748
1775
|
const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
|
|
1749
1776
|
const nextHandle = handles[nextIndex];
|
|
@@ -1756,7 +1783,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1756
1783
|
return () => {
|
|
1757
1784
|
handleElement.removeEventListener("keydown", onKeyDown);
|
|
1758
1785
|
};
|
|
1759
|
-
}, [disabled, handleId, resizeHandler]);
|
|
1786
|
+
}, [panelGroupElement, disabled, handleId, resizeHandler]);
|
|
1760
1787
|
}
|
|
1761
1788
|
|
|
1762
1789
|
function PanelResizeHandle({
|
|
@@ -1789,7 +1816,8 @@ function PanelResizeHandle({
|
|
|
1789
1816
|
groupId,
|
|
1790
1817
|
registerResizeHandle,
|
|
1791
1818
|
startDragging,
|
|
1792
|
-
stopDragging
|
|
1819
|
+
stopDragging,
|
|
1820
|
+
panelGroupElement
|
|
1793
1821
|
} = panelGroupContext;
|
|
1794
1822
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1795
1823
|
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
@@ -1848,7 +1876,8 @@ function PanelResizeHandle({
|
|
|
1848
1876
|
useWindowSplitterResizeHandlerBehavior({
|
|
1849
1877
|
disabled,
|
|
1850
1878
|
handleId: resizeHandleId,
|
|
1851
|
-
resizeHandler
|
|
1879
|
+
resizeHandler,
|
|
1880
|
+
panelGroupElement
|
|
1852
1881
|
});
|
|
1853
1882
|
const style = {
|
|
1854
1883
|
cursor: getCursorStyle(direction),
|
|
@@ -1904,13 +1933,12 @@ function PanelResizeHandle({
|
|
|
1904
1933
|
}
|
|
1905
1934
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1906
1935
|
|
|
1907
|
-
function calculateAvailablePanelSizeInPixels(groupId) {
|
|
1908
|
-
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1936
|
+
function calculateAvailablePanelSizeInPixels(groupId, panelGroupElement) {
|
|
1909
1937
|
if (panelGroupElement == null) {
|
|
1910
1938
|
return NaN;
|
|
1911
1939
|
}
|
|
1912
1940
|
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1913
|
-
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1941
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1914
1942
|
if (direction === "horizontal") {
|
|
1915
1943
|
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1916
1944
|
return accumulated + handle.offsetWidth;
|
|
@@ -1922,13 +1950,9 @@ function calculateAvailablePanelSizeInPixels(groupId) {
|
|
|
1922
1950
|
}
|
|
1923
1951
|
}
|
|
1924
1952
|
|
|
1925
|
-
function getAvailableGroupSizePixels(groupId) {
|
|
1926
|
-
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1927
|
-
if (panelGroupElement == null) {
|
|
1928
|
-
return NaN;
|
|
1929
|
-
}
|
|
1953
|
+
function getAvailableGroupSizePixels(groupId, panelGroupElement) {
|
|
1930
1954
|
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1931
|
-
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1955
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1932
1956
|
if (direction === "horizontal") {
|
|
1933
1957
|
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1934
1958
|
return accumulated + handle.offsetWidth;
|
|
@@ -1940,16 +1964,16 @@ function getAvailableGroupSizePixels(groupId) {
|
|
|
1940
1964
|
}
|
|
1941
1965
|
}
|
|
1942
1966
|
|
|
1943
|
-
function getPanelElement(id) {
|
|
1944
|
-
const element =
|
|
1967
|
+
function getPanelElement(id, panelGroupElement) {
|
|
1968
|
+
const element = panelGroupElement.querySelector(`[data-panel-id="${id}"]`);
|
|
1945
1969
|
if (element) {
|
|
1946
1970
|
return element;
|
|
1947
1971
|
}
|
|
1948
1972
|
return null;
|
|
1949
1973
|
}
|
|
1950
1974
|
|
|
1951
|
-
function getPanelElementsForGroup(groupId) {
|
|
1952
|
-
return Array.from(
|
|
1975
|
+
function getPanelElementsForGroup(groupId, panelGroupElement) {
|
|
1976
|
+
return Array.from(panelGroupElement.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
|
|
1953
1977
|
}
|
|
1954
1978
|
|
|
1955
1979
|
export { Panel, PanelGroup, PanelResizeHandle, assert, calculateAvailablePanelSizeInPixels, getAvailableGroupSizePixels, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds };
|