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
|
@@ -497,41 +497,48 @@ function calculateAriaValues({
|
|
|
497
497
|
};
|
|
498
498
|
}
|
|
499
499
|
|
|
500
|
-
function getResizeHandleElementsForGroup(groupId) {
|
|
501
|
-
return Array.from(
|
|
500
|
+
function getResizeHandleElementsForGroup(groupId, panelGroupElement) {
|
|
501
|
+
return Array.from(panelGroupElement.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
|
|
502
502
|
}
|
|
503
503
|
|
|
504
|
-
function getResizeHandleElementIndex(groupId, id) {
|
|
505
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
504
|
+
function getResizeHandleElementIndex(groupId, id, panelGroupElement) {
|
|
505
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
506
506
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
507
507
|
return index !== null && index !== void 0 ? index : null;
|
|
508
508
|
}
|
|
509
509
|
|
|
510
|
-
function determinePivotIndices(groupId, dragHandleId) {
|
|
511
|
-
const index = getResizeHandleElementIndex(groupId, dragHandleId);
|
|
510
|
+
function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
|
|
511
|
+
const index = getResizeHandleElementIndex(groupId, dragHandleId, panelGroupElement);
|
|
512
512
|
return index != null ? [index, index + 1] : [-1, -1];
|
|
513
513
|
}
|
|
514
514
|
|
|
515
|
-
function getPanelGroupElement(id) {
|
|
516
|
-
|
|
515
|
+
function getPanelGroupElement(id, rootElement) {
|
|
516
|
+
var _dataset;
|
|
517
|
+
//If the root element is the PanelGroup
|
|
518
|
+
if (rootElement instanceof HTMLElement && (rootElement === null || rootElement === void 0 ? void 0 : (_dataset = rootElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.panelGroupId) == id) {
|
|
519
|
+
return rootElement;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
//Else query children
|
|
523
|
+
const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
517
524
|
if (element) {
|
|
518
525
|
return element;
|
|
519
526
|
}
|
|
520
527
|
return null;
|
|
521
528
|
}
|
|
522
529
|
|
|
523
|
-
function getResizeHandleElement(id) {
|
|
524
|
-
const element =
|
|
530
|
+
function getResizeHandleElement(id, panelGroupElement) {
|
|
531
|
+
const element = panelGroupElement.querySelector(`[data-panel-resize-handle-id="${id}"]`);
|
|
525
532
|
if (element) {
|
|
526
533
|
return element;
|
|
527
534
|
}
|
|
528
535
|
return null;
|
|
529
536
|
}
|
|
530
537
|
|
|
531
|
-
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
538
|
+
function getResizeHandlePanelIds(groupId, handleId, panelsArray, panelGroupElement) {
|
|
532
539
|
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
533
|
-
const handle = getResizeHandleElement(handleId);
|
|
534
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
540
|
+
const handle = getResizeHandleElement(handleId, panelGroupElement);
|
|
541
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
535
542
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
536
543
|
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;
|
|
537
544
|
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
@@ -546,13 +553,17 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
546
553
|
groupId,
|
|
547
554
|
layout,
|
|
548
555
|
panelDataArray,
|
|
556
|
+
panelGroupElement,
|
|
549
557
|
setLayout
|
|
550
558
|
}) {
|
|
551
559
|
useRef({
|
|
552
560
|
didWarnAboutMissingResizeHandle: false
|
|
553
561
|
});
|
|
554
562
|
useIsomorphicLayoutEffect(() => {
|
|
555
|
-
|
|
563
|
+
if (!panelGroupElement) {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
const resizeHandleElements = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
556
567
|
for (let index = 0; index < panelDataArray.length - 1; index++) {
|
|
557
568
|
const {
|
|
558
569
|
valueMax,
|
|
@@ -581,21 +592,24 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
581
592
|
resizeHandleElement.removeAttribute("aria-valuenow");
|
|
582
593
|
});
|
|
583
594
|
};
|
|
584
|
-
}, [groupId, layout, panelDataArray]);
|
|
595
|
+
}, [groupId, layout, panelDataArray, panelGroupElement]);
|
|
585
596
|
useEffect(() => {
|
|
597
|
+
if (!panelGroupElement) {
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
586
600
|
const eagerValues = eagerValuesRef.current;
|
|
587
601
|
assert(eagerValues);
|
|
588
602
|
const {
|
|
589
603
|
panelDataArray
|
|
590
604
|
} = eagerValues;
|
|
591
|
-
const groupElement = getPanelGroupElement(groupId);
|
|
605
|
+
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
592
606
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
593
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
607
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
594
608
|
assert(handles);
|
|
595
609
|
const cleanupFunctions = handles.map(handle => {
|
|
596
610
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
597
611
|
assert(handleId);
|
|
598
|
-
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray);
|
|
612
|
+
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
|
|
599
613
|
if (idBefore == null || idAfter == null) {
|
|
600
614
|
return () => {};
|
|
601
615
|
}
|
|
@@ -622,7 +636,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
622
636
|
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
623
637
|
layout,
|
|
624
638
|
panelConstraints: panelDataArray.map(panelData => panelData.constraints),
|
|
625
|
-
pivotIndices: determinePivotIndices(groupId, handleId),
|
|
639
|
+
pivotIndices: determinePivotIndices(groupId, handleId, panelGroupElement),
|
|
626
640
|
trigger: "keyboard"
|
|
627
641
|
});
|
|
628
642
|
if (layout !== nextLayout) {
|
|
@@ -642,7 +656,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
642
656
|
return () => {
|
|
643
657
|
cleanupFunctions.forEach(cleanupFunction => cleanupFunction());
|
|
644
658
|
};
|
|
645
|
-
}, [committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
|
|
659
|
+
}, [panelGroupElement, committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
|
|
646
660
|
}
|
|
647
661
|
|
|
648
662
|
function areEqual(arrayA, arrayB) {
|
|
@@ -680,9 +694,9 @@ function getResizeEventCursorPosition(direction, event) {
|
|
|
680
694
|
}
|
|
681
695
|
}
|
|
682
696
|
|
|
683
|
-
function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState) {
|
|
697
|
+
function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement) {
|
|
684
698
|
const isHorizontal = direction === "horizontal";
|
|
685
|
-
const handleElement = getResizeHandleElement(dragHandleId);
|
|
699
|
+
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
|
|
686
700
|
assert(handleElement);
|
|
687
701
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
688
702
|
assert(groupId);
|
|
@@ -690,7 +704,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
|
|
|
690
704
|
initialCursorPosition
|
|
691
705
|
} = initialDragState;
|
|
692
706
|
const cursorPosition = getResizeEventCursorPosition(direction, event);
|
|
693
|
-
const groupElement = getPanelGroupElement(groupId);
|
|
707
|
+
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
694
708
|
assert(groupElement);
|
|
695
709
|
const groupRect = groupElement.getBoundingClientRect();
|
|
696
710
|
const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
|
|
@@ -700,7 +714,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
|
|
|
700
714
|
}
|
|
701
715
|
|
|
702
716
|
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX
|
|
703
|
-
function calculateDeltaPercentage(event, dragHandleId, direction, initialDragState, keyboardResizeBy) {
|
|
717
|
+
function calculateDeltaPercentage(event, dragHandleId, direction, initialDragState, keyboardResizeBy, panelGroupElement) {
|
|
704
718
|
if (isKeyDown(event)) {
|
|
705
719
|
const isHorizontal = direction === "horizontal";
|
|
706
720
|
let delta = 0;
|
|
@@ -737,7 +751,7 @@ function calculateDeltaPercentage(event, dragHandleId, direction, initialDragSta
|
|
|
737
751
|
if (initialDragState == null) {
|
|
738
752
|
return 0;
|
|
739
753
|
}
|
|
740
|
-
return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState);
|
|
754
|
+
return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement);
|
|
741
755
|
}
|
|
742
756
|
}
|
|
743
757
|
|
|
@@ -1089,6 +1103,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1089
1103
|
...rest
|
|
1090
1104
|
}) {
|
|
1091
1105
|
const groupId = useUniqueId(idFromProps);
|
|
1106
|
+
const panelGroupElementRef = useRef(null);
|
|
1092
1107
|
const [dragState, setDragState] = useState(null);
|
|
1093
1108
|
const [layout, setLayout] = useState([]);
|
|
1094
1109
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
@@ -1157,7 +1172,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1157
1172
|
groupId,
|
|
1158
1173
|
layout,
|
|
1159
1174
|
panelDataArray: eagerValuesRef.current.panelDataArray,
|
|
1160
|
-
setLayout
|
|
1175
|
+
setLayout,
|
|
1176
|
+
panelGroupElement: panelGroupElementRef.current
|
|
1161
1177
|
});
|
|
1162
1178
|
useEffect(() => {
|
|
1163
1179
|
const {
|
|
@@ -1400,6 +1416,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1400
1416
|
const registerResizeHandle = useCallback(dragHandleId => {
|
|
1401
1417
|
return function resizeHandler(event) {
|
|
1402
1418
|
event.preventDefault();
|
|
1419
|
+
const panelGroupElement = panelGroupElementRef.current;
|
|
1420
|
+
if (!panelGroupElement) {
|
|
1421
|
+
return () => null;
|
|
1422
|
+
}
|
|
1403
1423
|
const {
|
|
1404
1424
|
direction,
|
|
1405
1425
|
dragState,
|
|
@@ -1414,8 +1434,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1414
1434
|
const {
|
|
1415
1435
|
initialLayout
|
|
1416
1436
|
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1417
|
-
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1418
|
-
let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy);
|
|
1437
|
+
const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
|
|
1438
|
+
let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
|
|
1419
1439
|
if (delta === 0) {
|
|
1420
1440
|
return;
|
|
1421
1441
|
}
|
|
@@ -1510,7 +1530,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1510
1530
|
const {
|
|
1511
1531
|
layout
|
|
1512
1532
|
} = eagerValuesRef.current;
|
|
1513
|
-
|
|
1533
|
+
if (!panelGroupElementRef.current) {
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1536
|
+
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElementRef.current);
|
|
1514
1537
|
assert(handleElement);
|
|
1515
1538
|
const initialCursorPosition = getResizeEventCursorPosition(direction, event);
|
|
1516
1539
|
setDragState({
|
|
@@ -1555,7 +1578,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1555
1578
|
resizePanel,
|
|
1556
1579
|
startDragging,
|
|
1557
1580
|
stopDragging,
|
|
1558
|
-
unregisterPanel
|
|
1581
|
+
unregisterPanel,
|
|
1582
|
+
panelGroupElement: panelGroupElementRef.current
|
|
1559
1583
|
}), [collapsePanel, dragState, direction, expandPanel, getPanelSize, getPanelStyle, groupId, isPanelCollapsed, isPanelExpanded, registerPanel, registerResizeHandle, resizePanel, startDragging, stopDragging, unregisterPanel]);
|
|
1560
1584
|
const style = {
|
|
1561
1585
|
display: "flex",
|
|
@@ -1574,6 +1598,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1574
1598
|
...style,
|
|
1575
1599
|
...styleFromProps
|
|
1576
1600
|
},
|
|
1601
|
+
ref: panelGroupElementRef,
|
|
1577
1602
|
// CSS selectors
|
|
1578
1603
|
"data-panel-group": "",
|
|
1579
1604
|
"data-panel-group-direction": direction,
|
|
@@ -1608,13 +1633,14 @@ function panelDataHelper(panelDataArray, panelData, layout) {
|
|
|
1608
1633
|
function useWindowSplitterResizeHandlerBehavior({
|
|
1609
1634
|
disabled,
|
|
1610
1635
|
handleId,
|
|
1611
|
-
resizeHandler
|
|
1636
|
+
resizeHandler,
|
|
1637
|
+
panelGroupElement
|
|
1612
1638
|
}) {
|
|
1613
1639
|
useEffect(() => {
|
|
1614
|
-
if (disabled || resizeHandler == null) {
|
|
1640
|
+
if (disabled || resizeHandler == null || panelGroupElement == null) {
|
|
1615
1641
|
return;
|
|
1616
1642
|
}
|
|
1617
|
-
const handleElement = getResizeHandleElement(handleId);
|
|
1643
|
+
const handleElement = getResizeHandleElement(handleId, panelGroupElement);
|
|
1618
1644
|
if (handleElement == null) {
|
|
1619
1645
|
return;
|
|
1620
1646
|
}
|
|
@@ -1639,8 +1665,8 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1639
1665
|
event.preventDefault();
|
|
1640
1666
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
1641
1667
|
assert(groupId);
|
|
1642
|
-
const handles = getResizeHandleElementsForGroup(groupId);
|
|
1643
|
-
const index = getResizeHandleElementIndex(groupId, handleId);
|
|
1668
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1669
|
+
const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
|
|
1644
1670
|
assert(index !== null);
|
|
1645
1671
|
const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
|
|
1646
1672
|
const nextHandle = handles[nextIndex];
|
|
@@ -1653,7 +1679,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1653
1679
|
return () => {
|
|
1654
1680
|
handleElement.removeEventListener("keydown", onKeyDown);
|
|
1655
1681
|
};
|
|
1656
|
-
}, [disabled, handleId, resizeHandler]);
|
|
1682
|
+
}, [panelGroupElement, disabled, handleId, resizeHandler]);
|
|
1657
1683
|
}
|
|
1658
1684
|
|
|
1659
1685
|
function PanelResizeHandle({
|
|
@@ -1667,7 +1693,7 @@ function PanelResizeHandle({
|
|
|
1667
1693
|
tagName: Type = "div",
|
|
1668
1694
|
...rest
|
|
1669
1695
|
}) {
|
|
1670
|
-
const
|
|
1696
|
+
const elementRef = useRef(null);
|
|
1671
1697
|
|
|
1672
1698
|
// Use a ref to guard against users passing inline props
|
|
1673
1699
|
const callbacksRef = useRef({
|
|
@@ -1686,7 +1712,8 @@ function PanelResizeHandle({
|
|
|
1686
1712
|
groupId,
|
|
1687
1713
|
registerResizeHandle,
|
|
1688
1714
|
startDragging,
|
|
1689
|
-
stopDragging
|
|
1715
|
+
stopDragging,
|
|
1716
|
+
panelGroupElement
|
|
1690
1717
|
} = panelGroupContext;
|
|
1691
1718
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1692
1719
|
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
@@ -1695,9 +1722,9 @@ function PanelResizeHandle({
|
|
|
1695
1722
|
const stopDraggingAndBlur = useCallback(() => {
|
|
1696
1723
|
// Clicking on the drag handle shouldn't leave it focused;
|
|
1697
1724
|
// That would cause the PanelGroup to think it was still active.
|
|
1698
|
-
const
|
|
1699
|
-
assert(
|
|
1700
|
-
|
|
1725
|
+
const element = elementRef.current;
|
|
1726
|
+
assert(element);
|
|
1727
|
+
element.blur();
|
|
1701
1728
|
stopDragging();
|
|
1702
1729
|
const {
|
|
1703
1730
|
onDragging
|
|
@@ -1724,9 +1751,9 @@ function PanelResizeHandle({
|
|
|
1724
1751
|
const onMouseLeave = event => {
|
|
1725
1752
|
resizeHandler(event);
|
|
1726
1753
|
};
|
|
1727
|
-
const
|
|
1728
|
-
assert(
|
|
1729
|
-
const targetDocument =
|
|
1754
|
+
const element = elementRef.current;
|
|
1755
|
+
assert(element);
|
|
1756
|
+
const targetDocument = element.ownerDocument;
|
|
1730
1757
|
targetDocument.body.addEventListener("contextmenu", stopDraggingAndBlur);
|
|
1731
1758
|
targetDocument.body.addEventListener("mousemove", onMove);
|
|
1732
1759
|
targetDocument.body.addEventListener("touchmove", onMove);
|
|
@@ -1745,7 +1772,8 @@ function PanelResizeHandle({
|
|
|
1745
1772
|
useWindowSplitterResizeHandlerBehavior({
|
|
1746
1773
|
disabled,
|
|
1747
1774
|
handleId: resizeHandleId,
|
|
1748
|
-
resizeHandler
|
|
1775
|
+
resizeHandler,
|
|
1776
|
+
panelGroupElement
|
|
1749
1777
|
});
|
|
1750
1778
|
const style = {
|
|
1751
1779
|
cursor: getCursorStyle(direction),
|
|
@@ -1783,7 +1811,7 @@ function PanelResizeHandle({
|
|
|
1783
1811
|
onDragging(true);
|
|
1784
1812
|
}
|
|
1785
1813
|
},
|
|
1786
|
-
ref:
|
|
1814
|
+
ref: elementRef,
|
|
1787
1815
|
role: "separator",
|
|
1788
1816
|
style: {
|
|
1789
1817
|
...style,
|
|
@@ -1801,13 +1829,12 @@ function PanelResizeHandle({
|
|
|
1801
1829
|
}
|
|
1802
1830
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1803
1831
|
|
|
1804
|
-
function calculateAvailablePanelSizeInPixels(groupId) {
|
|
1805
|
-
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1832
|
+
function calculateAvailablePanelSizeInPixels(groupId, panelGroupElement) {
|
|
1806
1833
|
if (panelGroupElement == null) {
|
|
1807
1834
|
return NaN;
|
|
1808
1835
|
}
|
|
1809
1836
|
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1810
|
-
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1837
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1811
1838
|
if (direction === "horizontal") {
|
|
1812
1839
|
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1813
1840
|
return accumulated + handle.offsetWidth;
|
|
@@ -1819,13 +1846,9 @@ function calculateAvailablePanelSizeInPixels(groupId) {
|
|
|
1819
1846
|
}
|
|
1820
1847
|
}
|
|
1821
1848
|
|
|
1822
|
-
function getAvailableGroupSizePixels(groupId) {
|
|
1823
|
-
const panelGroupElement = getPanelGroupElement(groupId);
|
|
1824
|
-
if (panelGroupElement == null) {
|
|
1825
|
-
return NaN;
|
|
1826
|
-
}
|
|
1849
|
+
function getAvailableGroupSizePixels(groupId, panelGroupElement) {
|
|
1827
1850
|
const direction = panelGroupElement.getAttribute("data-panel-group-direction");
|
|
1828
|
-
const resizeHandles = getResizeHandleElementsForGroup(groupId);
|
|
1851
|
+
const resizeHandles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1829
1852
|
if (direction === "horizontal") {
|
|
1830
1853
|
return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
|
|
1831
1854
|
return accumulated + handle.offsetWidth;
|
|
@@ -1837,16 +1860,16 @@ function getAvailableGroupSizePixels(groupId) {
|
|
|
1837
1860
|
}
|
|
1838
1861
|
}
|
|
1839
1862
|
|
|
1840
|
-
function getPanelElement(id) {
|
|
1841
|
-
const element =
|
|
1863
|
+
function getPanelElement(id, panelGroupElement) {
|
|
1864
|
+
const element = panelGroupElement.querySelector(`[data-panel-id="${id}"]`);
|
|
1842
1865
|
if (element) {
|
|
1843
1866
|
return element;
|
|
1844
1867
|
}
|
|
1845
1868
|
return null;
|
|
1846
1869
|
}
|
|
1847
1870
|
|
|
1848
|
-
function getPanelElementsForGroup(groupId) {
|
|
1849
|
-
return Array.from(
|
|
1871
|
+
function getPanelElementsForGroup(groupId, panelGroupElement) {
|
|
1872
|
+
return Array.from(panelGroupElement.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
|
|
1850
1873
|
}
|
|
1851
1874
|
|
|
1852
1875
|
export { Panel, PanelGroup, PanelResizeHandle, assert, calculateAvailablePanelSizeInPixels, getAvailableGroupSizePixels, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds };
|