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;
|
|
@@ -306,6 +305,114 @@ function intersects(rectOne, rectTwo, strict) {
|
|
|
306
305
|
}
|
|
307
306
|
}
|
|
308
307
|
|
|
308
|
+
// Forked from NPM stacking-order@2.0.0
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Determine which of two nodes appears in front of the other —
|
|
312
|
+
* if `a` is in front, returns 1, otherwise returns -1
|
|
313
|
+
* @param {HTMLElement} a
|
|
314
|
+
* @param {HTMLElement} b
|
|
315
|
+
*/
|
|
316
|
+
function compare(a, b) {
|
|
317
|
+
if (a === b) throw new Error("Cannot compare node with itself");
|
|
318
|
+
const ancestors = {
|
|
319
|
+
a: get_ancestors(a),
|
|
320
|
+
b: get_ancestors(b)
|
|
321
|
+
};
|
|
322
|
+
let common_ancestor;
|
|
323
|
+
|
|
324
|
+
// remove shared ancestors
|
|
325
|
+
while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
|
|
326
|
+
a = ancestors.a.pop();
|
|
327
|
+
b = ancestors.b.pop();
|
|
328
|
+
common_ancestor = a;
|
|
329
|
+
}
|
|
330
|
+
assert(common_ancestor, "Stacking order can only be calculated for elements with a common ancestor");
|
|
331
|
+
const z_indexes = {
|
|
332
|
+
a: get_z_index(find_stacking_context(ancestors.a)),
|
|
333
|
+
b: get_z_index(find_stacking_context(ancestors.b))
|
|
334
|
+
};
|
|
335
|
+
if (z_indexes.a === z_indexes.b) {
|
|
336
|
+
const children = common_ancestor.childNodes;
|
|
337
|
+
const furthest_ancestors = {
|
|
338
|
+
a: ancestors.a.at(-1),
|
|
339
|
+
b: ancestors.b.at(-1)
|
|
340
|
+
};
|
|
341
|
+
let i = children.length;
|
|
342
|
+
while (i--) {
|
|
343
|
+
const child = children[i];
|
|
344
|
+
if (child === furthest_ancestors.a) return 1;
|
|
345
|
+
if (child === furthest_ancestors.b) return -1;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return Math.sign(z_indexes.a - z_indexes.b);
|
|
349
|
+
}
|
|
350
|
+
const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
351
|
+
|
|
352
|
+
/** @param {HTMLElement} node */
|
|
353
|
+
function is_flex_item(node) {
|
|
354
|
+
const display = getComputedStyle(get_parent(node)).display;
|
|
355
|
+
return display === "flex" || display === "inline-flex";
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** @param {HTMLElement} node */
|
|
359
|
+
function creates_stacking_context(node) {
|
|
360
|
+
const style = getComputedStyle(node);
|
|
361
|
+
|
|
362
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
|
|
363
|
+
if (style.position === "fixed") return true;
|
|
364
|
+
// Forked to fix upstream bug https://github.com/Rich-Harris/stacking-order/issues/3
|
|
365
|
+
// if (
|
|
366
|
+
// (style.zIndex !== "auto" && style.position !== "static") ||
|
|
367
|
+
// is_flex_item(node)
|
|
368
|
+
// )
|
|
369
|
+
if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node))) return true;
|
|
370
|
+
if (+style.opacity < 1) return true;
|
|
371
|
+
if ("transform" in style && style.transform !== "none") return true;
|
|
372
|
+
if ("webkitTransform" in style && style.webkitTransform !== "none") return true;
|
|
373
|
+
if ("mixBlendMode" in style && style.mixBlendMode !== "normal") return true;
|
|
374
|
+
if ("filter" in style && style.filter !== "none") return true;
|
|
375
|
+
if ("webkitFilter" in style && style.webkitFilter !== "none") return true;
|
|
376
|
+
if ("isolation" in style && style.isolation === "isolate") return true;
|
|
377
|
+
if (props.test(style.willChange)) return true;
|
|
378
|
+
// @ts-expect-error
|
|
379
|
+
if (style.webkitOverflowScrolling === "touch") return true;
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** @param {HTMLElement[]} nodes */
|
|
384
|
+
function find_stacking_context(nodes) {
|
|
385
|
+
let i = nodes.length;
|
|
386
|
+
while (i--) {
|
|
387
|
+
const node = nodes[i];
|
|
388
|
+
assert(node, "Missing node");
|
|
389
|
+
if (creates_stacking_context(node)) return node;
|
|
390
|
+
}
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** @param {HTMLElement} node */
|
|
395
|
+
function get_z_index(node) {
|
|
396
|
+
return node && Number(getComputedStyle(node).zIndex) || 0;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** @param {HTMLElement} node */
|
|
400
|
+
function get_ancestors(node) {
|
|
401
|
+
const ancestors = [];
|
|
402
|
+
while (node) {
|
|
403
|
+
ancestors.push(node);
|
|
404
|
+
node = get_parent(node);
|
|
405
|
+
}
|
|
406
|
+
return ancestors; // [ node, ... <body>, <html>, document ]
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** @param {HTMLElement} node */
|
|
410
|
+
function get_parent(node) {
|
|
411
|
+
var _node$parentNode;
|
|
412
|
+
// @ts-ignore
|
|
413
|
+
return ((_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.host) || node.parentNode;
|
|
414
|
+
}
|
|
415
|
+
|
|
309
416
|
const EXCEEDED_HORIZONTAL_MIN = 0b0001;
|
|
310
417
|
const EXCEEDED_HORIZONTAL_MAX = 0b0010;
|
|
311
418
|
const EXCEEDED_VERTICAL_MIN = 0b0100;
|
|
@@ -447,7 +554,7 @@ function recalculateIntersectingHandles({
|
|
|
447
554
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
448
555
|
// That is why we only check potentially intersecting handles,
|
|
449
556
|
// and why we skip if the event target is within the handle's DOM
|
|
450
|
-
|
|
557
|
+
compare(targetElement, dragHandleElement) > 0) {
|
|
451
558
|
// If the target is above the drag handle, then we also need to confirm they overlap
|
|
452
559
|
// If they are beside each other (e.g. a panel and its drag handle) then the handle is still interactive
|
|
453
560
|
//
|
|
@@ -518,7 +625,7 @@ function updateListeners() {
|
|
|
518
625
|
window.removeEventListener("mouseup", handlePointerUp);
|
|
519
626
|
window.removeEventListener("touchcancel", handlePointerUp);
|
|
520
627
|
window.removeEventListener("touchend", handlePointerUp);
|
|
521
|
-
if (
|
|
628
|
+
if (registeredResizeHandlers.size > 0) {
|
|
522
629
|
if (isPointerDown) {
|
|
523
630
|
if (intersectingHandles.length > 0) {
|
|
524
631
|
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
@@ -565,7 +672,7 @@ function updateResizeHandlerStates(action, event) {
|
|
|
565
672
|
});
|
|
566
673
|
}
|
|
567
674
|
|
|
568
|
-
function assert(expectedCondition, message
|
|
675
|
+
function assert(expectedCondition, message) {
|
|
569
676
|
if (!expectedCondition) {
|
|
570
677
|
console.error(message);
|
|
571
678
|
throw Error(message);
|
|
@@ -596,7 +703,7 @@ function resizePanel({
|
|
|
596
703
|
size
|
|
597
704
|
}) {
|
|
598
705
|
const panelConstraints = panelConstraintsArray[panelIndex];
|
|
599
|
-
assert(panelConstraints != null);
|
|
706
|
+
assert(panelConstraints != null, `Panel constraints not found for index ${panelIndex}`);
|
|
600
707
|
let {
|
|
601
708
|
collapsedSize = 0,
|
|
602
709
|
collapsible,
|
|
@@ -634,8 +741,8 @@ function adjustLayoutByDelta({
|
|
|
634
741
|
}
|
|
635
742
|
const nextLayout = [...prevLayout];
|
|
636
743
|
const [firstPivotIndex, secondPivotIndex] = pivotIndices;
|
|
637
|
-
assert(firstPivotIndex != null);
|
|
638
|
-
assert(secondPivotIndex != null);
|
|
744
|
+
assert(firstPivotIndex != null, "Invalid first pivot index");
|
|
745
|
+
assert(secondPivotIndex != null, "Invalid second pivot index");
|
|
639
746
|
let deltaApplied = 0;
|
|
640
747
|
|
|
641
748
|
//const DEBUG = [];
|
|
@@ -661,19 +768,18 @@ function adjustLayoutByDelta({
|
|
|
661
768
|
// Check if we should expand a collapsed panel
|
|
662
769
|
const index = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
663
770
|
const panelConstraints = panelConstraintsArray[index];
|
|
664
|
-
assert(panelConstraints);
|
|
771
|
+
assert(panelConstraints, `Panel constraints not found for index ${index}`);
|
|
772
|
+
const {
|
|
773
|
+
collapsedSize = 0,
|
|
774
|
+
collapsible,
|
|
775
|
+
minSize = 0
|
|
776
|
+
} = panelConstraints;
|
|
665
777
|
|
|
666
778
|
//DEBUG.push(`edge case check 1: ${index}`);
|
|
667
779
|
//DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
|
|
668
|
-
if (
|
|
780
|
+
if (collapsible) {
|
|
669
781
|
const prevSize = prevLayout[index];
|
|
670
|
-
assert(prevSize != null);
|
|
671
|
-
const panelConstraints = panelConstraintsArray[index];
|
|
672
|
-
assert(panelConstraints);
|
|
673
|
-
const {
|
|
674
|
-
collapsedSize = 0,
|
|
675
|
-
minSize = 0
|
|
676
|
-
} = panelConstraints;
|
|
782
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
677
783
|
if (fuzzyNumbersEqual(prevSize, collapsedSize)) {
|
|
678
784
|
const localDelta = minSize - prevSize;
|
|
679
785
|
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
@@ -690,22 +796,18 @@ function adjustLayoutByDelta({
|
|
|
690
796
|
// Check if we should collapse a panel at its minimum size
|
|
691
797
|
const index = delta < 0 ? firstPivotIndex : secondPivotIndex;
|
|
692
798
|
const panelConstraints = panelConstraintsArray[index];
|
|
693
|
-
assert(panelConstraints);
|
|
799
|
+
assert(panelConstraints, `No panel constraints found for index ${index}`);
|
|
694
800
|
const {
|
|
695
|
-
|
|
801
|
+
collapsedSize = 0,
|
|
802
|
+
collapsible,
|
|
803
|
+
minSize = 0
|
|
696
804
|
} = panelConstraints;
|
|
697
805
|
|
|
698
806
|
//DEBUG.push(`edge case check 2: ${index}`);
|
|
699
807
|
//DEBUG.push(` -> collapsible? ${collapsible}`);
|
|
700
808
|
if (collapsible) {
|
|
701
809
|
const prevSize = prevLayout[index];
|
|
702
|
-
assert(prevSize != null);
|
|
703
|
-
const panelConstraints = panelConstraintsArray[index];
|
|
704
|
-
assert(panelConstraints);
|
|
705
|
-
const {
|
|
706
|
-
collapsedSize = 0,
|
|
707
|
-
minSize = 0
|
|
708
|
-
} = panelConstraints;
|
|
810
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
709
811
|
if (fuzzyNumbersEqual(prevSize, minSize)) {
|
|
710
812
|
const localDelta = prevSize - collapsedSize;
|
|
711
813
|
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
@@ -735,7 +837,7 @@ function adjustLayoutByDelta({
|
|
|
735
837
|
//DEBUG.push("pre calc...");
|
|
736
838
|
while (true) {
|
|
737
839
|
const prevSize = prevLayout[index];
|
|
738
|
-
assert(prevSize != null);
|
|
840
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
739
841
|
const maxSafeSize = resizePanel({
|
|
740
842
|
panelConstraints: panelConstraintsArray,
|
|
741
843
|
panelIndex: index,
|
|
@@ -766,7 +868,7 @@ function adjustLayoutByDelta({
|
|
|
766
868
|
while (index >= 0 && index < panelConstraintsArray.length) {
|
|
767
869
|
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
768
870
|
const prevSize = prevLayout[index];
|
|
769
|
-
assert(prevSize != null);
|
|
871
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
770
872
|
const unsafeSize = prevSize - deltaRemaining;
|
|
771
873
|
const safeSize = resizePanel({
|
|
772
874
|
panelConstraints: panelConstraintsArray,
|
|
@@ -803,7 +905,7 @@ function adjustLayoutByDelta({
|
|
|
803
905
|
// Now distribute the applied delta to the panels in the other direction
|
|
804
906
|
const pivotIndex = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
805
907
|
const prevSize = prevLayout[pivotIndex];
|
|
806
|
-
assert(prevSize != null);
|
|
908
|
+
assert(prevSize != null, `Previous layout not found for panel index ${pivotIndex}`);
|
|
807
909
|
const unsafeSize = prevSize + deltaApplied;
|
|
808
910
|
const safeSize = resizePanel({
|
|
809
911
|
panelConstraints: panelConstraintsArray,
|
|
@@ -821,7 +923,7 @@ function adjustLayoutByDelta({
|
|
|
821
923
|
let index = pivotIndex;
|
|
822
924
|
while (index >= 0 && index < panelConstraintsArray.length) {
|
|
823
925
|
const prevSize = nextLayout[index];
|
|
824
|
-
assert(prevSize != null);
|
|
926
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
825
927
|
const unsafeSize = prevSize + deltaRemaining;
|
|
826
928
|
const safeSize = resizePanel({
|
|
827
929
|
panelConstraints: panelConstraintsArray,
|
|
@@ -867,7 +969,7 @@ function calculateAriaValues({
|
|
|
867
969
|
let totalMinSize = 0;
|
|
868
970
|
let totalMaxSize = 0;
|
|
869
971
|
const firstIndex = pivotIndices[0];
|
|
870
|
-
assert(firstIndex != null);
|
|
972
|
+
assert(firstIndex != null, "No pivot index found");
|
|
871
973
|
|
|
872
974
|
// A panel's effective min/max sizes also need to account for other panel's sizes.
|
|
873
975
|
panelsArray.forEach((panelData, index) => {
|
|
@@ -976,7 +1078,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
976
1078
|
const resizeHandleElement = resizeHandleElements[index];
|
|
977
1079
|
if (resizeHandleElement == null) ; else {
|
|
978
1080
|
const panelData = panelDataArray[index];
|
|
979
|
-
assert(panelData);
|
|
1081
|
+
assert(panelData, `No panel data found for index "${index}"`);
|
|
980
1082
|
resizeHandleElement.setAttribute("aria-controls", panelData.id);
|
|
981
1083
|
resizeHandleElement.setAttribute("aria-valuemax", "" + Math.round(valueMax));
|
|
982
1084
|
resizeHandleElement.setAttribute("aria-valuemin", "" + Math.round(valueMin));
|
|
@@ -997,17 +1099,17 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
997
1099
|
return;
|
|
998
1100
|
}
|
|
999
1101
|
const eagerValues = eagerValuesRef.current;
|
|
1000
|
-
assert(eagerValues);
|
|
1102
|
+
assert(eagerValues, `Eager values not found`);
|
|
1001
1103
|
const {
|
|
1002
1104
|
panelDataArray
|
|
1003
1105
|
} = eagerValues;
|
|
1004
1106
|
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
1005
1107
|
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
1006
1108
|
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1007
|
-
assert(handles);
|
|
1109
|
+
assert(handles, `No resize handles found for group id "${groupId}"`);
|
|
1008
1110
|
const cleanupFunctions = handles.map(handle => {
|
|
1009
1111
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
1010
|
-
assert(handleId);
|
|
1112
|
+
assert(handleId, `Resize handle element has no handle id attribute`);
|
|
1011
1113
|
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
|
|
1012
1114
|
if (idBefore == null || idAfter == null) {
|
|
1013
1115
|
return () => {};
|
|
@@ -1023,7 +1125,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1023
1125
|
const index = panelDataArray.findIndex(panelData => panelData.id === idBefore);
|
|
1024
1126
|
if (index >= 0) {
|
|
1025
1127
|
const panelData = panelDataArray[index];
|
|
1026
|
-
assert(panelData);
|
|
1128
|
+
assert(panelData, `No panel data found for index ${index}`);
|
|
1027
1129
|
const size = layout[index];
|
|
1028
1130
|
const {
|
|
1029
1131
|
collapsedSize = 0,
|
|
@@ -1082,15 +1184,15 @@ function getResizeEventCursorPosition(direction, event) {
|
|
|
1082
1184
|
function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement) {
|
|
1083
1185
|
const isHorizontal = direction === "horizontal";
|
|
1084
1186
|
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
|
|
1085
|
-
assert(handleElement);
|
|
1187
|
+
assert(handleElement, `No resize handle element found for id "${dragHandleId}"`);
|
|
1086
1188
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
1087
|
-
assert(groupId);
|
|
1189
|
+
assert(groupId, `Resize handle element has no group id attribute`);
|
|
1088
1190
|
let {
|
|
1089
1191
|
initialCursorPosition
|
|
1090
1192
|
} = initialDragState;
|
|
1091
1193
|
const cursorPosition = getResizeEventCursorPosition(direction, event);
|
|
1092
1194
|
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
1093
|
-
assert(groupElement);
|
|
1195
|
+
assert(groupElement, `No group element found for id "${groupId}"`);
|
|
1094
1196
|
const groupRect = groupElement.getBoundingClientRect();
|
|
1095
1197
|
const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
|
|
1096
1198
|
const offsetPixels = cursorPosition - initialCursorPosition;
|
|
@@ -1151,7 +1253,7 @@ function calculateUnsafeDefaultLayout({
|
|
|
1151
1253
|
// Distribute default sizes first
|
|
1152
1254
|
for (let index = 0; index < panelDataArray.length; index++) {
|
|
1153
1255
|
const panelConstraints = panelConstraintsArray[index];
|
|
1154
|
-
assert(panelConstraints);
|
|
1256
|
+
assert(panelConstraints, `Panel constraints not found for index ${index}`);
|
|
1155
1257
|
const {
|
|
1156
1258
|
defaultSize
|
|
1157
1259
|
} = panelConstraints;
|
|
@@ -1165,7 +1267,7 @@ function calculateUnsafeDefaultLayout({
|
|
|
1165
1267
|
// Remaining size should be distributed evenly between panels without default sizes
|
|
1166
1268
|
for (let index = 0; index < panelDataArray.length; index++) {
|
|
1167
1269
|
const panelConstraints = panelConstraintsArray[index];
|
|
1168
|
-
assert(panelConstraints);
|
|
1270
|
+
assert(panelConstraints, `Panel constraints not found for index ${index}`);
|
|
1169
1271
|
const {
|
|
1170
1272
|
defaultSize
|
|
1171
1273
|
} = panelConstraints;
|
|
@@ -1185,7 +1287,7 @@ function calculateUnsafeDefaultLayout({
|
|
|
1185
1287
|
function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
1186
1288
|
layout.forEach((size, index) => {
|
|
1187
1289
|
const panelData = panelsArray[index];
|
|
1188
|
-
assert(panelData);
|
|
1290
|
+
assert(panelData, `Panel data not found for index ${index}`);
|
|
1189
1291
|
const {
|
|
1190
1292
|
callbacks,
|
|
1191
1293
|
constraints,
|
|
@@ -1375,7 +1477,7 @@ function validatePanelGroupLayout({
|
|
|
1375
1477
|
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1376
1478
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1377
1479
|
const unsafeSize = nextLayout[index];
|
|
1378
|
-
assert(unsafeSize != null);
|
|
1480
|
+
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
1379
1481
|
const safeSize = 100 / nextLayoutTotalSize * unsafeSize;
|
|
1380
1482
|
nextLayout[index] = safeSize;
|
|
1381
1483
|
}
|
|
@@ -1385,7 +1487,7 @@ function validatePanelGroupLayout({
|
|
|
1385
1487
|
// First pass: Validate the proposed layout given each panel's constraints
|
|
1386
1488
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1387
1489
|
const unsafeSize = nextLayout[index];
|
|
1388
|
-
assert(unsafeSize != null);
|
|
1490
|
+
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
1389
1491
|
const safeSize = resizePanel({
|
|
1390
1492
|
panelConstraints,
|
|
1391
1493
|
panelIndex: index,
|
|
@@ -1402,7 +1504,7 @@ function validatePanelGroupLayout({
|
|
|
1402
1504
|
if (!fuzzyNumbersEqual(remainingSize, 0)) {
|
|
1403
1505
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1404
1506
|
const prevSize = nextLayout[index];
|
|
1405
|
-
assert(prevSize != null);
|
|
1507
|
+
assert(prevSize != null, `No layout data found for index ${index}`);
|
|
1406
1508
|
const unsafeSize = prevSize + remainingSize;
|
|
1407
1509
|
const safeSize = resizePanel({
|
|
1408
1510
|
panelConstraints,
|
|
@@ -1568,7 +1670,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1568
1670
|
panelSize,
|
|
1569
1671
|
pivotIndices
|
|
1570
1672
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1571
|
-
assert(panelSize != null);
|
|
1673
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1572
1674
|
if (panelSize !== collapsedSize) {
|
|
1573
1675
|
// Store size before collapse;
|
|
1574
1676
|
// This is the size that gets restored if the expand() API is used.
|
|
@@ -1645,7 +1747,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1645
1747
|
const {
|
|
1646
1748
|
panelSize
|
|
1647
1749
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
1648
|
-
assert(panelSize != null);
|
|
1750
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1649
1751
|
return panelSize;
|
|
1650
1752
|
}, []);
|
|
1651
1753
|
|
|
@@ -1689,7 +1791,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1689
1791
|
collapsible,
|
|
1690
1792
|
panelSize
|
|
1691
1793
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
1692
|
-
assert(panelSize != null);
|
|
1794
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1693
1795
|
return !collapsible || panelSize > collapsedSize;
|
|
1694
1796
|
}, []);
|
|
1695
1797
|
const registerPanel = useCallback(panelData => {
|
|
@@ -1856,7 +1958,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1856
1958
|
panelSize,
|
|
1857
1959
|
pivotIndices
|
|
1858
1960
|
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
1859
|
-
assert(panelSize != null);
|
|
1961
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1860
1962
|
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
1861
1963
|
const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
|
|
1862
1964
|
const nextLayout = adjustLayoutByDelta({
|
|
@@ -1893,7 +1995,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1893
1995
|
const {
|
|
1894
1996
|
panelSize: prevPanelSize
|
|
1895
1997
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
1896
|
-
|
|
1998
|
+
if (prevPanelSize == null) {
|
|
1999
|
+
// It's possible that the panels in this group have changed since the last render
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
1897
2002
|
if (prevCollapsible && nextCollapsible && prevPanelSize === prevCollapsedSize) {
|
|
1898
2003
|
if (prevCollapsedSize !== nextCollapsedSize) {
|
|
1899
2004
|
resizePanel(panelData, nextCollapsedSize);
|
|
@@ -1915,7 +2020,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1915
2020
|
return;
|
|
1916
2021
|
}
|
|
1917
2022
|
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElementRef.current);
|
|
1918
|
-
assert(handleElement);
|
|
2023
|
+
assert(handleElement, `Drag handle element not found for id "${dragHandleId}"`);
|
|
1919
2024
|
const initialCursorPosition = getResizeEventCursorPosition(direction, event);
|
|
1920
2025
|
setDragState({
|
|
1921
2026
|
dragHandleId,
|
|
@@ -2044,10 +2149,10 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
2044
2149
|
{
|
|
2045
2150
|
event.preventDefault();
|
|
2046
2151
|
const groupId = handleElement.getAttribute("data-panel-group-id");
|
|
2047
|
-
assert(groupId);
|
|
2152
|
+
assert(groupId, `No group element found for id "${groupId}"`);
|
|
2048
2153
|
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
2049
2154
|
const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
|
|
2050
|
-
assert(index !== null);
|
|
2155
|
+
assert(index !== null, `No resize element found for id "${handleId}"`);
|
|
2051
2156
|
const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
|
|
2052
2157
|
const nextHandle = handles[nextIndex];
|
|
2053
2158
|
nextHandle.focus();
|
|
@@ -2119,7 +2224,7 @@ function PanelResizeHandle({
|
|
|
2119
2224
|
return;
|
|
2120
2225
|
}
|
|
2121
2226
|
const element = elementRef.current;
|
|
2122
|
-
assert(element);
|
|
2227
|
+
assert(element, "Element ref not attached");
|
|
2123
2228
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2124
2229
|
if (isActive) {
|
|
2125
2230
|
switch (action) {
|