react-resizable-panels 2.0.8 → 2.0.10
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 +9 -0
- package/dist/declarations/src/utils/assert.d.ts +1 -1
- package/dist/react-resizable-panels.browser.cjs.js +158 -53
- package/dist/react-resizable-panels.browser.development.cjs.js +160 -55
- package/dist/react-resizable-panels.browser.development.esm.js +159 -54
- package/dist/react-resizable-panels.browser.esm.js +157 -52
- package/dist/react-resizable-panels.cjs.js +158 -53
- package/dist/react-resizable-panels.development.cjs.js +160 -55
- package/dist/react-resizable-panels.development.esm.js +159 -54
- package/dist/react-resizable-panels.development.node.cjs.js +156 -51
- package/dist/react-resizable-panels.development.node.esm.js +155 -50
- package/dist/react-resizable-panels.esm.js +157 -52
- package/dist/react-resizable-panels.node.cjs.js +154 -49
- package/dist/react-resizable-panels.node.esm.js +153 -48
- package/package.json +1 -4
- package/src/Panel.test.tsx +23 -23
- package/src/PanelGroup.test.tsx +32 -3
- package/src/PanelGroup.ts +25 -7
- package/src/PanelResizeHandle.test.tsx +3 -3
- package/src/PanelResizeHandle.ts +1 -1
- package/src/PanelResizeHandleRegistry.ts +2 -2
- package/src/hooks/useWindowSplitterBehavior.ts +5 -2
- package/src/hooks/useWindowSplitterPanelGroupBehavior.ts +5 -5
- package/src/utils/adjustLayoutByDelta.ts +47 -20
- package/src/utils/assert.ts +1 -1
- package/src/utils/calculateAriaValues.ts +1 -1
- package/src/utils/calculateDragOffsetPercentage.ts +6 -3
- package/src/utils/calculateUnsafeDefaultLayout.ts +2 -2
- package/src/utils/callPanelCallbacks.ts +1 -1
- package/src/utils/resizePanel.ts +4 -1
- package/src/utils/test-utils.ts +1 -1
- package/src/utils/validatePanelConstraints.ts +4 -1
- package/src/utils/validatePanelGroupLayout.ts +3 -3
- package/src/vendor/stacking-order.ts +133 -0
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var stackingOrder = require('stacking-order');
|
|
7
6
|
|
|
8
7
|
function _interopNamespace(e) {
|
|
9
8
|
if (e && e.__esModule) return e;
|
|
@@ -279,6 +278,114 @@ function intersects(rectOne, rectTwo, strict) {
|
|
|
279
278
|
}
|
|
280
279
|
}
|
|
281
280
|
|
|
281
|
+
// Forked from NPM stacking-order@2.0.0
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Determine which of two nodes appears in front of the other —
|
|
285
|
+
* if `a` is in front, returns 1, otherwise returns -1
|
|
286
|
+
* @param {HTMLElement} a
|
|
287
|
+
* @param {HTMLElement} b
|
|
288
|
+
*/
|
|
289
|
+
function compare(a, b) {
|
|
290
|
+
if (a === b) throw new Error("Cannot compare node with itself");
|
|
291
|
+
const ancestors = {
|
|
292
|
+
a: get_ancestors(a),
|
|
293
|
+
b: get_ancestors(b)
|
|
294
|
+
};
|
|
295
|
+
let common_ancestor;
|
|
296
|
+
|
|
297
|
+
// remove shared ancestors
|
|
298
|
+
while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
|
|
299
|
+
a = ancestors.a.pop();
|
|
300
|
+
b = ancestors.b.pop();
|
|
301
|
+
common_ancestor = a;
|
|
302
|
+
}
|
|
303
|
+
assert(common_ancestor, "Stacking order can only be calculated for elements with a common ancestor");
|
|
304
|
+
const z_indexes = {
|
|
305
|
+
a: get_z_index(find_stacking_context(ancestors.a)),
|
|
306
|
+
b: get_z_index(find_stacking_context(ancestors.b))
|
|
307
|
+
};
|
|
308
|
+
if (z_indexes.a === z_indexes.b) {
|
|
309
|
+
const children = common_ancestor.childNodes;
|
|
310
|
+
const furthest_ancestors = {
|
|
311
|
+
a: ancestors.a.at(-1),
|
|
312
|
+
b: ancestors.b.at(-1)
|
|
313
|
+
};
|
|
314
|
+
let i = children.length;
|
|
315
|
+
while (i--) {
|
|
316
|
+
const child = children[i];
|
|
317
|
+
if (child === furthest_ancestors.a) return 1;
|
|
318
|
+
if (child === furthest_ancestors.b) return -1;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return Math.sign(z_indexes.a - z_indexes.b);
|
|
322
|
+
}
|
|
323
|
+
const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
324
|
+
|
|
325
|
+
/** @param {HTMLElement} node */
|
|
326
|
+
function is_flex_item(node) {
|
|
327
|
+
const display = getComputedStyle(get_parent(node)).display;
|
|
328
|
+
return display === "flex" || display === "inline-flex";
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** @param {HTMLElement} node */
|
|
332
|
+
function creates_stacking_context(node) {
|
|
333
|
+
const style = getComputedStyle(node);
|
|
334
|
+
|
|
335
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
|
|
336
|
+
if (style.position === "fixed") return true;
|
|
337
|
+
// Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
|
|
338
|
+
// if (
|
|
339
|
+
// (style.zIndex !== "auto" && style.position !== "static") ||
|
|
340
|
+
// is_flex_item(node)
|
|
341
|
+
// )
|
|
342
|
+
if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
|
|
343
|
+
if (+style.opacity < 1) return true;
|
|
344
|
+
if ("transform" in style && style.transform !== "none") return true;
|
|
345
|
+
if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
|
|
346
|
+
if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
|
|
347
|
+
if ("filter" in style && style.filter !== "none") return true;
|
|
348
|
+
if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
|
|
349
|
+
if ("isolation" in style && style.isolation === "isolate") return true;
|
|
350
|
+
if (props.test(style.willChange)) return true;
|
|
351
|
+
// @ts-expect-error
|
|
352
|
+
if (style.webkitOverflowScrolling === "touch") return true;
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** @param {HTMLElement[]} nodes */
|
|
357
|
+
function find_stacking_context(nodes) {
|
|
358
|
+
let i = nodes.length;
|
|
359
|
+
while (i--) {
|
|
360
|
+
const node = nodes[i];
|
|
361
|
+
assert(node, "Missing node");
|
|
362
|
+
if (creates_stacking_context(node)) return node;
|
|
363
|
+
}
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** @param {HTMLElement} node */
|
|
368
|
+
function get_z_index(node) {
|
|
369
|
+
return node && Number(getComputedStyle(node).zIndex) || 0;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** @param {HTMLElement} node */
|
|
373
|
+
function get_ancestors(node) {
|
|
374
|
+
const ancestors = [];
|
|
375
|
+
while (node) {
|
|
376
|
+
ancestors.push(node);
|
|
377
|
+
node = get_parent(node);
|
|
378
|
+
}
|
|
379
|
+
return ancestors; // [ node, ... <body>, <html>, document ]
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** @param {HTMLElement} node */
|
|
383
|
+
function get_parent(node) {
|
|
384
|
+
var _node$parentNode;
|
|
385
|
+
// @ts-ignore
|
|
386
|
+
return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
|
|
387
|
+
}
|
|
388
|
+
|
|
282
389
|
const EXCEEDED_HORIZONTAL_MIN = 0b0001;
|
|
283
390
|
const EXCEEDED_HORIZONTAL_MAX = 0b0010;
|
|
284
391
|
const EXCEEDED_VERTICAL_MIN = 0b0100;
|
|
@@ -420,7 +527,7 @@ function recalculateIntersectingHandles({
|
|
|
420
527
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
421
528
|
// That is why we only check potentially intersecting handles,
|
|
422
529
|
// and why we skip if the event target is within the handle's DOM
|
|
423
|
-
|
|
530
|
+
compare(targetElement, dragHandleElement) > 0) {
|
|
424
531
|
// If the target is above the drag handle, then we also need to confirm they overlap
|
|
425
532
|
// If they are beside each other (e.g. a panel and its drag handle) then the handle is still interactive
|
|
426
533
|
//
|
|
@@ -491,7 +598,7 @@ function updateListeners() {
|
|
|
491
598
|
window.removeEventListener("mouseup", handlePointerUp);
|
|
492
599
|
window.removeEventListener("touchcancel", handlePointerUp);
|
|
493
600
|
window.removeEventListener("touchend", handlePointerUp);
|
|
494
|
-
if (
|
|
601
|
+
if (registeredResizeHandlers.size > 0) {
|
|
495
602
|
if (isPointerDown) {
|
|
496
603
|
if (intersectingHandles.length > 0) {
|
|
497
604
|
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
@@ -538,7 +645,7 @@ function updateResizeHandlerStates(action, event) {
|
|
|
538
645
|
});
|
|
539
646
|
}
|
|
540
647
|
|
|
541
|
-
function assert(expectedCondition, message
|
|
648
|
+
function assert(expectedCondition, message) {
|
|
542
649
|
if (!expectedCondition) {
|
|
543
650
|
console.error(message);
|
|
544
651
|
throw Error(message);
|
|
@@ -569,7 +676,7 @@ function resizePanel({
|
|
|
569
676
|
size
|
|
570
677
|
}) {
|
|
571
678
|
const panelConstraints = panelConstraintsArray[panelIndex];
|
|
572
|
-
assert(panelConstraints != null);
|
|
679
|
+
assert(panelConstraints != null, `Panel constraints not found for index ${panelIndex}`);
|
|
573
680
|
let {
|
|
574
681
|
collapsedSize = 0,
|
|
575
682
|
collapsible,
|
|
@@ -607,8 +714,8 @@ function adjustLayoutByDelta({
|
|
|
607
714
|
}
|
|
608
715
|
const nextLayout = [...prevLayout];
|
|
609
716
|
const [firstPivotIndex, secondPivotIndex] = pivotIndices;
|
|
610
|
-
assert(firstPivotIndex != null);
|
|
611
|
-
assert(secondPivotIndex != null);
|
|
717
|
+
assert(firstPivotIndex != null, "Invalid first pivot index");
|
|
718
|
+
assert(secondPivotIndex != null, "Invalid second pivot index");
|
|
612
719
|
let deltaApplied = 0;
|
|
613
720
|
|
|
614
721
|
//const DEBUG = [];
|
|
@@ -634,19 +741,18 @@ function adjustLayoutByDelta({
|
|
|
634
741
|
// Check if we should expand a collapsed panel
|
|
635
742
|
const index = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
636
743
|
const panelConstraints = panelConstraintsArray[index];
|
|
637
|
-
assert(panelConstraints);
|
|
744
|
+
assert(panelConstraints, `Panel constraints not found for index ${index}`);
|
|
745
|
+
const {
|
|
746
|
+
collapsedSize = 0,
|
|
747
|
+
collapsible,
|
|
748
|
+
minSize = 0
|
|
749
|
+
} = panelConstraints;
|
|
638
750
|
|
|
639
751
|
//DEBUG.push(`edge case check 1: ${index}`);
|
|
640
752
|
//DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
|
|
641
|
-
if (
|
|
753
|
+
if (collapsible) {
|
|
642
754
|
const prevSize = prevLayout[index];
|
|
643
|
-
assert(prevSize != null);
|
|
644
|
-
const panelConstraints = panelConstraintsArray[index];
|
|
645
|
-
assert(panelConstraints);
|
|
646
|
-
const {
|
|
647
|
-
collapsedSize = 0,
|
|
648
|
-
minSize = 0
|
|
649
|
-
} = panelConstraints;
|
|
755
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
650
756
|
if (fuzzyNumbersEqual(prevSize, collapsedSize)) {
|
|
651
757
|
const localDelta = minSize - prevSize;
|
|
652
758
|
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
@@ -663,22 +769,18 @@ function adjustLayoutByDelta({
|
|
|
663
769
|
// Check if we should collapse a panel at its minimum size
|
|
664
770
|
const index = delta < 0 ? firstPivotIndex : secondPivotIndex;
|
|
665
771
|
const panelConstraints = panelConstraintsArray[index];
|
|
666
|
-
assert(panelConstraints);
|
|
772
|
+
assert(panelConstraints, `No panel constraints found for index ${index}`);
|
|
667
773
|
const {
|
|
668
|
-
|
|
774
|
+
collapsedSize = 0,
|
|
775
|
+
collapsible,
|
|
776
|
+
minSize = 0
|
|
669
777
|
} = panelConstraints;
|
|
670
778
|
|
|
671
779
|
//DEBUG.push(`edge case check 2: ${index}`);
|
|
672
780
|
//DEBUG.push(` -> collapsible? ${collapsible}`);
|
|
673
781
|
if (collapsible) {
|
|
674
782
|
const prevSize = prevLayout[index];
|
|
675
|
-
assert(prevSize != null);
|
|
676
|
-
const panelConstraints = panelConstraintsArray[index];
|
|
677
|
-
assert(panelConstraints);
|
|
678
|
-
const {
|
|
679
|
-
collapsedSize = 0,
|
|
680
|
-
minSize = 0
|
|
681
|
-
} = panelConstraints;
|
|
783
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
682
784
|
if (fuzzyNumbersEqual(prevSize, minSize)) {
|
|
683
785
|
const localDelta = prevSize - collapsedSize;
|
|
684
786
|
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
@@ -708,7 +810,7 @@ function adjustLayoutByDelta({
|
|
|
708
810
|
//DEBUG.push("pre calc...");
|
|
709
811
|
while (true) {
|
|
710
812
|
const prevSize = prevLayout[index];
|
|
711
|
-
assert(prevSize != null);
|
|
813
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
712
814
|
const maxSafeSize = resizePanel({
|
|
713
815
|
panelConstraints: panelConstraintsArray,
|
|
714
816
|
panelIndex: index,
|
|
@@ -739,7 +841,7 @@ function adjustLayoutByDelta({
|
|
|
739
841
|
while (index >= 0 && index < panelConstraintsArray.length) {
|
|
740
842
|
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
741
843
|
const prevSize = prevLayout[index];
|
|
742
|
-
assert(prevSize != null);
|
|
844
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
743
845
|
const unsafeSize = prevSize - deltaRemaining;
|
|
744
846
|
const safeSize = resizePanel({
|
|
745
847
|
panelConstraints: panelConstraintsArray,
|
|
@@ -776,7 +878,7 @@ function adjustLayoutByDelta({
|
|
|
776
878
|
// Now distribute the applied delta to the panels in the other direction
|
|
777
879
|
const pivotIndex = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
778
880
|
const prevSize = prevLayout[pivotIndex];
|
|
779
|
-
assert(prevSize != null);
|
|
881
|
+
assert(prevSize != null, `Previous layout not found for panel index ${pivotIndex}`);
|
|
780
882
|
const unsafeSize = prevSize + deltaApplied;
|
|
781
883
|
const safeSize = resizePanel({
|
|
782
884
|
panelConstraints: panelConstraintsArray,
|
|
@@ -794,7 +896,7 @@ function adjustLayoutByDelta({
|
|
|
794
896
|
let index = pivotIndex;
|
|
795
897
|
while (index >= 0 && index < panelConstraintsArray.length) {
|
|
796
898
|
const prevSize = nextLayout[index];
|
|
797
|
-
assert(prevSize != null);
|
|
899
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
798
900
|
const unsafeSize = prevSize + deltaRemaining;
|
|
799
901
|
const safeSize = resizePanel({
|
|
800
902
|
panelConstraints: panelConstraintsArray,
|
|
@@ -897,17 +999,17 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
897
999
|
return;
|
|
898
1000
|
}
|
|
899
1001
|
const eagerValues = eagerValuesRef.current;
|
|
900
|
-
assert(eagerValues);
|
|
1002
|
+
assert(eagerValues, `Eager values not found`);
|
|
901
1003
|
const {
|
|
902
1004
|
panelDataArray
|
|
903
1005
|
} = eagerValues;
|
|
904
1006
|
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
905
1007
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
906
1008
|
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
907
|
-
assert(handles);
|
|
1009
|
+
assert(handles, `No resize handles found for group id "${groupId}"`);
|
|
908
1010
|
const cleanupFunctions = handles.map(handle => {
|
|
909
1011
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
910
|
-
assert(handleId);
|
|
1012
|
+
assert(handleId, `Resize handle element has no handle id attribute`);
|
|
911
1013
|
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
|
|
912
1014
|
if (idBefore == null || idAfter == null) {
|
|
913
1015
|
return () => {};
|
|
@@ -923,7 +1025,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
923
1025
|
const index = panelDataArray.findIndex(panelData => panelData.id === idBefore);
|
|
924
1026
|
if (index >= 0) {
|
|
925
1027
|
const panelData = panelDataArray[index];
|
|
926
|
-
assert(panelData);
|
|
1028
|
+
assert(panelData, `No panel data found for index ${index}`);
|
|
927
1029
|
const size = layout[index];
|
|
928
1030
|
const {
|
|
929
1031
|
collapsedSize = 0,
|
|
@@ -982,15 +1084,15 @@ function getResizeEventCursorPosition(direction, event) {
|
|
|
982
1084
|
function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement) {
|
|
983
1085
|
const isHorizontal = direction === "horizontal";
|
|
984
1086
|
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
|
|
985
|
-
assert(handleElement);
|
|
1087
|
+
assert(handleElement, `No resize handle element found for id "${dragHandleId}"`);
|
|
986
1088
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
987
|
-
assert(groupId);
|
|
1089
|
+
assert(groupId, `Resize handle element has no group id attribute`);
|
|
988
1090
|
let {
|
|
989
1091
|
initialCursorPosition
|
|
990
1092
|
} = initialDragState;
|
|
991
1093
|
const cursorPosition = getResizeEventCursorPosition(direction, event);
|
|
992
1094
|
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
993
|
-
assert(groupElement);
|
|
1095
|
+
assert(groupElement, `No group element found for id "${groupId}"`);
|
|
994
1096
|
const groupRect = groupElement.getBoundingClientRect();
|
|
995
1097
|
const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
|
|
996
1098
|
const offsetPixels = cursorPosition - initialCursorPosition;
|
|
@@ -1044,7 +1146,7 @@ function calculateDeltaPercentage(event, dragHandleId, direction, initialDragSta
|
|
|
1044
1146
|
function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
1045
1147
|
layout.forEach((size, index) => {
|
|
1046
1148
|
const panelData = panelsArray[index];
|
|
1047
|
-
assert(panelData);
|
|
1149
|
+
assert(panelData, `Panel data not found for index ${index}`);
|
|
1048
1150
|
const {
|
|
1049
1151
|
callbacks,
|
|
1050
1152
|
constraints,
|
|
@@ -1222,7 +1324,7 @@ function validatePanelConstraints({
|
|
|
1222
1324
|
{
|
|
1223
1325
|
const warnings = [];
|
|
1224
1326
|
const panelConstraints = panelConstraintsArray[panelIndex];
|
|
1225
|
-
assert(panelConstraints);
|
|
1327
|
+
assert(panelConstraints, `No panel constraints found for index ${panelIndex}`);
|
|
1226
1328
|
const {
|
|
1227
1329
|
collapsedSize = 0,
|
|
1228
1330
|
collapsible = false,
|
|
@@ -1276,7 +1378,7 @@ function validatePanelGroupLayout({
|
|
|
1276
1378
|
}
|
|
1277
1379
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1278
1380
|
const unsafeSize = nextLayout[index];
|
|
1279
|
-
assert(unsafeSize != null);
|
|
1381
|
+
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
1280
1382
|
const safeSize = 100 / nextLayoutTotalSize * unsafeSize;
|
|
1281
1383
|
nextLayout[index] = safeSize;
|
|
1282
1384
|
}
|
|
@@ -1286,7 +1388,7 @@ function validatePanelGroupLayout({
|
|
|
1286
1388
|
// First pass: Validate the proposed layout given each panel's constraints
|
|
1287
1389
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1288
1390
|
const unsafeSize = nextLayout[index];
|
|
1289
|
-
assert(unsafeSize != null);
|
|
1391
|
+
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
1290
1392
|
const safeSize = resizePanel({
|
|
1291
1393
|
panelConstraints,
|
|
1292
1394
|
panelIndex: index,
|
|
@@ -1303,7 +1405,7 @@ function validatePanelGroupLayout({
|
|
|
1303
1405
|
if (!fuzzyNumbersEqual(remainingSize, 0)) {
|
|
1304
1406
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1305
1407
|
const prevSize = nextLayout[index];
|
|
1306
|
-
assert(prevSize != null);
|
|
1408
|
+
assert(prevSize != null, `No layout data found for index ${index}`);
|
|
1307
1409
|
const unsafeSize = prevSize + remainingSize;
|
|
1308
1410
|
const safeSize = resizePanel({
|
|
1309
1411
|
panelConstraints,
|
|
@@ -1472,7 +1574,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1472
1574
|
const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
|
|
1473
1575
|
for (let panelIndex = 0; panelIndex < panelConstraints.length; panelIndex++) {
|
|
1474
1576
|
const panelData = panelDataArray[panelIndex];
|
|
1475
|
-
assert(panelData);
|
|
1577
|
+
assert(panelData, `Panel data not found for index ${panelIndex}`);
|
|
1476
1578
|
const isValid = validatePanelConstraints({
|
|
1477
1579
|
panelConstraints,
|
|
1478
1580
|
panelId: panelData.id,
|
|
@@ -1503,7 +1605,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1503
1605
|
panelSize,
|
|
1504
1606
|
pivotIndices
|
|
1505
1607
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1506
|
-
assert(panelSize != null);
|
|
1608
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1507
1609
|
if (panelSize !== collapsedSize) {
|
|
1508
1610
|
// Store size before collapse;
|
|
1509
1611
|
// This is the size that gets restored if the expand() API is used.
|
|
@@ -1580,7 +1682,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1580
1682
|
const {
|
|
1581
1683
|
panelSize
|
|
1582
1684
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
1583
|
-
assert(panelSize != null);
|
|
1685
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1584
1686
|
return panelSize;
|
|
1585
1687
|
}, []);
|
|
1586
1688
|
|
|
@@ -1624,7 +1726,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1624
1726
|
collapsible,
|
|
1625
1727
|
panelSize
|
|
1626
1728
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
1627
|
-
assert(panelSize != null);
|
|
1729
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1628
1730
|
return !collapsible || panelSize > collapsedSize;
|
|
1629
1731
|
}, []);
|
|
1630
1732
|
const registerPanel = useCallback(panelData => {
|
|
@@ -1735,7 +1837,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1735
1837
|
panelSize,
|
|
1736
1838
|
pivotIndices
|
|
1737
1839
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1738
|
-
assert(panelSize != null);
|
|
1840
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1739
1841
|
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1740
1842
|
const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
|
|
1741
1843
|
const nextLayout = adjustLayoutByDelta({
|
|
@@ -1772,7 +1874,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1772
1874
|
const {
|
|
1773
1875
|
panelSize: prevPanelSize
|
|
1774
1876
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
1775
|
-
|
|
1877
|
+
if (prevPanelSize == null) {
|
|
1878
|
+
// It's possible that the panels in this group have changed since the last render
|
|
1879
|
+
return;
|
|
1880
|
+
}
|
|
1776
1881
|
if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
|
|
1777
1882
|
if (prevCollapsedSize !== nextCollapsedSize) {
|
|
1778
1883
|
resizePanel(panelData, nextCollapsedSize);
|
|
@@ -1794,7 +1899,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1794
1899
|
return;
|
|
1795
1900
|
}
|
|
1796
1901
|
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElementRef.current);
|
|
1797
|
-
assert(handleElement);
|
|
1902
|
+
assert(handleElement, `Drag handle element not found for id "${dragHandleId}"`);
|
|
1798
1903
|
const initialCursorPosition = getResizeEventCursorPosition(direction, event);
|
|
1799
1904
|
setDragState({
|
|
1800
1905
|
dragHandleId,
|
|
@@ -1923,10 +2028,10 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1923
2028
|
{
|
|
1924
2029
|
event.preventDefault();
|
|
1925
2030
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
1926
|
-
assert(groupId);
|
|
2031
|
+
assert(groupId, `No group element found for id "${groupId}"`);
|
|
1927
2032
|
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1928
2033
|
const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
|
|
1929
|
-
assert(index !== null);
|
|
2034
|
+
assert(index !== null, `No resize element found for id "${handleId}"`);
|
|
1930
2035
|
const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
|
|
1931
2036
|
const nextHandle = handles[nextIndex];
|
|
1932
2037
|
nextHandle.focus();
|
|
@@ -1995,7 +2100,7 @@ function PanelResizeHandle({
|
|
|
1995
2100
|
return;
|
|
1996
2101
|
}
|
|
1997
2102
|
const element = elementRef.current;
|
|
1998
|
-
assert(element);
|
|
2103
|
+
assert(element, "Element ref not attached");
|
|
1999
2104
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2000
2105
|
if (isActive) {
|
|
2001
2106
|
switch (action) {
|