react-resizable-panels 0.0.56 → 0.0.58
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 +11 -0
- package/dist/declarations/src/Panel.d.ts +7 -3
- package/dist/declarations/src/PanelGroup.d.ts +3 -1
- package/dist/declarations/src/PanelResizeHandle.d.ts +3 -1
- package/dist/declarations/src/types.d.ts +3 -0
- package/dist/react-resizable-panels.browser.cjs.js +186 -87
- package/dist/react-resizable-panels.browser.development.cjs.js +186 -87
- package/dist/react-resizable-panels.browser.development.esm.js +186 -87
- package/dist/react-resizable-panels.browser.esm.js +186 -87
- package/dist/react-resizable-panels.cjs.js +186 -87
- package/dist/react-resizable-panels.cjs.js.map +1 -1
- package/dist/react-resizable-panels.development.cjs.js +186 -87
- package/dist/react-resizable-panels.development.esm.js +186 -87
- package/dist/react-resizable-panels.development.node.cjs.js +175 -82
- package/dist/react-resizable-panels.development.node.esm.js +175 -82
- package/dist/react-resizable-panels.esm.js +186 -87
- package/dist/react-resizable-panels.esm.js.map +1 -1
- package/dist/react-resizable-panels.node.cjs.js +175 -82
- package/dist/react-resizable-panels.node.esm.js +175 -82
- package/package.json +3 -1
- package/src/Panel.ts +9 -3
- package/src/PanelGroup.ts +11 -5
- package/src/PanelResizeHandle.ts +17 -13
- package/src/types.ts +4 -0
- package/src/utils/adjustLayoutByDelta.test.ts +238 -8
- package/src/utils/adjustLayoutByDelta.ts +122 -72
- package/src/utils/computePercentagePanelConstraints.test.ts +27 -0
- package/src/utils/convertPixelConstraintsToPercentages.test.ts +47 -0
- package/src/utils/convertPixelConstraintsToPercentages.ts +17 -0
- package/src/utils/dom/getPanelGroupElement.ts +3 -1
- package/src/utils/resizePanel.test.ts +105 -0
- package/src/utils/resizePanel.ts +26 -1
- package/src/utils/validatePanelGroupLayout.test.ts +36 -6
|
@@ -61,7 +61,7 @@ function useUniqueId(idFromParams = null) {
|
|
|
61
61
|
if (idRef.current === null) {
|
|
62
62
|
idRef.current = "" + counter++;
|
|
63
63
|
}
|
|
64
|
-
return idFromParams
|
|
64
|
+
return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function PanelWithForwardedRef({
|
|
@@ -70,6 +70,7 @@ function PanelWithForwardedRef({
|
|
|
70
70
|
collapsedSizePercentage,
|
|
71
71
|
collapsedSizePixels,
|
|
72
72
|
collapsible,
|
|
73
|
+
dataAttributes,
|
|
73
74
|
defaultSizePercentage,
|
|
74
75
|
defaultSizePixels,
|
|
75
76
|
forwardedRef,
|
|
@@ -183,11 +184,12 @@ function PanelWithForwardedRef({
|
|
|
183
184
|
...style,
|
|
184
185
|
...styleFromProps
|
|
185
186
|
},
|
|
187
|
+
...dataAttributes,
|
|
186
188
|
// CSS selectors
|
|
187
189
|
"data-panel": "",
|
|
190
|
+
"data-panel-id": panelId,
|
|
188
191
|
// e2e test attributes
|
|
189
192
|
"data-panel-collapsible": undefined,
|
|
190
|
-
"data-panel-id": undefined,
|
|
191
193
|
"data-panel-size": undefined
|
|
192
194
|
});
|
|
193
195
|
}
|
|
@@ -215,6 +217,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
|
|
|
215
217
|
minSizePercentage = 0,
|
|
216
218
|
minSizePixels
|
|
217
219
|
} = panelConstraints;
|
|
220
|
+
const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
|
|
221
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
222
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
223
|
+
return {
|
|
224
|
+
collapsedSizePercentage: 0,
|
|
225
|
+
defaultSizePercentage,
|
|
226
|
+
maxSizePercentage: 0,
|
|
227
|
+
minSizePercentage: 0
|
|
228
|
+
};
|
|
229
|
+
}
|
|
218
230
|
if (collapsedSizePixels != null) {
|
|
219
231
|
collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
|
|
220
232
|
}
|
|
@@ -289,6 +301,16 @@ function resizePanel({
|
|
|
289
301
|
panelIndex,
|
|
290
302
|
size
|
|
291
303
|
}) {
|
|
304
|
+
const hasPixelConstraints = panelConstraints.some(({
|
|
305
|
+
collapsedSizePixels,
|
|
306
|
+
defaultSizePixels,
|
|
307
|
+
minSizePixels,
|
|
308
|
+
maxSizePixels
|
|
309
|
+
}) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
|
|
310
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
311
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
312
|
+
return 0;
|
|
313
|
+
}
|
|
292
314
|
let {
|
|
293
315
|
collapsible
|
|
294
316
|
} = panelConstraints[panelIndex];
|
|
@@ -300,7 +322,13 @@ function resizePanel({
|
|
|
300
322
|
if (minSizePercentage != null) {
|
|
301
323
|
if (fuzzyCompareNumbers(size, minSizePercentage) < 0) {
|
|
302
324
|
if (collapsible) {
|
|
303
|
-
|
|
325
|
+
// Collapsible panels should snap closed or open only once they cross the halfway point between collapsed and min size.
|
|
326
|
+
const halfwayPoint = (collapsedSizePercentage + minSizePercentage) / 2;
|
|
327
|
+
if (fuzzyCompareNumbers(size, halfwayPoint) < 0) {
|
|
328
|
+
size = collapsedSizePercentage;
|
|
329
|
+
} else {
|
|
330
|
+
size = minSizePercentage;
|
|
331
|
+
}
|
|
304
332
|
} else {
|
|
305
333
|
size = minSizePercentage;
|
|
306
334
|
}
|
|
@@ -327,61 +355,123 @@ function adjustLayoutByDelta({
|
|
|
327
355
|
const nextLayout = [...prevLayout];
|
|
328
356
|
let deltaApplied = 0;
|
|
329
357
|
|
|
358
|
+
//const DEBUG = [];
|
|
359
|
+
//DEBUG.push(`adjustLayoutByDelta() ${prevLayout.join(", ")}`);
|
|
360
|
+
//DEBUG.push(` delta: ${delta}`);
|
|
361
|
+
//DEBUG.push(` pivotIndices: ${pivotIndices.join(", ")}`);
|
|
362
|
+
//DEBUG.push(` trigger: ${trigger}`);
|
|
363
|
+
//DEBUG.push("");
|
|
364
|
+
|
|
330
365
|
// A resizing panel affects the panels before or after it.
|
|
331
366
|
//
|
|
332
|
-
// A negative delta means the panel immediately after the
|
|
367
|
+
// A negative delta means the panel(s) immediately after the resize handle should grow/expand by decreasing its offset.
|
|
333
368
|
// Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
|
|
334
369
|
//
|
|
335
|
-
// A positive delta means the panel immediately before the
|
|
336
|
-
// This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the
|
|
370
|
+
// A positive delta means the panel(s) immediately before the resize handle should "expand".
|
|
371
|
+
// This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resize handle.
|
|
337
372
|
|
|
338
|
-
// First, check the panel we're pivoting around;
|
|
339
|
-
// We should only expand or contract by as much as its constraints allow
|
|
340
373
|
{
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
if (
|
|
357
|
-
|
|
374
|
+
// If this is a resize triggered by a keyboard event, our logic for expanding/collapsing is different.
|
|
375
|
+
// We no longer check the halfway threshold because this may prevent the panel from expanding at all.
|
|
376
|
+
if (trigger === "keyboard") {
|
|
377
|
+
{
|
|
378
|
+
// Check if we should expand a collapsed panel
|
|
379
|
+
const index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
380
|
+
const constraints = panelConstraints[index];
|
|
381
|
+
//DEBUG.push(`edge case check 1: ${index}`);
|
|
382
|
+
//DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
|
|
383
|
+
if (constraints.collapsible) {
|
|
384
|
+
const prevSize = prevLayout[index];
|
|
385
|
+
const {
|
|
386
|
+
collapsedSizePercentage,
|
|
387
|
+
minSizePercentage
|
|
388
|
+
} = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
|
|
389
|
+
if (fuzzyNumbersEqual(prevSize, collapsedSizePercentage)) {
|
|
390
|
+
const localDelta = minSizePercentage - prevSize;
|
|
391
|
+
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
392
|
+
|
|
393
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
|
|
394
|
+
delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
395
|
+
//DEBUG.push(` -> delta: ${delta}`);
|
|
396
|
+
}
|
|
358
397
|
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
{
|
|
402
|
+
// Check if we should collapse a panel at its minimum size
|
|
403
|
+
const index = delta < 0 ? pivotIndices[0] : pivotIndices[1];
|
|
404
|
+
const constraints = panelConstraints[index];
|
|
405
|
+
//DEBUG.push(`edge case check 2: ${index}`);
|
|
406
|
+
//DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
|
|
407
|
+
if (constraints.collapsible) {
|
|
408
|
+
const prevSize = prevLayout[index];
|
|
409
|
+
const {
|
|
410
|
+
collapsedSizePercentage,
|
|
411
|
+
minSizePercentage
|
|
412
|
+
} = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
|
|
413
|
+
if (fuzzyNumbersEqual(prevSize, minSizePercentage)) {
|
|
414
|
+
const localDelta = prevSize - collapsedSizePercentage;
|
|
415
|
+
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
416
|
+
|
|
417
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
|
|
418
|
+
delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
419
|
+
//DEBUG.push(` -> delta: ${delta}`);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
359
423
|
}
|
|
360
424
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
425
|
+
//DEBUG.push("");
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
{
|
|
429
|
+
// Pre-calculate max available delta in the opposite direction of our pivot.
|
|
430
|
+
// This will be the maximum amount we're allowed to expand/contract the panels in the primary direction.
|
|
431
|
+
// If this amount is less than the requested delta, adjust the requested delta.
|
|
432
|
+
// If this amount is greater than the requested delta, that's useful information too–
|
|
433
|
+
// as an expanding panel might change from collapsed to min size.
|
|
434
|
+
|
|
435
|
+
const increment = delta < 0 ? 1 : -1;
|
|
436
|
+
let index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
437
|
+
let maxAvailableDelta = 0;
|
|
438
|
+
|
|
439
|
+
//DEBUG.push("pre calc...");
|
|
440
|
+
while (true) {
|
|
441
|
+
const prevSize = prevLayout[index];
|
|
442
|
+
const maxSafeSize = resizePanel({
|
|
443
|
+
groupSizePixels,
|
|
444
|
+
panelConstraints,
|
|
445
|
+
panelIndex: index,
|
|
446
|
+
size: 100
|
|
447
|
+
});
|
|
448
|
+
const delta = maxSafeSize - prevSize;
|
|
449
|
+
//DEBUG.push(` ${index}: ${prevSize} -> ${maxSafeSize}`);
|
|
450
|
+
|
|
451
|
+
maxAvailableDelta += delta;
|
|
452
|
+
index += increment;
|
|
453
|
+
if (index < 0 || index >= panelConstraints.length) {
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
372
456
|
}
|
|
457
|
+
|
|
458
|
+
//DEBUG.push(` -> max available delta: ${maxAvailableDelta}`);
|
|
459
|
+
const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
|
|
460
|
+
delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
|
|
461
|
+
//DEBUG.push(` -> adjusted delta: ${delta}`);
|
|
462
|
+
//DEBUG.push("");
|
|
373
463
|
}
|
|
374
464
|
|
|
375
|
-
// Delta added to a panel needs to be subtracted from other panels
|
|
376
|
-
// within the constraints that those panels allow
|
|
377
465
|
{
|
|
466
|
+
// Delta added to a panel needs to be subtracted from other panels (within the constraints that those panels allow).
|
|
467
|
+
|
|
378
468
|
const pivotIndex = delta < 0 ? pivotIndices[0] : pivotIndices[1];
|
|
379
469
|
let index = pivotIndex;
|
|
380
470
|
while (index >= 0 && index < panelConstraints.length) {
|
|
381
471
|
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
382
472
|
const prevSize = prevLayout[index];
|
|
383
473
|
const unsafeSize = prevSize - deltaRemaining;
|
|
384
|
-
|
|
474
|
+
const safeSize = resizePanel({
|
|
385
475
|
groupSizePixels,
|
|
386
476
|
panelConstraints,
|
|
387
477
|
panelIndex: index,
|
|
@@ -403,13 +493,18 @@ function adjustLayoutByDelta({
|
|
|
403
493
|
}
|
|
404
494
|
}
|
|
405
495
|
}
|
|
496
|
+
//DEBUG.push(`after 1: ${nextLayout.join(", ")}`);
|
|
497
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
498
|
+
//DEBUG.push("");
|
|
406
499
|
|
|
407
500
|
// If we were unable to resize any of the panels panels, return the previous state.
|
|
408
501
|
// This will essentially bailout and ignore e.g. drags past a panel's boundaries
|
|
409
502
|
if (fuzzyNumbersEqual(deltaApplied, 0)) {
|
|
503
|
+
//console.log(DEBUG.join("\n"));
|
|
410
504
|
return prevLayout;
|
|
411
505
|
}
|
|
412
506
|
{
|
|
507
|
+
// Now distribute the applied delta to the panels in the other direction
|
|
413
508
|
const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
414
509
|
const unsafeSize = prevLayout[pivotIndex] + deltaApplied;
|
|
415
510
|
const safeSize = resizePanel({
|
|
@@ -449,29 +544,21 @@ function adjustLayoutByDelta({
|
|
|
449
544
|
index++;
|
|
450
545
|
}
|
|
451
546
|
}
|
|
452
|
-
|
|
453
|
-
// If we can't redistribute, this layout is invalid;
|
|
454
|
-
// There may be an incremental layout that is valid though
|
|
455
|
-
if (!fuzzyNumbersEqual(deltaRemaining, 0)) {
|
|
456
|
-
try {
|
|
457
|
-
return adjustLayoutByDelta({
|
|
458
|
-
delta: delta < 0 ? delta + 1 : delta - 1,
|
|
459
|
-
groupSizePixels,
|
|
460
|
-
layout: prevLayout,
|
|
461
|
-
panelConstraints,
|
|
462
|
-
pivotIndices,
|
|
463
|
-
trigger
|
|
464
|
-
});
|
|
465
|
-
} catch (error) {
|
|
466
|
-
if (error instanceof RangeError) {
|
|
467
|
-
console.error(`Could not apply delta ${delta} to layout`);
|
|
468
|
-
return prevLayout;
|
|
469
|
-
}
|
|
470
|
-
} finally {
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
547
|
}
|
|
474
548
|
}
|
|
549
|
+
//DEBUG.push(`after 2: ${nextLayout.join(", ")}`);
|
|
550
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
551
|
+
//DEBUG.push("");
|
|
552
|
+
|
|
553
|
+
const totalSize = nextLayout.reduce((total, size) => size + total, 0);
|
|
554
|
+
deltaApplied = 100 - totalSize;
|
|
555
|
+
//DEBUG.push(`total size: ${totalSize}`);
|
|
556
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
557
|
+
//console.log(DEBUG.join("\n"));
|
|
558
|
+
|
|
559
|
+
if (!fuzzyNumbersEqual(totalSize, 100)) {
|
|
560
|
+
return prevLayout;
|
|
561
|
+
}
|
|
475
562
|
return nextLayout;
|
|
476
563
|
}
|
|
477
564
|
|
|
@@ -507,6 +594,7 @@ function calculateAriaValues({
|
|
|
507
594
|
|
|
508
595
|
// A panel's effective min/max sizes also need to account for other panel's sizes.
|
|
509
596
|
panelsArray.forEach((panelData, index) => {
|
|
597
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
510
598
|
const {
|
|
511
599
|
constraints
|
|
512
600
|
} = panelData;
|
|
@@ -516,14 +604,14 @@ function calculateAriaValues({
|
|
|
516
604
|
minSizePercentage,
|
|
517
605
|
minSizePixels
|
|
518
606
|
} = constraints;
|
|
519
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
607
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
520
608
|
sizePercentage: minSizePercentage,
|
|
521
609
|
sizePixels: minSizePixels
|
|
522
|
-
}, groupSizePixels)
|
|
523
|
-
const maxSize = getPercentageSizeFromMixedSizes({
|
|
610
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
611
|
+
const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
524
612
|
sizePercentage: maxSizePercentage,
|
|
525
613
|
sizePixels: maxSizePixels
|
|
526
|
-
}, groupSizePixels)
|
|
614
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
|
|
527
615
|
if (index === pivotIndices[0]) {
|
|
528
616
|
currentMinSize = minSize;
|
|
529
617
|
currentMaxSize = maxSize;
|
|
@@ -549,7 +637,7 @@ function getResizeHandleElementsForGroup(groupId) {
|
|
|
549
637
|
function getResizeHandleElementIndex(groupId, id) {
|
|
550
638
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
551
639
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
552
|
-
return index
|
|
640
|
+
return index !== null && index !== void 0 ? index : null;
|
|
553
641
|
}
|
|
554
642
|
|
|
555
643
|
function determinePivotIndices(groupId, dragHandleId) {
|
|
@@ -558,7 +646,7 @@ function determinePivotIndices(groupId, dragHandleId) {
|
|
|
558
646
|
}
|
|
559
647
|
|
|
560
648
|
function getPanelGroupElement(id) {
|
|
561
|
-
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
649
|
+
const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
562
650
|
if (element) {
|
|
563
651
|
return element;
|
|
564
652
|
}
|
|
@@ -610,11 +698,12 @@ function getResizeHandleElement(id) {
|
|
|
610
698
|
}
|
|
611
699
|
|
|
612
700
|
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
701
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
613
702
|
const handle = getResizeHandleElement(handleId);
|
|
614
703
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
615
704
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
616
|
-
const idBefore = panelsArray[index]
|
|
617
|
-
const idAfter = panelsArray[index + 1]
|
|
705
|
+
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;
|
|
706
|
+
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
618
707
|
return [idBefore, idAfter];
|
|
619
708
|
}
|
|
620
709
|
|
|
@@ -692,11 +781,12 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
692
781
|
const panelData = panelDataArray[index];
|
|
693
782
|
const size = layout[index];
|
|
694
783
|
if (size != null) {
|
|
784
|
+
var _getPercentageSizeFro;
|
|
695
785
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
696
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
786
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
697
787
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
698
788
|
sizePixels: panelData.constraints.minSizePixels
|
|
699
|
-
}, groupSizePixels)
|
|
789
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
700
790
|
let delta = 0;
|
|
701
791
|
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
702
792
|
delta = direction === "horizontal" ? width : height;
|
|
@@ -901,10 +991,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
|
|
|
901
991
|
onResize(mixedSizes, lastNotifiedMixedSizes);
|
|
902
992
|
}
|
|
903
993
|
if (collapsible && (onCollapse || onExpand)) {
|
|
904
|
-
|
|
994
|
+
var _getPercentageSizeFro;
|
|
995
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
905
996
|
sizePercentage: constraints.collapsedSizePercentage,
|
|
906
997
|
sizePixels: constraints.collapsedSizePixels
|
|
907
|
-
}, groupSizePixels)
|
|
998
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
908
999
|
const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
|
|
909
1000
|
if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
|
|
910
1001
|
onExpand();
|
|
@@ -1070,8 +1161,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
|
1070
1161
|
function loadPanelLayout(autoSaveId, panels, storage) {
|
|
1071
1162
|
const state = loadSerializedPanelGroupState(autoSaveId, storage);
|
|
1072
1163
|
if (state) {
|
|
1164
|
+
var _state$key;
|
|
1073
1165
|
const key = getSerializationKey(panels);
|
|
1074
|
-
return state[key]
|
|
1166
|
+
return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
|
|
1075
1167
|
}
|
|
1076
1168
|
return null;
|
|
1077
1169
|
}
|
|
@@ -1163,6 +1255,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1163
1255
|
autoSaveId,
|
|
1164
1256
|
children,
|
|
1165
1257
|
className: classNameFromProps = "",
|
|
1258
|
+
dataAttributes,
|
|
1166
1259
|
direction,
|
|
1167
1260
|
forwardedRef,
|
|
1168
1261
|
id: idFromProps,
|
|
@@ -1287,6 +1380,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1287
1380
|
unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
|
|
1288
1381
|
}
|
|
1289
1382
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1383
|
+
if (groupSizePixels <= 0) {
|
|
1384
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1290
1387
|
if (unsafeLayout == null) {
|
|
1291
1388
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
1292
1389
|
groupSizePixels,
|
|
@@ -1530,7 +1627,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1530
1627
|
} = committedValuesRef.current;
|
|
1531
1628
|
const {
|
|
1532
1629
|
initialLayout
|
|
1533
|
-
} = dragState
|
|
1630
|
+
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1534
1631
|
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1535
1632
|
let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
|
|
1536
1633
|
percentage: keyboardResizeByPercentage,
|
|
@@ -1550,7 +1647,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1550
1647
|
const nextLayout = adjustLayoutByDelta({
|
|
1551
1648
|
delta,
|
|
1552
1649
|
groupSizePixels,
|
|
1553
|
-
layout: initialLayout
|
|
1650
|
+
layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
|
|
1554
1651
|
panelConstraints,
|
|
1555
1652
|
pivotIndices,
|
|
1556
1653
|
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
@@ -1691,11 +1788,11 @@ function PanelGroupWithForwardedRef({
|
|
|
1691
1788
|
...style,
|
|
1692
1789
|
...styleFromProps
|
|
1693
1790
|
},
|
|
1791
|
+
...dataAttributes,
|
|
1694
1792
|
// CSS selectors
|
|
1695
1793
|
"data-panel-group": "",
|
|
1696
|
-
|
|
1697
|
-
"data-panel-group-
|
|
1698
|
-
"data-panel-group-id": undefined
|
|
1794
|
+
"data-panel-group-direction": direction,
|
|
1795
|
+
"data-panel-group-id": groupId
|
|
1699
1796
|
}));
|
|
1700
1797
|
}
|
|
1701
1798
|
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
@@ -1779,6 +1876,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1779
1876
|
function PanelResizeHandle({
|
|
1780
1877
|
children = null,
|
|
1781
1878
|
className: classNameFromProps = "",
|
|
1879
|
+
dataAttributes,
|
|
1782
1880
|
disabled = false,
|
|
1783
1881
|
id: idFromProps = null,
|
|
1784
1882
|
onDragging,
|
|
@@ -1807,7 +1905,7 @@ function PanelResizeHandle({
|
|
|
1807
1905
|
stopDragging
|
|
1808
1906
|
} = panelGroupContext;
|
|
1809
1907
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1810
|
-
const isDragging = dragState
|
|
1908
|
+
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
1811
1909
|
const [isFocused, setIsFocused] = useState(false);
|
|
1812
1910
|
const [resizeHandler, setResizeHandler] = useState(null);
|
|
1813
1911
|
const stopDraggingAndBlur = useCallback(() => {
|
|
@@ -1871,13 +1969,6 @@ function PanelResizeHandle({
|
|
|
1871
1969
|
return createElement(Type, {
|
|
1872
1970
|
children,
|
|
1873
1971
|
className: classNameFromProps,
|
|
1874
|
-
// CSS selectors
|
|
1875
|
-
"data-resize-handle": "",
|
|
1876
|
-
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1877
|
-
"data-panel-group-direction": direction,
|
|
1878
|
-
"data-panel-group-id": groupId,
|
|
1879
|
-
"data-panel-resize-handle-enabled": !disabled,
|
|
1880
|
-
"data-panel-resize-handle-id": resizeHandleId,
|
|
1881
1972
|
onBlur: () => setIsFocused(false),
|
|
1882
1973
|
onFocus: () => setIsFocused(true),
|
|
1883
1974
|
onMouseDown: event => {
|
|
@@ -1907,7 +1998,15 @@ function PanelResizeHandle({
|
|
|
1907
1998
|
...style,
|
|
1908
1999
|
...styleFromProps
|
|
1909
2000
|
},
|
|
1910
|
-
tabIndex: 0
|
|
2001
|
+
tabIndex: 0,
|
|
2002
|
+
...dataAttributes,
|
|
2003
|
+
// CSS selectors
|
|
2004
|
+
"data-panel-group-direction": direction,
|
|
2005
|
+
"data-panel-group-id": groupId,
|
|
2006
|
+
"data-resize-handle": "",
|
|
2007
|
+
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
2008
|
+
"data-panel-resize-handle-enabled": !disabled,
|
|
2009
|
+
"data-panel-resize-handle-id": resizeHandleId
|
|
1911
2010
|
});
|
|
1912
2011
|
}
|
|
1913
2012
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|