react-resizable-panels 1.0.6 → 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 +10 -0
- package/README.md +20 -4
- package/dist/declarations/src/Panel.d.ts +6 -6
- package/dist/declarations/src/PanelGroup.d.ts +5 -5
- package/dist/declarations/src/PanelResizeHandle.d.ts +4 -4
- 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 +82 -59
- package/dist/react-resizable-panels.browser.development.cjs.js +84 -60
- package/dist/react-resizable-panels.browser.development.esm.js +84 -60
- package/dist/react-resizable-panels.browser.esm.js +82 -59
- package/dist/react-resizable-panels.cjs.js +82 -59
- package/dist/react-resizable-panels.development.cjs.js +84 -60
- package/dist/react-resizable-panels.development.esm.js +84 -60
- package/dist/react-resizable-panels.development.node.cjs.js +79 -58
- package/dist/react-resizable-panels.development.node.esm.js +79 -58
- package/dist/react-resizable-panels.esm.js +82 -59
- package/dist/react-resizable-panels.node.cjs.js +77 -57
- package/dist/react-resizable-panels.node.esm.js +77 -57
- package/package.json +1 -1
- package/src/Panel.test.tsx +3 -2
- package/src/Panel.ts +7 -4
- package/src/PanelGroup.test.tsx +3 -2
- package/src/PanelGroup.ts +53 -30
- package/src/PanelGroupContext.ts +4 -2
- package/src/PanelResizeHandle.test.tsx +3 -3
- package/src/PanelResizeHandle.ts +17 -12
- package/src/hooks/useWindowSplitterBehavior.ts +15 -6
- 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 +6 -3
- package/src/utils/dom/getPanelElementsForGroup.ts +7 -2
- package/src/utils/dom/getPanelGroupElement.ts +15 -3
- package/src/utils/dom/getResizeHandleElement.ts +6 -3
- package/src/utils/dom/getResizeHandleElementIndex.ts +3 -2
- package/src/utils/dom/getResizeHandleElementsForGroup.ts +4 -3
- 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
|
@@ -521,41 +521,48 @@ function calculateAriaValues({
|
|
|
521
521
|
};
|
|
522
522
|
}
|
|
523
523
|
|
|
524
|
-
function getResizeHandleElementsForGroup(groupId) {
|
|
525
|
-
return Array.from(
|
|
524
|
+
function getResizeHandleElementsForGroup(groupId, panelGroupElement) {
|
|
525
|
+
return Array.from(panelGroupElement.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
|
|
526
526
|
}
|
|
527
527
|
|
|
528
|
-
function getResizeHandleElementIndex(groupId, id) {
|
|
529
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
528
|
+
function getResizeHandleElementIndex(groupId, id, panelGroupElement) {
|
|
529
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
530
530
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
531
531
|
return index !== null && index !== void 0 ? index : null;
|
|
532
532
|
}
|
|
533
533
|
|
|
534
|
-
function determinePivotIndices(groupId, dragHandleId) {
|
|
535
|
-
const index = getResizeHandleElementIndex(groupId, dragHandleId);
|
|
534
|
+
function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
|
|
535
|
+
const index = getResizeHandleElementIndex(groupId, dragHandleId, panelGroupElement);
|
|
536
536
|
return index != null ? [index, index + 1] : [-1, -1];
|
|
537
537
|
}
|
|
538
538
|
|
|
539
|
-
function getPanelGroupElement(id) {
|
|
540
|
-
|
|
539
|
+
function getPanelGroupElement(id, rootElement) {
|
|
540
|
+
var _dataset;
|
|
541
|
+
//If the root element is the PanelGroup
|
|
542
|
+
if (rootElement instanceof HTMLElement && (rootElement === null || rootElement === void 0 ? void 0 : (_dataset = rootElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.panelGroupId) == id) {
|
|
543
|
+
return rootElement;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
//Else query children
|
|
547
|
+
const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
541
548
|
if (element) {
|
|
542
549
|
return element;
|
|
543
550
|
}
|
|
544
551
|
return null;
|
|
545
552
|
}
|
|
546
553
|
|
|
547
|
-
function getResizeHandleElement(id) {
|
|
548
|
-
const element =
|
|
554
|
+
function getResizeHandleElement(id, panelGroupElement) {
|
|
555
|
+
const element = panelGroupElement.querySelector(`[data-panel-resize-handle-id="${id}"]`);
|
|
549
556
|
if (element) {
|
|
550
557
|
return element;
|
|
551
558
|
}
|
|
552
559
|
return null;
|
|
553
560
|
}
|
|
554
561
|
|
|
555
|
-
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
562
|
+
function getResizeHandlePanelIds(groupId, handleId, panelsArray, panelGroupElement) {
|
|
556
563
|
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
557
|
-
const handle = getResizeHandleElement(handleId);
|
|
558
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
564
|
+
const handle = getResizeHandleElement(handleId, panelGroupElement);
|
|
565
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
559
566
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
560
567
|
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;
|
|
561
568
|
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
@@ -570,13 +577,17 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
570
577
|
groupId,
|
|
571
578
|
layout,
|
|
572
579
|
panelDataArray,
|
|
580
|
+
panelGroupElement,
|
|
573
581
|
setLayout
|
|
574
582
|
}) {
|
|
575
583
|
useRef({
|
|
576
584
|
didWarnAboutMissingResizeHandle: false
|
|
577
585
|
});
|
|
578
586
|
useIsomorphicLayoutEffect(() => {
|
|
579
|
-
|
|
587
|
+
if (!panelGroupElement) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
const resizeHandleElements = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
580
591
|
for (let index = 0; index < panelDataArray.length - 1; index++) {
|
|
581
592
|
const {
|
|
582
593
|
valueMax,
|
|
@@ -605,21 +616,24 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
605
616
|
resizeHandleElement.removeAttribute("aria-valuenow");
|
|
606
617
|
});
|
|
607
618
|
};
|
|
608
|
-
}, [groupId, layout, panelDataArray]);
|
|
619
|
+
}, [groupId, layout, panelDataArray, panelGroupElement]);
|
|
609
620
|
useEffect(() => {
|
|
621
|
+
if (!panelGroupElement) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
610
624
|
const eagerValues = eagerValuesRef.current;
|
|
611
625
|
assert(eagerValues);
|
|
612
626
|
const {
|
|
613
627
|
panelDataArray
|
|
614
628
|
} = eagerValues;
|
|
615
|
-
const groupElement = getPanelGroupElement(groupId);
|
|
629
|
+
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
616
630
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
617
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
631
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
618
632
|
assert(handles);
|
|
619
633
|
const cleanupFunctions = handles.map(handle => {
|
|
620
634
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
621
635
|
assert(handleId);
|
|
622
|
-
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray);
|
|
636
|
+
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
|
|
623
637
|
if (idBefore == null || idAfter == null) {
|
|
624
638
|
return () => {};
|
|
625
639
|
}
|
|
@@ -646,7 +660,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
646
660
|
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
647
661
|
layout,
|
|
648
662
|
panelConstraints: panelDataArray.map(panelData => panelData.constraints),
|
|
649
|
-
pivotIndices: determinePivotIndices(groupId, handleId),
|
|
663
|
+
pivotIndices: determinePivotIndices(groupId, handleId, panelGroupElement),
|
|
650
664
|
trigger: "keyboard"
|
|
651
665
|
});
|
|
652
666
|
if (layout !== nextLayout) {
|
|
@@ -666,7 +680,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
666
680
|
return () => {
|
|
667
681
|
cleanupFunctions.forEach(cleanupFunction => cleanupFunction());
|
|
668
682
|
};
|
|
669
|
-
}, [committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
|
|
683
|
+
}, [panelGroupElement, committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
|
|
670
684
|
}
|
|
671
685
|
|
|
672
686
|
function areEqual(arrayA, arrayB) {
|
|
@@ -704,9 +718,9 @@ function getResizeEventCursorPosition(direction, event) {
|
|
|
704
718
|
}
|
|
705
719
|
}
|
|
706
720
|
|
|
707
|
-
function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState) {
|
|
721
|
+
function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement) {
|
|
708
722
|
const isHorizontal = direction === "horizontal";
|
|
709
|
-
const handleElement = getResizeHandleElement(dragHandleId);
|
|
723
|
+
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
|
|
710
724
|
assert(handleElement);
|
|
711
725
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
712
726
|
assert(groupId);
|
|
@@ -714,7 +728,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
|
|
|
714
728
|
initialCursorPosition
|
|
715
729
|
} = initialDragState;
|
|
716
730
|
const cursorPosition = getResizeEventCursorPosition(direction, event);
|
|
717
|
-
const groupElement = getPanelGroupElement(groupId);
|
|
731
|
+
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
718
732
|
assert(groupElement);
|
|
719
733
|
const groupRect = groupElement.getBoundingClientRect();
|
|
720
734
|
const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
|
|
@@ -724,7 +738,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
|
|
|
724
738
|
}
|
|
725
739
|
|
|
726
740
|
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX
|
|
727
|
-
function calculateDeltaPercentage(event, dragHandleId, direction, initialDragState, keyboardResizeBy) {
|
|
741
|
+
function calculateDeltaPercentage(event, dragHandleId, direction, initialDragState, keyboardResizeBy, panelGroupElement) {
|
|
728
742
|
if (isKeyDown(event)) {
|
|
729
743
|
const isHorizontal = direction === "horizontal";
|
|
730
744
|
let delta = 0;
|
|
@@ -761,7 +775,7 @@ function calculateDeltaPercentage(event, dragHandleId, direction, initialDragSta
|
|
|
761
775
|
if (initialDragState == null) {
|
|
762
776
|
return 0;
|
|
763
777
|
}
|
|
764
|
-
return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState);
|
|
778
|
+
return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement);
|
|
765
779
|
}
|
|
766
780
|
}
|
|
767
781
|
|
|
@@ -1113,6 +1127,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1113
1127
|
...rest
|
|
1114
1128
|
}) {
|
|
1115
1129
|
const groupId = useUniqueId(idFromProps);
|
|
1130
|
+
const panelGroupElementRef = useRef(null);
|
|
1116
1131
|
const [dragState, setDragState] = useState(null);
|
|
1117
1132
|
const [layout, setLayout] = useState([]);
|
|
1118
1133
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
@@ -1181,7 +1196,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1181
1196
|
groupId,
|
|
1182
1197
|
layout,
|
|
1183
1198
|
panelDataArray: eagerValuesRef.current.panelDataArray,
|
|
1184
|
-
setLayout
|
|
1199
|
+
setLayout,
|
|
1200
|
+
panelGroupElement: panelGroupElementRef.current
|
|
1185
1201
|
});
|
|
1186
1202
|
useEffect(() => {
|
|
1187
1203
|
const {
|
|
@@ -1424,6 +1440,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1424
1440
|
const registerResizeHandle = useCallback(dragHandleId => {
|
|
1425
1441
|
return function resizeHandler(event) {
|
|
1426
1442
|
event.preventDefault();
|
|
1443
|
+
const panelGroupElement = panelGroupElementRef.current;
|
|
1444
|
+
if (!panelGroupElement) {
|
|
1445
|
+
return () => null;
|
|
1446
|
+
}
|
|
1427
1447
|
const {
|
|
1428
1448
|
direction,
|
|
1429
1449
|
dragState,
|
|
@@ -1438,8 +1458,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1438
1458
|
const {
|
|
1439
1459
|
initialLayout
|
|
1440
1460
|
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1441
|
-
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1442
|
-
let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy);
|
|
1461
|
+
const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
|
|
1462
|
+
let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
|
|
1443
1463
|
if (delta === 0) {
|
|
1444
1464
|
return;
|
|
1445
1465
|
}
|
|
@@ -1534,7 +1554,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1534
1554
|
const {
|
|
1535
1555
|
layout
|
|
1536
1556
|
} = eagerValuesRef.current;
|
|
1537
|
-
|
|
1557
|
+
if (!panelGroupElementRef.current) {
|
|
1558
|
+
return;
|
|
1559
|
+
}
|
|
1560
|
+
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElementRef.current);
|
|
1538
1561
|
assert(handleElement);
|
|
1539
1562
|
const initialCursorPosition = getResizeEventCursorPosition(direction, event);
|
|
1540
1563
|
setDragState({
|
|
@@ -1579,7 +1602,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1579
1602
|
resizePanel,
|
|
1580
1603
|
startDragging,
|
|
1581
1604
|
stopDragging,
|
|
1582
|
-
unregisterPanel
|
|
1605
|
+
unregisterPanel,
|
|
1606
|
+
panelGroupElement: panelGroupElementRef.current
|
|
1583
1607
|
}), [collapsePanel, dragState, direction, expandPanel, getPanelSize, getPanelStyle, groupId, isPanelCollapsed, isPanelExpanded, registerPanel, registerResizeHandle, resizePanel, startDragging, stopDragging, unregisterPanel]);
|
|
1584
1608
|
const style = {
|
|
1585
1609
|
display: "flex",
|
|
@@ -1598,6 +1622,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1598
1622
|
...style,
|
|
1599
1623
|
...styleFromProps
|
|
1600
1624
|
},
|
|
1625
|
+
ref: panelGroupElementRef,
|
|
1601
1626
|
// CSS selectors
|
|
1602
1627
|
"data-panel-group": "",
|
|
1603
1628
|
"data-panel-group-direction": direction,
|
|
@@ -1632,13 +1657,14 @@ function panelDataHelper(panelDataArray, panelData, layout) {
|
|
|
1632
1657
|
function useWindowSplitterResizeHandlerBehavior({
|
|
1633
1658
|
disabled,
|
|
1634
1659
|
handleId,
|
|
1635
|
-
resizeHandler
|
|
1660
|
+
resizeHandler,
|
|
1661
|
+
panelGroupElement
|
|
1636
1662
|
}) {
|
|
1637
1663
|
useEffect(() => {
|
|
1638
|
-
if (disabled || resizeHandler == null) {
|
|
1664
|
+
if (disabled || resizeHandler == null || panelGroupElement == null) {
|
|
1639
1665
|
return;
|
|
1640
1666
|
}
|
|
1641
|
-
const handleElement = getResizeHandleElement(handleId);
|
|
1667
|
+
const handleElement = getResizeHandleElement(handleId, panelGroupElement);
|
|
1642
1668
|
if (handleElement == null) {
|
|
1643
1669
|
return;
|
|
1644
1670
|
}
|
|
@@ -1663,8 +1689,8 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1663
1689
|
event.preventDefault();
|
|
1664
1690
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
1665
1691
|
assert(groupId);
|
|
1666
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
1667
|
-
const index = getResizeHandleElementIndex(groupId, handleId);
|
|
1692
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1693
|
+
const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
|
|
1668
1694
|
assert(index !== null);
|
|
1669
1695
|
const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
|
|
1670
1696
|
const nextHandle = handles[nextIndex];
|
|
@@ -1677,7 +1703,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1677
1703
|
return () => {
|
|
1678
1704
|
handleElement.removeEventListener("keydown", onKeyDown);
|
|
1679
1705
|
};
|
|
1680
|
-
}, [disabled, handleId, resizeHandler]);
|
|
1706
|
+
}, [panelGroupElement, disabled, handleId, resizeHandler]);
|
|
1681
1707
|
}
|
|
1682
1708
|
|
|
1683
1709
|
function PanelResizeHandle({
|
|
@@ -1691,7 +1717,7 @@ function PanelResizeHandle({
|
|
|
1691
1717
|
tagName: Type = "div",
|
|
1692
1718
|
...rest
|
|
1693
1719
|
}) {
|
|
1694
|
-
const
|
|
1720
|
+
const elementRef = useRef(null);
|
|
1695
1721
|
|
|
1696
1722
|
// Use a ref to guard against users passing inline props
|
|
1697
1723
|
const callbacksRef = useRef({
|
|
@@ -1710,7 +1736,8 @@ function PanelResizeHandle({
|
|
|
1710
1736
|
groupId,
|
|
1711
1737
|
registerResizeHandle,
|
|
1712
1738
|
startDragging,
|
|
1713
|
-
stopDragging
|
|
1739
|
+
stopDragging,
|
|
1740
|
+
panelGroupElement
|
|
1714
1741
|
} = panelGroupContext;
|
|
1715
1742
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1716
1743
|
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
@@ -1719,9 +1746,9 @@ function PanelResizeHandle({
|
|
|
1719
1746
|
const stopDraggingAndBlur = useCallback(() => {
|
|
1720
1747
|
// Clicking on the drag handle shouldn't leave it focused;
|
|
1721
1748
|
// That would cause the PanelGroup to think it was still active.
|
|
1722
|
-
const
|
|
1723
|
-
assert(
|
|
1724
|
-
|
|
1749
|
+
const element = elementRef.current;
|
|
1750
|
+
assert(element);
|
|
1751
|
+
element.blur();
|
|
1725
1752
|
stopDragging();
|
|
1726
1753
|
const {
|
|
1727
1754
|
onDragging
|
|
@@ -1748,9 +1775,9 @@ function PanelResizeHandle({
|
|
|
1748
1775
|
const onMouseLeave = event => {
|
|
1749
1776
|
resizeHandler(event);
|
|
1750
1777
|
};
|
|
1751
|
-
const
|
|
1752
|
-
assert(
|
|
1753
|
-
const targetDocument =
|
|
1778
|
+
const element = elementRef.current;
|
|
1779
|
+
assert(element);
|
|
1780
|
+
const targetDocument = element.ownerDocument;
|
|
1754
1781
|
targetDocument.body.addEventListener("contextmenu", stopDraggingAndBlur);
|
|
1755
1782
|
targetDocument.body.addEventListener("mousemove", onMove);
|
|
1756
1783
|
targetDocument.body.addEventListener("touchmove", onMove);
|
|
@@ -1769,7 +1796,8 @@ function PanelResizeHandle({
|
|
|
1769
1796
|
useWindowSplitterResizeHandlerBehavior({
|
|
1770
1797
|
disabled,
|
|
1771
1798
|
handleId: resizeHandleId,
|
|
1772
|
-
resizeHandler
|
|
1799
|
+
resizeHandler,
|
|
1800
|
+
panelGroupElement
|
|
1773
1801
|
});
|
|
1774
1802
|
const style = {
|
|
1775
1803
|
cursor: getCursorStyle(direction),
|
|
@@ -1807,7 +1835,7 @@ function PanelResizeHandle({
|
|
|
1807
1835
|
onDragging(true);
|
|
1808
1836
|
}
|
|
1809
1837
|
},
|
|
1810
|
-
ref:
|
|
1838
|
+
ref: elementRef,
|
|
1811
1839
|
role: "separator",
|
|
1812
1840
|
style: {
|
|
1813
1841
|
...style,
|
|
@@ -1825,13 +1853,12 @@ function PanelResizeHandle({
|
|
|
1825
1853
|
}
|
|
1826
1854
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1827
1855
|
|
|
1828
|
-
function calculateAvailablePanelSizeInPixels(groupId) {
|
|
1829
|
-
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1856
|
+
function calculateAvailablePanelSizeInPixels(groupId, panelGroupElement) {
|
|
1830
1857
|
if (panelGroupElement == null) {
|
|
1831
1858
|
return NaN;
|
|
1832
1859
|
}
|
|
1833
1860
|
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1834
|
-
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1861
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1835
1862
|
if (direction === "horizontal") {
|
|
1836
1863
|
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1837
1864
|
return accumulated + handle.offsetWidth;
|
|
@@ -1843,13 +1870,9 @@ function calculateAvailablePanelSizeInPixels(groupId) {
|
|
|
1843
1870
|
}
|
|
1844
1871
|
}
|
|
1845
1872
|
|
|
1846
|
-
function getAvailableGroupSizePixels(groupId) {
|
|
1847
|
-
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1848
|
-
if (panelGroupElement == null) {
|
|
1849
|
-
return NaN;
|
|
1850
|
-
}
|
|
1873
|
+
function getAvailableGroupSizePixels(groupId, panelGroupElement) {
|
|
1851
1874
|
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1852
|
-
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1875
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1853
1876
|
if (direction === "horizontal") {
|
|
1854
1877
|
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1855
1878
|
return accumulated + handle.offsetWidth;
|
|
@@ -1861,16 +1884,16 @@ function getAvailableGroupSizePixels(groupId) {
|
|
|
1861
1884
|
}
|
|
1862
1885
|
}
|
|
1863
1886
|
|
|
1864
|
-
function getPanelElement(id) {
|
|
1865
|
-
const element =
|
|
1887
|
+
function getPanelElement(id, panelGroupElement) {
|
|
1888
|
+
const element = panelGroupElement.querySelector(`[data-panel-id="${id}"]`);
|
|
1866
1889
|
if (element) {
|
|
1867
1890
|
return element;
|
|
1868
1891
|
}
|
|
1869
1892
|
return null;
|
|
1870
1893
|
}
|
|
1871
1894
|
|
|
1872
|
-
function getPanelElementsForGroup(groupId) {
|
|
1873
|
-
return Array.from(
|
|
1895
|
+
function getPanelElementsForGroup(groupId, panelGroupElement) {
|
|
1896
|
+
return Array.from(panelGroupElement.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
|
|
1874
1897
|
}
|
|
1875
1898
|
|
|
1876
1899
|
exports.Panel = Panel;
|