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