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
|
@@ -525,41 +525,48 @@ function calculateAriaValues({
|
|
|
525
525
|
};
|
|
526
526
|
}
|
|
527
527
|
|
|
528
|
-
function getResizeHandleElementsForGroup(groupId) {
|
|
529
|
-
return Array.from(
|
|
528
|
+
function getResizeHandleElementsForGroup(groupId, panelGroupElement) {
|
|
529
|
+
return Array.from(panelGroupElement.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
|
|
530
530
|
}
|
|
531
531
|
|
|
532
|
-
function getResizeHandleElementIndex(groupId, id) {
|
|
533
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
532
|
+
function getResizeHandleElementIndex(groupId, id, panelGroupElement) {
|
|
533
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
534
534
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
535
535
|
return index !== null && index !== void 0 ? index : null;
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
-
function determinePivotIndices(groupId, dragHandleId) {
|
|
539
|
-
const index = getResizeHandleElementIndex(groupId, dragHandleId);
|
|
538
|
+
function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
|
|
539
|
+
const index = getResizeHandleElementIndex(groupId, dragHandleId, panelGroupElement);
|
|
540
540
|
return index != null ? [index, index + 1] : [-1, -1];
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
-
function getPanelGroupElement(id) {
|
|
544
|
-
|
|
543
|
+
function getPanelGroupElement(id, rootElement) {
|
|
544
|
+
var _dataset;
|
|
545
|
+
//If the root element is the PanelGroup
|
|
546
|
+
if (rootElement instanceof HTMLElement && (rootElement === null || rootElement === void 0 ? void 0 : (_dataset = rootElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.panelGroupId) == id) {
|
|
547
|
+
return rootElement;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
//Else query children
|
|
551
|
+
const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
545
552
|
if (element) {
|
|
546
553
|
return element;
|
|
547
554
|
}
|
|
548
555
|
return null;
|
|
549
556
|
}
|
|
550
557
|
|
|
551
|
-
function getResizeHandleElement(id) {
|
|
552
|
-
const element =
|
|
558
|
+
function getResizeHandleElement(id, panelGroupElement) {
|
|
559
|
+
const element = panelGroupElement.querySelector(`[data-panel-resize-handle-id="${id}"]`);
|
|
553
560
|
if (element) {
|
|
554
561
|
return element;
|
|
555
562
|
}
|
|
556
563
|
return null;
|
|
557
564
|
}
|
|
558
565
|
|
|
559
|
-
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
566
|
+
function getResizeHandlePanelIds(groupId, handleId, panelsArray, panelGroupElement) {
|
|
560
567
|
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
561
|
-
const handle = getResizeHandleElement(handleId);
|
|
562
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
568
|
+
const handle = getResizeHandleElement(handleId, panelGroupElement);
|
|
569
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
563
570
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
564
571
|
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;
|
|
565
572
|
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
@@ -574,13 +581,17 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
574
581
|
groupId,
|
|
575
582
|
layout,
|
|
576
583
|
panelDataArray,
|
|
584
|
+
panelGroupElement,
|
|
577
585
|
setLayout
|
|
578
586
|
}) {
|
|
579
587
|
const devWarningsRef = useRef({
|
|
580
588
|
didWarnAboutMissingResizeHandle: false
|
|
581
589
|
});
|
|
582
590
|
useIsomorphicLayoutEffect(() => {
|
|
583
|
-
|
|
591
|
+
if (!panelGroupElement) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
const resizeHandleElements = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
584
595
|
for (let index = 0; index < panelDataArray.length - 1; index++) {
|
|
585
596
|
const {
|
|
586
597
|
valueMax,
|
|
@@ -619,21 +630,24 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
619
630
|
resizeHandleElement.removeAttribute("aria-valuenow");
|
|
620
631
|
});
|
|
621
632
|
};
|
|
622
|
-
}, [groupId, layout, panelDataArray]);
|
|
633
|
+
}, [groupId, layout, panelDataArray, panelGroupElement]);
|
|
623
634
|
useEffect(() => {
|
|
635
|
+
if (!panelGroupElement) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
624
638
|
const eagerValues = eagerValuesRef.current;
|
|
625
639
|
assert(eagerValues);
|
|
626
640
|
const {
|
|
627
641
|
panelDataArray
|
|
628
642
|
} = eagerValues;
|
|
629
|
-
const groupElement = getPanelGroupElement(groupId);
|
|
643
|
+
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
630
644
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
631
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
645
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
632
646
|
assert(handles);
|
|
633
647
|
const cleanupFunctions = handles.map(handle => {
|
|
634
648
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
635
649
|
assert(handleId);
|
|
636
|
-
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray);
|
|
650
|
+
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
|
|
637
651
|
if (idBefore == null || idAfter == null) {
|
|
638
652
|
return () => {};
|
|
639
653
|
}
|
|
@@ -660,7 +674,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
660
674
|
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
661
675
|
layout,
|
|
662
676
|
panelConstraints: panelDataArray.map(panelData => panelData.constraints),
|
|
663
|
-
pivotIndices: determinePivotIndices(groupId, handleId),
|
|
677
|
+
pivotIndices: determinePivotIndices(groupId, handleId, panelGroupElement),
|
|
664
678
|
trigger: "keyboard"
|
|
665
679
|
});
|
|
666
680
|
if (layout !== nextLayout) {
|
|
@@ -680,7 +694,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
680
694
|
return () => {
|
|
681
695
|
cleanupFunctions.forEach(cleanupFunction => cleanupFunction());
|
|
682
696
|
};
|
|
683
|
-
}, [committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
|
|
697
|
+
}, [panelGroupElement, committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
|
|
684
698
|
}
|
|
685
699
|
|
|
686
700
|
function areEqual(arrayA, arrayB) {
|
|
@@ -718,9 +732,9 @@ function getResizeEventCursorPosition(direction, event) {
|
|
|
718
732
|
}
|
|
719
733
|
}
|
|
720
734
|
|
|
721
|
-
function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState) {
|
|
735
|
+
function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement) {
|
|
722
736
|
const isHorizontal = direction === "horizontal";
|
|
723
|
-
const handleElement = getResizeHandleElement(dragHandleId);
|
|
737
|
+
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
|
|
724
738
|
assert(handleElement);
|
|
725
739
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
726
740
|
assert(groupId);
|
|
@@ -728,7 +742,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
|
|
|
728
742
|
initialCursorPosition
|
|
729
743
|
} = initialDragState;
|
|
730
744
|
const cursorPosition = getResizeEventCursorPosition(direction, event);
|
|
731
|
-
const groupElement = getPanelGroupElement(groupId);
|
|
745
|
+
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
732
746
|
assert(groupElement);
|
|
733
747
|
const groupRect = groupElement.getBoundingClientRect();
|
|
734
748
|
const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
|
|
@@ -738,7 +752,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
|
|
|
738
752
|
}
|
|
739
753
|
|
|
740
754
|
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX
|
|
741
|
-
function calculateDeltaPercentage(event, dragHandleId, direction, initialDragState, keyboardResizeBy) {
|
|
755
|
+
function calculateDeltaPercentage(event, dragHandleId, direction, initialDragState, keyboardResizeBy, panelGroupElement) {
|
|
742
756
|
if (isKeyDown(event)) {
|
|
743
757
|
const isHorizontal = direction === "horizontal";
|
|
744
758
|
let delta = 0;
|
|
@@ -775,7 +789,7 @@ function calculateDeltaPercentage(event, dragHandleId, direction, initialDragSta
|
|
|
775
789
|
if (initialDragState == null) {
|
|
776
790
|
return 0;
|
|
777
791
|
}
|
|
778
|
-
return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState);
|
|
792
|
+
return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement);
|
|
779
793
|
}
|
|
780
794
|
}
|
|
781
795
|
|
|
@@ -1049,6 +1063,7 @@ function validatePanelConstraints({
|
|
|
1049
1063
|
assert(panelConstraints);
|
|
1050
1064
|
const {
|
|
1051
1065
|
collapsedSize = 0,
|
|
1066
|
+
collapsible = false,
|
|
1052
1067
|
defaultSize,
|
|
1053
1068
|
maxSize = 100,
|
|
1054
1069
|
minSize = 0
|
|
@@ -1059,7 +1074,7 @@ function validatePanelConstraints({
|
|
|
1059
1074
|
if (defaultSize != null) {
|
|
1060
1075
|
if (defaultSize < 0) {
|
|
1061
1076
|
warnings.push("default size should not be less than 0");
|
|
1062
|
-
} else if (defaultSize < minSize) {
|
|
1077
|
+
} else if (defaultSize < minSize && (!collapsible || defaultSize !== collapsedSize)) {
|
|
1063
1078
|
warnings.push("default size should not be less than min size");
|
|
1064
1079
|
}
|
|
1065
1080
|
if (defaultSize > 100) {
|
|
@@ -1174,6 +1189,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1174
1189
|
...rest
|
|
1175
1190
|
}) {
|
|
1176
1191
|
const groupId = useUniqueId(idFromProps);
|
|
1192
|
+
const panelGroupElementRef = useRef(null);
|
|
1177
1193
|
const [dragState, setDragState] = useState(null);
|
|
1178
1194
|
const [layout, setLayout] = useState([]);
|
|
1179
1195
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
@@ -1242,7 +1258,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1242
1258
|
groupId,
|
|
1243
1259
|
layout,
|
|
1244
1260
|
panelDataArray: eagerValuesRef.current.panelDataArray,
|
|
1245
|
-
setLayout
|
|
1261
|
+
setLayout,
|
|
1262
|
+
panelGroupElement: panelGroupElementRef.current
|
|
1246
1263
|
});
|
|
1247
1264
|
useEffect(() => {
|
|
1248
1265
|
const {
|
|
@@ -1527,6 +1544,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1527
1544
|
const registerResizeHandle = useCallback(dragHandleId => {
|
|
1528
1545
|
return function resizeHandler(event) {
|
|
1529
1546
|
event.preventDefault();
|
|
1547
|
+
const panelGroupElement = panelGroupElementRef.current;
|
|
1548
|
+
if (!panelGroupElement) {
|
|
1549
|
+
return () => null;
|
|
1550
|
+
}
|
|
1530
1551
|
const {
|
|
1531
1552
|
direction,
|
|
1532
1553
|
dragState,
|
|
@@ -1541,8 +1562,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1541
1562
|
const {
|
|
1542
1563
|
initialLayout
|
|
1543
1564
|
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1544
|
-
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1545
|
-
let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy);
|
|
1565
|
+
const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
|
|
1566
|
+
let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
|
|
1546
1567
|
if (delta === 0) {
|
|
1547
1568
|
return;
|
|
1548
1569
|
}
|
|
@@ -1637,7 +1658,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1637
1658
|
const {
|
|
1638
1659
|
layout
|
|
1639
1660
|
} = eagerValuesRef.current;
|
|
1640
|
-
|
|
1661
|
+
if (!panelGroupElementRef.current) {
|
|
1662
|
+
return;
|
|
1663
|
+
}
|
|
1664
|
+
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElementRef.current);
|
|
1641
1665
|
assert(handleElement);
|
|
1642
1666
|
const initialCursorPosition = getResizeEventCursorPosition(direction, event);
|
|
1643
1667
|
setDragState({
|
|
@@ -1682,7 +1706,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1682
1706
|
resizePanel,
|
|
1683
1707
|
startDragging,
|
|
1684
1708
|
stopDragging,
|
|
1685
|
-
unregisterPanel
|
|
1709
|
+
unregisterPanel,
|
|
1710
|
+
panelGroupElement: panelGroupElementRef.current
|
|
1686
1711
|
}), [collapsePanel, dragState, direction, expandPanel, getPanelSize, getPanelStyle, groupId, isPanelCollapsed, isPanelExpanded, registerPanel, registerResizeHandle, resizePanel, startDragging, stopDragging, unregisterPanel]);
|
|
1687
1712
|
const style = {
|
|
1688
1713
|
display: "flex",
|
|
@@ -1701,6 +1726,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1701
1726
|
...style,
|
|
1702
1727
|
...styleFromProps
|
|
1703
1728
|
},
|
|
1729
|
+
ref: panelGroupElementRef,
|
|
1704
1730
|
// CSS selectors
|
|
1705
1731
|
"data-panel-group": "",
|
|
1706
1732
|
"data-panel-group-direction": direction,
|
|
@@ -1735,13 +1761,14 @@ function panelDataHelper(panelDataArray, panelData, layout) {
|
|
|
1735
1761
|
function useWindowSplitterResizeHandlerBehavior({
|
|
1736
1762
|
disabled,
|
|
1737
1763
|
handleId,
|
|
1738
|
-
resizeHandler
|
|
1764
|
+
resizeHandler,
|
|
1765
|
+
panelGroupElement
|
|
1739
1766
|
}) {
|
|
1740
1767
|
useEffect(() => {
|
|
1741
|
-
if (disabled || resizeHandler == null) {
|
|
1768
|
+
if (disabled || resizeHandler == null || panelGroupElement == null) {
|
|
1742
1769
|
return;
|
|
1743
1770
|
}
|
|
1744
|
-
const handleElement = getResizeHandleElement(handleId);
|
|
1771
|
+
const handleElement = getResizeHandleElement(handleId, panelGroupElement);
|
|
1745
1772
|
if (handleElement == null) {
|
|
1746
1773
|
return;
|
|
1747
1774
|
}
|
|
@@ -1766,8 +1793,8 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1766
1793
|
event.preventDefault();
|
|
1767
1794
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
1768
1795
|
assert(groupId);
|
|
1769
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
1770
|
-
const index = getResizeHandleElementIndex(groupId, handleId);
|
|
1796
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1797
|
+
const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
|
|
1771
1798
|
assert(index !== null);
|
|
1772
1799
|
const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
|
|
1773
1800
|
const nextHandle = handles[nextIndex];
|
|
@@ -1780,7 +1807,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1780
1807
|
return () => {
|
|
1781
1808
|
handleElement.removeEventListener("keydown", onKeyDown);
|
|
1782
1809
|
};
|
|
1783
|
-
}, [disabled, handleId, resizeHandler]);
|
|
1810
|
+
}, [panelGroupElement, disabled, handleId, resizeHandler]);
|
|
1784
1811
|
}
|
|
1785
1812
|
|
|
1786
1813
|
function PanelResizeHandle({
|
|
@@ -1813,7 +1840,8 @@ function PanelResizeHandle({
|
|
|
1813
1840
|
groupId,
|
|
1814
1841
|
registerResizeHandle,
|
|
1815
1842
|
startDragging,
|
|
1816
|
-
stopDragging
|
|
1843
|
+
stopDragging,
|
|
1844
|
+
panelGroupElement
|
|
1817
1845
|
} = panelGroupContext;
|
|
1818
1846
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1819
1847
|
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
@@ -1872,7 +1900,8 @@ function PanelResizeHandle({
|
|
|
1872
1900
|
useWindowSplitterResizeHandlerBehavior({
|
|
1873
1901
|
disabled,
|
|
1874
1902
|
handleId: resizeHandleId,
|
|
1875
|
-
resizeHandler
|
|
1903
|
+
resizeHandler,
|
|
1904
|
+
panelGroupElement
|
|
1876
1905
|
});
|
|
1877
1906
|
const style = {
|
|
1878
1907
|
cursor: getCursorStyle(direction),
|
|
@@ -1928,13 +1957,12 @@ function PanelResizeHandle({
|
|
|
1928
1957
|
}
|
|
1929
1958
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1930
1959
|
|
|
1931
|
-
function calculateAvailablePanelSizeInPixels(groupId) {
|
|
1932
|
-
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1960
|
+
function calculateAvailablePanelSizeInPixels(groupId, panelGroupElement) {
|
|
1933
1961
|
if (panelGroupElement == null) {
|
|
1934
1962
|
return NaN;
|
|
1935
1963
|
}
|
|
1936
1964
|
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1937
|
-
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1965
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1938
1966
|
if (direction === "horizontal") {
|
|
1939
1967
|
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1940
1968
|
return accumulated + handle.offsetWidth;
|
|
@@ -1946,13 +1974,9 @@ function calculateAvailablePanelSizeInPixels(groupId) {
|
|
|
1946
1974
|
}
|
|
1947
1975
|
}
|
|
1948
1976
|
|
|
1949
|
-
function getAvailableGroupSizePixels(groupId) {
|
|
1950
|
-
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1951
|
-
if (panelGroupElement == null) {
|
|
1952
|
-
return NaN;
|
|
1953
|
-
}
|
|
1977
|
+
function getAvailableGroupSizePixels(groupId, panelGroupElement) {
|
|
1954
1978
|
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1955
|
-
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1979
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1956
1980
|
if (direction === "horizontal") {
|
|
1957
1981
|
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1958
1982
|
return accumulated + handle.offsetWidth;
|
|
@@ -1964,16 +1988,16 @@ function getAvailableGroupSizePixels(groupId) {
|
|
|
1964
1988
|
}
|
|
1965
1989
|
}
|
|
1966
1990
|
|
|
1967
|
-
function getPanelElement(id) {
|
|
1968
|
-
const element =
|
|
1991
|
+
function getPanelElement(id, panelGroupElement) {
|
|
1992
|
+
const element = panelGroupElement.querySelector(`[data-panel-id="${id}"]`);
|
|
1969
1993
|
if (element) {
|
|
1970
1994
|
return element;
|
|
1971
1995
|
}
|
|
1972
1996
|
return null;
|
|
1973
1997
|
}
|
|
1974
1998
|
|
|
1975
|
-
function getPanelElementsForGroup(groupId) {
|
|
1976
|
-
return Array.from(
|
|
1999
|
+
function getPanelElementsForGroup(groupId, panelGroupElement) {
|
|
2000
|
+
return Array.from(panelGroupElement.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
|
|
1977
2001
|
}
|
|
1978
2002
|
|
|
1979
2003
|
exports.Panel = Panel;
|