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
|
@@ -35,7 +35,7 @@ function useUniqueId(idFromParams = null) {
|
|
|
35
35
|
if (idRef.current === null) {
|
|
36
36
|
idRef.current = "" + counter++;
|
|
37
37
|
}
|
|
38
|
-
return idFromParams
|
|
38
|
+
return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function PanelWithForwardedRef({
|
|
@@ -44,6 +44,7 @@ function PanelWithForwardedRef({
|
|
|
44
44
|
collapsedSizePercentage,
|
|
45
45
|
collapsedSizePixels,
|
|
46
46
|
collapsible,
|
|
47
|
+
dataAttributes,
|
|
47
48
|
defaultSizePercentage,
|
|
48
49
|
defaultSizePixels,
|
|
49
50
|
forwardedRef,
|
|
@@ -163,11 +164,12 @@ function PanelWithForwardedRef({
|
|
|
163
164
|
...style,
|
|
164
165
|
...styleFromProps
|
|
165
166
|
},
|
|
167
|
+
...dataAttributes,
|
|
166
168
|
// CSS selectors
|
|
167
169
|
"data-panel": "",
|
|
170
|
+
"data-panel-id": panelId,
|
|
168
171
|
// e2e test attributes
|
|
169
172
|
"data-panel-collapsible": collapsible || undefined ,
|
|
170
|
-
"data-panel-id": panelId ,
|
|
171
173
|
"data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
|
|
172
174
|
});
|
|
173
175
|
}
|
|
@@ -195,6 +197,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
|
|
|
195
197
|
minSizePercentage = 0,
|
|
196
198
|
minSizePixels
|
|
197
199
|
} = panelConstraints;
|
|
200
|
+
const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
|
|
201
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
202
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
203
|
+
return {
|
|
204
|
+
collapsedSizePercentage: 0,
|
|
205
|
+
defaultSizePercentage,
|
|
206
|
+
maxSizePercentage: 0,
|
|
207
|
+
minSizePercentage: 0
|
|
208
|
+
};
|
|
209
|
+
}
|
|
198
210
|
if (collapsedSizePixels != null) {
|
|
199
211
|
collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
|
|
200
212
|
}
|
|
@@ -269,6 +281,16 @@ function resizePanel({
|
|
|
269
281
|
panelIndex,
|
|
270
282
|
size
|
|
271
283
|
}) {
|
|
284
|
+
const hasPixelConstraints = panelConstraints.some(({
|
|
285
|
+
collapsedSizePixels,
|
|
286
|
+
defaultSizePixels,
|
|
287
|
+
minSizePixels,
|
|
288
|
+
maxSizePixels
|
|
289
|
+
}) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
|
|
290
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
291
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
292
|
+
return 0;
|
|
293
|
+
}
|
|
272
294
|
let {
|
|
273
295
|
collapsible
|
|
274
296
|
} = panelConstraints[panelIndex];
|
|
@@ -280,7 +302,13 @@ function resizePanel({
|
|
|
280
302
|
if (minSizePercentage != null) {
|
|
281
303
|
if (fuzzyCompareNumbers(size, minSizePercentage) < 0) {
|
|
282
304
|
if (collapsible) {
|
|
283
|
-
|
|
305
|
+
// Collapsible panels should snap closed or open only once they cross the halfway point between collapsed and min size.
|
|
306
|
+
const halfwayPoint = (collapsedSizePercentage + minSizePercentage) / 2;
|
|
307
|
+
if (fuzzyCompareNumbers(size, halfwayPoint) < 0) {
|
|
308
|
+
size = collapsedSizePercentage;
|
|
309
|
+
} else {
|
|
310
|
+
size = minSizePercentage;
|
|
311
|
+
}
|
|
284
312
|
} else {
|
|
285
313
|
size = minSizePercentage;
|
|
286
314
|
}
|
|
@@ -307,61 +335,123 @@ function adjustLayoutByDelta({
|
|
|
307
335
|
const nextLayout = [...prevLayout];
|
|
308
336
|
let deltaApplied = 0;
|
|
309
337
|
|
|
338
|
+
//const DEBUG = [];
|
|
339
|
+
//DEBUG.push(`adjustLayoutByDelta() ${prevLayout.join(", ")}`);
|
|
340
|
+
//DEBUG.push(` delta: ${delta}`);
|
|
341
|
+
//DEBUG.push(` pivotIndices: ${pivotIndices.join(", ")}`);
|
|
342
|
+
//DEBUG.push(` trigger: ${trigger}`);
|
|
343
|
+
//DEBUG.push("");
|
|
344
|
+
|
|
310
345
|
// A resizing panel affects the panels before or after it.
|
|
311
346
|
//
|
|
312
|
-
// A negative delta means the panel immediately after the
|
|
347
|
+
// A negative delta means the panel(s) immediately after the resize handle should grow/expand by decreasing its offset.
|
|
313
348
|
// Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
|
|
314
349
|
//
|
|
315
|
-
// A positive delta means the panel immediately before the
|
|
316
|
-
// This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the
|
|
350
|
+
// A positive delta means the panel(s) immediately before the resize handle should "expand".
|
|
351
|
+
// This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resize handle.
|
|
317
352
|
|
|
318
|
-
// First, check the panel we're pivoting around;
|
|
319
|
-
// We should only expand or contract by as much as its constraints allow
|
|
320
353
|
{
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
if (
|
|
337
|
-
|
|
354
|
+
// If this is a resize triggered by a keyboard event, our logic for expanding/collapsing is different.
|
|
355
|
+
// We no longer check the halfway threshold because this may prevent the panel from expanding at all.
|
|
356
|
+
if (trigger === "keyboard") {
|
|
357
|
+
{
|
|
358
|
+
// Check if we should expand a collapsed panel
|
|
359
|
+
const index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
360
|
+
const constraints = panelConstraints[index];
|
|
361
|
+
//DEBUG.push(`edge case check 1: ${index}`);
|
|
362
|
+
//DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
|
|
363
|
+
if (constraints.collapsible) {
|
|
364
|
+
const prevSize = prevLayout[index];
|
|
365
|
+
const {
|
|
366
|
+
collapsedSizePercentage,
|
|
367
|
+
minSizePercentage
|
|
368
|
+
} = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
|
|
369
|
+
if (fuzzyNumbersEqual(prevSize, collapsedSizePercentage)) {
|
|
370
|
+
const localDelta = minSizePercentage - prevSize;
|
|
371
|
+
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
372
|
+
|
|
373
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
|
|
374
|
+
delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
375
|
+
//DEBUG.push(` -> delta: ${delta}`);
|
|
376
|
+
}
|
|
338
377
|
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
{
|
|
382
|
+
// Check if we should collapse a panel at its minimum size
|
|
383
|
+
const index = delta < 0 ? pivotIndices[0] : pivotIndices[1];
|
|
384
|
+
const constraints = panelConstraints[index];
|
|
385
|
+
//DEBUG.push(`edge case check 2: ${index}`);
|
|
386
|
+
//DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
|
|
387
|
+
if (constraints.collapsible) {
|
|
388
|
+
const prevSize = prevLayout[index];
|
|
389
|
+
const {
|
|
390
|
+
collapsedSizePercentage,
|
|
391
|
+
minSizePercentage
|
|
392
|
+
} = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
|
|
393
|
+
if (fuzzyNumbersEqual(prevSize, minSizePercentage)) {
|
|
394
|
+
const localDelta = prevSize - collapsedSizePercentage;
|
|
395
|
+
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
396
|
+
|
|
397
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
|
|
398
|
+
delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
399
|
+
//DEBUG.push(` -> delta: ${delta}`);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
339
403
|
}
|
|
340
404
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
405
|
+
//DEBUG.push("");
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
{
|
|
409
|
+
// Pre-calculate max available delta in the opposite direction of our pivot.
|
|
410
|
+
// This will be the maximum amount we're allowed to expand/contract the panels in the primary direction.
|
|
411
|
+
// If this amount is less than the requested delta, adjust the requested delta.
|
|
412
|
+
// If this amount is greater than the requested delta, that's useful information too–
|
|
413
|
+
// as an expanding panel might change from collapsed to min size.
|
|
414
|
+
|
|
415
|
+
const increment = delta < 0 ? 1 : -1;
|
|
416
|
+
let index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
417
|
+
let maxAvailableDelta = 0;
|
|
418
|
+
|
|
419
|
+
//DEBUG.push("pre calc...");
|
|
420
|
+
while (true) {
|
|
421
|
+
const prevSize = prevLayout[index];
|
|
422
|
+
const maxSafeSize = resizePanel({
|
|
423
|
+
groupSizePixels,
|
|
424
|
+
panelConstraints,
|
|
425
|
+
panelIndex: index,
|
|
426
|
+
size: 100
|
|
427
|
+
});
|
|
428
|
+
const delta = maxSafeSize - prevSize;
|
|
429
|
+
//DEBUG.push(` ${index}: ${prevSize} -> ${maxSafeSize}`);
|
|
430
|
+
|
|
431
|
+
maxAvailableDelta += delta;
|
|
432
|
+
index += increment;
|
|
433
|
+
if (index < 0 || index >= panelConstraints.length) {
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
352
436
|
}
|
|
437
|
+
|
|
438
|
+
//DEBUG.push(` -> max available delta: ${maxAvailableDelta}`);
|
|
439
|
+
const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
|
|
440
|
+
delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
|
|
441
|
+
//DEBUG.push(` -> adjusted delta: ${delta}`);
|
|
442
|
+
//DEBUG.push("");
|
|
353
443
|
}
|
|
354
444
|
|
|
355
|
-
// Delta added to a panel needs to be subtracted from other panels
|
|
356
|
-
// within the constraints that those panels allow
|
|
357
445
|
{
|
|
446
|
+
// Delta added to a panel needs to be subtracted from other panels (within the constraints that those panels allow).
|
|
447
|
+
|
|
358
448
|
const pivotIndex = delta < 0 ? pivotIndices[0] : pivotIndices[1];
|
|
359
449
|
let index = pivotIndex;
|
|
360
450
|
while (index >= 0 && index < panelConstraints.length) {
|
|
361
451
|
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
362
452
|
const prevSize = prevLayout[index];
|
|
363
453
|
const unsafeSize = prevSize - deltaRemaining;
|
|
364
|
-
|
|
454
|
+
const safeSize = resizePanel({
|
|
365
455
|
groupSizePixels,
|
|
366
456
|
panelConstraints,
|
|
367
457
|
panelIndex: index,
|
|
@@ -383,13 +473,18 @@ function adjustLayoutByDelta({
|
|
|
383
473
|
}
|
|
384
474
|
}
|
|
385
475
|
}
|
|
476
|
+
//DEBUG.push(`after 1: ${nextLayout.join(", ")}`);
|
|
477
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
478
|
+
//DEBUG.push("");
|
|
386
479
|
|
|
387
480
|
// If we were unable to resize any of the panels panels, return the previous state.
|
|
388
481
|
// This will essentially bailout and ignore e.g. drags past a panel's boundaries
|
|
389
482
|
if (fuzzyNumbersEqual(deltaApplied, 0)) {
|
|
483
|
+
//console.log(DEBUG.join("\n"));
|
|
390
484
|
return prevLayout;
|
|
391
485
|
}
|
|
392
486
|
{
|
|
487
|
+
// Now distribute the applied delta to the panels in the other direction
|
|
393
488
|
const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
394
489
|
const unsafeSize = prevLayout[pivotIndex] + deltaApplied;
|
|
395
490
|
const safeSize = resizePanel({
|
|
@@ -429,29 +524,21 @@ function adjustLayoutByDelta({
|
|
|
429
524
|
index++;
|
|
430
525
|
}
|
|
431
526
|
}
|
|
432
|
-
|
|
433
|
-
// If we can't redistribute, this layout is invalid;
|
|
434
|
-
// There may be an incremental layout that is valid though
|
|
435
|
-
if (!fuzzyNumbersEqual(deltaRemaining, 0)) {
|
|
436
|
-
try {
|
|
437
|
-
return adjustLayoutByDelta({
|
|
438
|
-
delta: delta < 0 ? delta + 1 : delta - 1,
|
|
439
|
-
groupSizePixels,
|
|
440
|
-
layout: prevLayout,
|
|
441
|
-
panelConstraints,
|
|
442
|
-
pivotIndices,
|
|
443
|
-
trigger
|
|
444
|
-
});
|
|
445
|
-
} catch (error) {
|
|
446
|
-
if (error instanceof RangeError) {
|
|
447
|
-
console.error(`Could not apply delta ${delta} to layout`);
|
|
448
|
-
return prevLayout;
|
|
449
|
-
}
|
|
450
|
-
} finally {
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
527
|
}
|
|
454
528
|
}
|
|
529
|
+
//DEBUG.push(`after 2: ${nextLayout.join(", ")}`);
|
|
530
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
531
|
+
//DEBUG.push("");
|
|
532
|
+
|
|
533
|
+
const totalSize = nextLayout.reduce((total, size) => size + total, 0);
|
|
534
|
+
deltaApplied = 100 - totalSize;
|
|
535
|
+
//DEBUG.push(`total size: ${totalSize}`);
|
|
536
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
537
|
+
//console.log(DEBUG.join("\n"));
|
|
538
|
+
|
|
539
|
+
if (!fuzzyNumbersEqual(totalSize, 100)) {
|
|
540
|
+
return prevLayout;
|
|
541
|
+
}
|
|
455
542
|
return nextLayout;
|
|
456
543
|
}
|
|
457
544
|
|
|
@@ -487,6 +574,7 @@ function calculateAriaValues({
|
|
|
487
574
|
|
|
488
575
|
// A panel's effective min/max sizes also need to account for other panel's sizes.
|
|
489
576
|
panelsArray.forEach((panelData, index) => {
|
|
577
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
490
578
|
const {
|
|
491
579
|
constraints
|
|
492
580
|
} = panelData;
|
|
@@ -496,14 +584,14 @@ function calculateAriaValues({
|
|
|
496
584
|
minSizePercentage,
|
|
497
585
|
minSizePixels
|
|
498
586
|
} = constraints;
|
|
499
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
587
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
500
588
|
sizePercentage: minSizePercentage,
|
|
501
589
|
sizePixels: minSizePixels
|
|
502
|
-
}, groupSizePixels)
|
|
503
|
-
const maxSize = getPercentageSizeFromMixedSizes({
|
|
590
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
591
|
+
const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
504
592
|
sizePercentage: maxSizePercentage,
|
|
505
593
|
sizePixels: maxSizePixels
|
|
506
|
-
}, groupSizePixels)
|
|
594
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
|
|
507
595
|
if (index === pivotIndices[0]) {
|
|
508
596
|
currentMinSize = minSize;
|
|
509
597
|
currentMaxSize = maxSize;
|
|
@@ -529,7 +617,7 @@ function getResizeHandleElementsForGroup(groupId) {
|
|
|
529
617
|
function getResizeHandleElementIndex(groupId, id) {
|
|
530
618
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
531
619
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
532
|
-
return index
|
|
620
|
+
return index !== null && index !== void 0 ? index : null;
|
|
533
621
|
}
|
|
534
622
|
|
|
535
623
|
function determinePivotIndices(groupId, dragHandleId) {
|
|
@@ -538,7 +626,7 @@ function determinePivotIndices(groupId, dragHandleId) {
|
|
|
538
626
|
}
|
|
539
627
|
|
|
540
628
|
function getPanelGroupElement(id) {
|
|
541
|
-
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
629
|
+
const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
542
630
|
if (element) {
|
|
543
631
|
return element;
|
|
544
632
|
}
|
|
@@ -590,11 +678,12 @@ function getResizeHandleElement(id) {
|
|
|
590
678
|
}
|
|
591
679
|
|
|
592
680
|
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
681
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
593
682
|
const handle = getResizeHandleElement(handleId);
|
|
594
683
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
595
684
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
596
|
-
const idBefore = panelsArray[index]
|
|
597
|
-
const idAfter = panelsArray[index + 1]
|
|
685
|
+
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;
|
|
686
|
+
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
598
687
|
return [idBefore, idAfter];
|
|
599
688
|
}
|
|
600
689
|
|
|
@@ -682,11 +771,12 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
682
771
|
const panelData = panelDataArray[index];
|
|
683
772
|
const size = layout[index];
|
|
684
773
|
if (size != null) {
|
|
774
|
+
var _getPercentageSizeFro;
|
|
685
775
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
686
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
776
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
687
777
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
688
778
|
sizePixels: panelData.constraints.minSizePixels
|
|
689
|
-
}, groupSizePixels)
|
|
779
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
690
780
|
let delta = 0;
|
|
691
781
|
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
692
782
|
delta = direction === "horizontal" ? width : height;
|
|
@@ -891,10 +981,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
|
|
|
891
981
|
onResize(mixedSizes, lastNotifiedMixedSizes);
|
|
892
982
|
}
|
|
893
983
|
if (collapsible && (onCollapse || onExpand)) {
|
|
894
|
-
|
|
984
|
+
var _getPercentageSizeFro;
|
|
985
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
895
986
|
sizePercentage: constraints.collapsedSizePercentage,
|
|
896
987
|
sizePixels: constraints.collapsedSizePixels
|
|
897
|
-
}, groupSizePixels)
|
|
988
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
898
989
|
const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
|
|
899
990
|
if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
|
|
900
991
|
onExpand();
|
|
@@ -1060,8 +1151,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
|
1060
1151
|
function loadPanelLayout(autoSaveId, panels, storage) {
|
|
1061
1152
|
const state = loadSerializedPanelGroupState(autoSaveId, storage);
|
|
1062
1153
|
if (state) {
|
|
1154
|
+
var _state$key;
|
|
1063
1155
|
const key = getSerializationKey(panels);
|
|
1064
|
-
return state[key]
|
|
1156
|
+
return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
|
|
1065
1157
|
}
|
|
1066
1158
|
return null;
|
|
1067
1159
|
}
|
|
@@ -1230,6 +1322,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1230
1322
|
autoSaveId,
|
|
1231
1323
|
children,
|
|
1232
1324
|
className: classNameFromProps = "",
|
|
1325
|
+
dataAttributes,
|
|
1233
1326
|
direction,
|
|
1234
1327
|
forwardedRef,
|
|
1235
1328
|
id: idFromProps,
|
|
@@ -1354,6 +1447,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1354
1447
|
unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
|
|
1355
1448
|
}
|
|
1356
1449
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1450
|
+
if (groupSizePixels <= 0) {
|
|
1451
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1357
1454
|
if (unsafeLayout == null) {
|
|
1358
1455
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
1359
1456
|
groupSizePixels,
|
|
@@ -1639,7 +1736,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1639
1736
|
} = committedValuesRef.current;
|
|
1640
1737
|
const {
|
|
1641
1738
|
initialLayout
|
|
1642
|
-
} = dragState
|
|
1739
|
+
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1643
1740
|
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1644
1741
|
let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
|
|
1645
1742
|
percentage: keyboardResizeByPercentage,
|
|
@@ -1659,7 +1756,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1659
1756
|
const nextLayout = adjustLayoutByDelta({
|
|
1660
1757
|
delta,
|
|
1661
1758
|
groupSizePixels,
|
|
1662
|
-
layout: initialLayout
|
|
1759
|
+
layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
|
|
1663
1760
|
panelConstraints,
|
|
1664
1761
|
pivotIndices,
|
|
1665
1762
|
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
@@ -1800,11 +1897,11 @@ function PanelGroupWithForwardedRef({
|
|
|
1800
1897
|
...style,
|
|
1801
1898
|
...styleFromProps
|
|
1802
1899
|
},
|
|
1900
|
+
...dataAttributes,
|
|
1803
1901
|
// CSS selectors
|
|
1804
1902
|
"data-panel-group": "",
|
|
1805
|
-
|
|
1806
|
-
"data-panel-group-
|
|
1807
|
-
"data-panel-group-id": groupId
|
|
1903
|
+
"data-panel-group-direction": direction,
|
|
1904
|
+
"data-panel-group-id": groupId
|
|
1808
1905
|
}));
|
|
1809
1906
|
}
|
|
1810
1907
|
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
@@ -1888,6 +1985,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1888
1985
|
function PanelResizeHandle({
|
|
1889
1986
|
children = null,
|
|
1890
1987
|
className: classNameFromProps = "",
|
|
1988
|
+
dataAttributes,
|
|
1891
1989
|
disabled = false,
|
|
1892
1990
|
id: idFromProps = null,
|
|
1893
1991
|
onDragging,
|
|
@@ -1916,7 +2014,7 @@ function PanelResizeHandle({
|
|
|
1916
2014
|
stopDragging
|
|
1917
2015
|
} = panelGroupContext;
|
|
1918
2016
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1919
|
-
const isDragging = dragState
|
|
2017
|
+
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
1920
2018
|
const [isFocused, setIsFocused] = useState(false);
|
|
1921
2019
|
const [resizeHandler, setResizeHandler] = useState(null);
|
|
1922
2020
|
const stopDraggingAndBlur = useCallback(() => {
|
|
@@ -1980,13 +2078,6 @@ function PanelResizeHandle({
|
|
|
1980
2078
|
return createElement(Type, {
|
|
1981
2079
|
children,
|
|
1982
2080
|
className: classNameFromProps,
|
|
1983
|
-
// CSS selectors
|
|
1984
|
-
"data-resize-handle": "",
|
|
1985
|
-
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1986
|
-
"data-panel-group-direction": direction,
|
|
1987
|
-
"data-panel-group-id": groupId,
|
|
1988
|
-
"data-panel-resize-handle-enabled": !disabled,
|
|
1989
|
-
"data-panel-resize-handle-id": resizeHandleId,
|
|
1990
2081
|
onBlur: () => setIsFocused(false),
|
|
1991
2082
|
onFocus: () => setIsFocused(true),
|
|
1992
2083
|
onMouseDown: event => {
|
|
@@ -2016,7 +2107,15 @@ function PanelResizeHandle({
|
|
|
2016
2107
|
...style,
|
|
2017
2108
|
...styleFromProps
|
|
2018
2109
|
},
|
|
2019
|
-
tabIndex: 0
|
|
2110
|
+
tabIndex: 0,
|
|
2111
|
+
...dataAttributes,
|
|
2112
|
+
// CSS selectors
|
|
2113
|
+
"data-panel-group-direction": direction,
|
|
2114
|
+
"data-panel-group-id": groupId,
|
|
2115
|
+
"data-resize-handle": "",
|
|
2116
|
+
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
2117
|
+
"data-panel-resize-handle-enabled": !disabled,
|
|
2118
|
+
"data-panel-resize-handle-id": resizeHandleId
|
|
2020
2119
|
});
|
|
2021
2120
|
}
|
|
2022
2121
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|