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
|
@@ -57,7 +57,7 @@ function useUniqueId(idFromParams = null) {
|
|
|
57
57
|
if (idRef.current === null) {
|
|
58
58
|
idRef.current = "" + counter++;
|
|
59
59
|
}
|
|
60
|
-
return idFromParams
|
|
60
|
+
return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
function PanelWithForwardedRef({
|
|
@@ -66,6 +66,7 @@ function PanelWithForwardedRef({
|
|
|
66
66
|
collapsedSizePercentage,
|
|
67
67
|
collapsedSizePixels,
|
|
68
68
|
collapsible,
|
|
69
|
+
dataAttributes,
|
|
69
70
|
defaultSizePercentage,
|
|
70
71
|
defaultSizePixels,
|
|
71
72
|
forwardedRef,
|
|
@@ -162,11 +163,12 @@ function PanelWithForwardedRef({
|
|
|
162
163
|
...style,
|
|
163
164
|
...styleFromProps
|
|
164
165
|
},
|
|
166
|
+
...dataAttributes,
|
|
165
167
|
// CSS selectors
|
|
166
168
|
"data-panel": "",
|
|
169
|
+
"data-panel-id": panelId,
|
|
167
170
|
// e2e test attributes
|
|
168
171
|
"data-panel-collapsible": collapsible || undefined ,
|
|
169
|
-
"data-panel-id": panelId ,
|
|
170
172
|
"data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
|
|
171
173
|
});
|
|
172
174
|
}
|
|
@@ -194,6 +196,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
|
|
|
194
196
|
minSizePercentage = 0,
|
|
195
197
|
minSizePixels
|
|
196
198
|
} = panelConstraints;
|
|
199
|
+
const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
|
|
200
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
201
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
202
|
+
return {
|
|
203
|
+
collapsedSizePercentage: 0,
|
|
204
|
+
defaultSizePercentage,
|
|
205
|
+
maxSizePercentage: 0,
|
|
206
|
+
minSizePercentage: 0
|
|
207
|
+
};
|
|
208
|
+
}
|
|
197
209
|
if (collapsedSizePixels != null) {
|
|
198
210
|
collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
|
|
199
211
|
}
|
|
@@ -268,6 +280,16 @@ function resizePanel({
|
|
|
268
280
|
panelIndex,
|
|
269
281
|
size
|
|
270
282
|
}) {
|
|
283
|
+
const hasPixelConstraints = panelConstraints.some(({
|
|
284
|
+
collapsedSizePixels,
|
|
285
|
+
defaultSizePixels,
|
|
286
|
+
minSizePixels,
|
|
287
|
+
maxSizePixels
|
|
288
|
+
}) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
|
|
289
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
290
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
291
|
+
return 0;
|
|
292
|
+
}
|
|
271
293
|
let {
|
|
272
294
|
collapsible
|
|
273
295
|
} = panelConstraints[panelIndex];
|
|
@@ -279,7 +301,13 @@ function resizePanel({
|
|
|
279
301
|
if (minSizePercentage != null) {
|
|
280
302
|
if (fuzzyCompareNumbers(size, minSizePercentage) < 0) {
|
|
281
303
|
if (collapsible) {
|
|
282
|
-
|
|
304
|
+
// Collapsible panels should snap closed or open only once they cross the halfway point between collapsed and min size.
|
|
305
|
+
const halfwayPoint = (collapsedSizePercentage + minSizePercentage) / 2;
|
|
306
|
+
if (fuzzyCompareNumbers(size, halfwayPoint) < 0) {
|
|
307
|
+
size = collapsedSizePercentage;
|
|
308
|
+
} else {
|
|
309
|
+
size = minSizePercentage;
|
|
310
|
+
}
|
|
283
311
|
} else {
|
|
284
312
|
size = minSizePercentage;
|
|
285
313
|
}
|
|
@@ -306,61 +334,123 @@ function adjustLayoutByDelta({
|
|
|
306
334
|
const nextLayout = [...prevLayout];
|
|
307
335
|
let deltaApplied = 0;
|
|
308
336
|
|
|
337
|
+
//const DEBUG = [];
|
|
338
|
+
//DEBUG.push(`adjustLayoutByDelta() ${prevLayout.join(", ")}`);
|
|
339
|
+
//DEBUG.push(` delta: ${delta}`);
|
|
340
|
+
//DEBUG.push(` pivotIndices: ${pivotIndices.join(", ")}`);
|
|
341
|
+
//DEBUG.push(` trigger: ${trigger}`);
|
|
342
|
+
//DEBUG.push("");
|
|
343
|
+
|
|
309
344
|
// A resizing panel affects the panels before or after it.
|
|
310
345
|
//
|
|
311
|
-
// A negative delta means the panel immediately after the
|
|
346
|
+
// A negative delta means the panel(s) immediately after the resize handle should grow/expand by decreasing its offset.
|
|
312
347
|
// Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
|
|
313
348
|
//
|
|
314
|
-
// A positive delta means the panel immediately before the
|
|
315
|
-
// This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the
|
|
349
|
+
// A positive delta means the panel(s) immediately before the resize handle should "expand".
|
|
350
|
+
// This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resize handle.
|
|
316
351
|
|
|
317
|
-
// First, check the panel we're pivoting around;
|
|
318
|
-
// We should only expand or contract by as much as its constraints allow
|
|
319
352
|
{
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (
|
|
336
|
-
|
|
353
|
+
// If this is a resize triggered by a keyboard event, our logic for expanding/collapsing is different.
|
|
354
|
+
// We no longer check the halfway threshold because this may prevent the panel from expanding at all.
|
|
355
|
+
if (trigger === "keyboard") {
|
|
356
|
+
{
|
|
357
|
+
// Check if we should expand a collapsed panel
|
|
358
|
+
const index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
359
|
+
const constraints = panelConstraints[index];
|
|
360
|
+
//DEBUG.push(`edge case check 1: ${index}`);
|
|
361
|
+
//DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
|
|
362
|
+
if (constraints.collapsible) {
|
|
363
|
+
const prevSize = prevLayout[index];
|
|
364
|
+
const {
|
|
365
|
+
collapsedSizePercentage,
|
|
366
|
+
minSizePercentage
|
|
367
|
+
} = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
|
|
368
|
+
if (fuzzyNumbersEqual(prevSize, collapsedSizePercentage)) {
|
|
369
|
+
const localDelta = minSizePercentage - prevSize;
|
|
370
|
+
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
371
|
+
|
|
372
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
|
|
373
|
+
delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
374
|
+
//DEBUG.push(` -> delta: ${delta}`);
|
|
375
|
+
}
|
|
337
376
|
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
{
|
|
381
|
+
// Check if we should collapse a panel at its minimum size
|
|
382
|
+
const index = delta < 0 ? pivotIndices[0] : pivotIndices[1];
|
|
383
|
+
const constraints = panelConstraints[index];
|
|
384
|
+
//DEBUG.push(`edge case check 2: ${index}`);
|
|
385
|
+
//DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
|
|
386
|
+
if (constraints.collapsible) {
|
|
387
|
+
const prevSize = prevLayout[index];
|
|
388
|
+
const {
|
|
389
|
+
collapsedSizePercentage,
|
|
390
|
+
minSizePercentage
|
|
391
|
+
} = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
|
|
392
|
+
if (fuzzyNumbersEqual(prevSize, minSizePercentage)) {
|
|
393
|
+
const localDelta = prevSize - collapsedSizePercentage;
|
|
394
|
+
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
395
|
+
|
|
396
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
|
|
397
|
+
delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
398
|
+
//DEBUG.push(` -> delta: ${delta}`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
338
402
|
}
|
|
339
403
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
404
|
+
//DEBUG.push("");
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
{
|
|
408
|
+
// Pre-calculate max available delta in the opposite direction of our pivot.
|
|
409
|
+
// This will be the maximum amount we're allowed to expand/contract the panels in the primary direction.
|
|
410
|
+
// If this amount is less than the requested delta, adjust the requested delta.
|
|
411
|
+
// If this amount is greater than the requested delta, that's useful information too–
|
|
412
|
+
// as an expanding panel might change from collapsed to min size.
|
|
413
|
+
|
|
414
|
+
const increment = delta < 0 ? 1 : -1;
|
|
415
|
+
let index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
416
|
+
let maxAvailableDelta = 0;
|
|
417
|
+
|
|
418
|
+
//DEBUG.push("pre calc...");
|
|
419
|
+
while (true) {
|
|
420
|
+
const prevSize = prevLayout[index];
|
|
421
|
+
const maxSafeSize = resizePanel({
|
|
422
|
+
groupSizePixels,
|
|
423
|
+
panelConstraints,
|
|
424
|
+
panelIndex: index,
|
|
425
|
+
size: 100
|
|
426
|
+
});
|
|
427
|
+
const delta = maxSafeSize - prevSize;
|
|
428
|
+
//DEBUG.push(` ${index}: ${prevSize} -> ${maxSafeSize}`);
|
|
429
|
+
|
|
430
|
+
maxAvailableDelta += delta;
|
|
431
|
+
index += increment;
|
|
432
|
+
if (index < 0 || index >= panelConstraints.length) {
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
351
435
|
}
|
|
436
|
+
|
|
437
|
+
//DEBUG.push(` -> max available delta: ${maxAvailableDelta}`);
|
|
438
|
+
const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
|
|
439
|
+
delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
|
|
440
|
+
//DEBUG.push(` -> adjusted delta: ${delta}`);
|
|
441
|
+
//DEBUG.push("");
|
|
352
442
|
}
|
|
353
443
|
|
|
354
|
-
// Delta added to a panel needs to be subtracted from other panels
|
|
355
|
-
// within the constraints that those panels allow
|
|
356
444
|
{
|
|
445
|
+
// Delta added to a panel needs to be subtracted from other panels (within the constraints that those panels allow).
|
|
446
|
+
|
|
357
447
|
const pivotIndex = delta < 0 ? pivotIndices[0] : pivotIndices[1];
|
|
358
448
|
let index = pivotIndex;
|
|
359
449
|
while (index >= 0 && index < panelConstraints.length) {
|
|
360
450
|
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
361
451
|
const prevSize = prevLayout[index];
|
|
362
452
|
const unsafeSize = prevSize - deltaRemaining;
|
|
363
|
-
|
|
453
|
+
const safeSize = resizePanel({
|
|
364
454
|
groupSizePixels,
|
|
365
455
|
panelConstraints,
|
|
366
456
|
panelIndex: index,
|
|
@@ -382,13 +472,18 @@ function adjustLayoutByDelta({
|
|
|
382
472
|
}
|
|
383
473
|
}
|
|
384
474
|
}
|
|
475
|
+
//DEBUG.push(`after 1: ${nextLayout.join(", ")}`);
|
|
476
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
477
|
+
//DEBUG.push("");
|
|
385
478
|
|
|
386
479
|
// If we were unable to resize any of the panels panels, return the previous state.
|
|
387
480
|
// This will essentially bailout and ignore e.g. drags past a panel's boundaries
|
|
388
481
|
if (fuzzyNumbersEqual(deltaApplied, 0)) {
|
|
482
|
+
//console.log(DEBUG.join("\n"));
|
|
389
483
|
return prevLayout;
|
|
390
484
|
}
|
|
391
485
|
{
|
|
486
|
+
// Now distribute the applied delta to the panels in the other direction
|
|
392
487
|
const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
393
488
|
const unsafeSize = prevLayout[pivotIndex] + deltaApplied;
|
|
394
489
|
const safeSize = resizePanel({
|
|
@@ -428,29 +523,21 @@ function adjustLayoutByDelta({
|
|
|
428
523
|
index++;
|
|
429
524
|
}
|
|
430
525
|
}
|
|
431
|
-
|
|
432
|
-
// If we can't redistribute, this layout is invalid;
|
|
433
|
-
// There may be an incremental layout that is valid though
|
|
434
|
-
if (!fuzzyNumbersEqual(deltaRemaining, 0)) {
|
|
435
|
-
try {
|
|
436
|
-
return adjustLayoutByDelta({
|
|
437
|
-
delta: delta < 0 ? delta + 1 : delta - 1,
|
|
438
|
-
groupSizePixels,
|
|
439
|
-
layout: prevLayout,
|
|
440
|
-
panelConstraints,
|
|
441
|
-
pivotIndices,
|
|
442
|
-
trigger
|
|
443
|
-
});
|
|
444
|
-
} catch (error) {
|
|
445
|
-
if (error instanceof RangeError) {
|
|
446
|
-
console.error(`Could not apply delta ${delta} to layout`);
|
|
447
|
-
return prevLayout;
|
|
448
|
-
}
|
|
449
|
-
} finally {
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
526
|
}
|
|
453
527
|
}
|
|
528
|
+
//DEBUG.push(`after 2: ${nextLayout.join(", ")}`);
|
|
529
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
530
|
+
//DEBUG.push("");
|
|
531
|
+
|
|
532
|
+
const totalSize = nextLayout.reduce((total, size) => size + total, 0);
|
|
533
|
+
deltaApplied = 100 - totalSize;
|
|
534
|
+
//DEBUG.push(`total size: ${totalSize}`);
|
|
535
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
536
|
+
//console.log(DEBUG.join("\n"));
|
|
537
|
+
|
|
538
|
+
if (!fuzzyNumbersEqual(totalSize, 100)) {
|
|
539
|
+
return prevLayout;
|
|
540
|
+
}
|
|
454
541
|
return nextLayout;
|
|
455
542
|
}
|
|
456
543
|
|
|
@@ -480,7 +567,7 @@ function getResizeHandleElementsForGroup(groupId) {
|
|
|
480
567
|
function getResizeHandleElementIndex(groupId, id) {
|
|
481
568
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
482
569
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
483
|
-
return index
|
|
570
|
+
return index !== null && index !== void 0 ? index : null;
|
|
484
571
|
}
|
|
485
572
|
|
|
486
573
|
function determinePivotIndices(groupId, dragHandleId) {
|
|
@@ -489,7 +576,7 @@ function determinePivotIndices(groupId, dragHandleId) {
|
|
|
489
576
|
}
|
|
490
577
|
|
|
491
578
|
function getPanelGroupElement(id) {
|
|
492
|
-
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
579
|
+
const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
493
580
|
if (element) {
|
|
494
581
|
return element;
|
|
495
582
|
}
|
|
@@ -541,11 +628,12 @@ function getResizeHandleElement(id) {
|
|
|
541
628
|
}
|
|
542
629
|
|
|
543
630
|
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
631
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
544
632
|
const handle = getResizeHandleElement(handleId);
|
|
545
633
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
546
634
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
547
|
-
const idBefore = panelsArray[index]
|
|
548
|
-
const idAfter = panelsArray[index + 1]
|
|
635
|
+
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;
|
|
636
|
+
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
549
637
|
return [idBefore, idAfter];
|
|
550
638
|
}
|
|
551
639
|
|
|
@@ -592,11 +680,12 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
592
680
|
const panelData = panelDataArray[index];
|
|
593
681
|
const size = layout[index];
|
|
594
682
|
if (size != null) {
|
|
683
|
+
var _getPercentageSizeFro;
|
|
595
684
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
596
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
685
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
597
686
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
598
687
|
sizePixels: panelData.constraints.minSizePixels
|
|
599
|
-
}, groupSizePixels)
|
|
688
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
600
689
|
let delta = 0;
|
|
601
690
|
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
602
691
|
delta = direction === "horizontal" ? width : height;
|
|
@@ -763,10 +852,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
|
|
|
763
852
|
onResize(mixedSizes, lastNotifiedMixedSizes);
|
|
764
853
|
}
|
|
765
854
|
if (collapsible && (onCollapse || onExpand)) {
|
|
766
|
-
|
|
855
|
+
var _getPercentageSizeFro;
|
|
856
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
767
857
|
sizePercentage: constraints.collapsedSizePercentage,
|
|
768
858
|
sizePixels: constraints.collapsedSizePixels
|
|
769
|
-
}, groupSizePixels)
|
|
859
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
770
860
|
const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
|
|
771
861
|
if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
|
|
772
862
|
onExpand();
|
|
@@ -1088,6 +1178,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1088
1178
|
autoSaveId,
|
|
1089
1179
|
children,
|
|
1090
1180
|
className: classNameFromProps = "",
|
|
1181
|
+
dataAttributes,
|
|
1091
1182
|
direction,
|
|
1092
1183
|
forwardedRef,
|
|
1093
1184
|
id: idFromProps,
|
|
@@ -1403,7 +1494,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1403
1494
|
} = committedValuesRef.current;
|
|
1404
1495
|
const {
|
|
1405
1496
|
initialLayout
|
|
1406
|
-
} = dragState
|
|
1497
|
+
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1407
1498
|
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1408
1499
|
let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
|
|
1409
1500
|
percentage: keyboardResizeByPercentage,
|
|
@@ -1423,7 +1514,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1423
1514
|
const nextLayout = adjustLayoutByDelta({
|
|
1424
1515
|
delta,
|
|
1425
1516
|
groupSizePixels,
|
|
1426
|
-
layout: initialLayout
|
|
1517
|
+
layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
|
|
1427
1518
|
panelConstraints,
|
|
1428
1519
|
pivotIndices,
|
|
1429
1520
|
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
@@ -1564,11 +1655,11 @@ function PanelGroupWithForwardedRef({
|
|
|
1564
1655
|
...style,
|
|
1565
1656
|
...styleFromProps
|
|
1566
1657
|
},
|
|
1658
|
+
...dataAttributes,
|
|
1567
1659
|
// CSS selectors
|
|
1568
1660
|
"data-panel-group": "",
|
|
1569
|
-
|
|
1570
|
-
"data-panel-group-
|
|
1571
|
-
"data-panel-group-id": groupId
|
|
1661
|
+
"data-panel-group-direction": direction,
|
|
1662
|
+
"data-panel-group-id": groupId
|
|
1572
1663
|
}));
|
|
1573
1664
|
}
|
|
1574
1665
|
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
@@ -1652,6 +1743,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1652
1743
|
function PanelResizeHandle({
|
|
1653
1744
|
children = null,
|
|
1654
1745
|
className: classNameFromProps = "",
|
|
1746
|
+
dataAttributes,
|
|
1655
1747
|
disabled = false,
|
|
1656
1748
|
id: idFromProps = null,
|
|
1657
1749
|
onDragging,
|
|
@@ -1680,7 +1772,7 @@ function PanelResizeHandle({
|
|
|
1680
1772
|
stopDragging
|
|
1681
1773
|
} = panelGroupContext;
|
|
1682
1774
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1683
|
-
const isDragging = dragState
|
|
1775
|
+
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
1684
1776
|
const [isFocused, setIsFocused] = useState(false);
|
|
1685
1777
|
const [resizeHandler, setResizeHandler] = useState(null);
|
|
1686
1778
|
const stopDraggingAndBlur = useCallback(() => {
|
|
@@ -1744,13 +1836,6 @@ function PanelResizeHandle({
|
|
|
1744
1836
|
return createElement(Type, {
|
|
1745
1837
|
children,
|
|
1746
1838
|
className: classNameFromProps,
|
|
1747
|
-
// CSS selectors
|
|
1748
|
-
"data-resize-handle": "",
|
|
1749
|
-
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1750
|
-
"data-panel-group-direction": direction,
|
|
1751
|
-
"data-panel-group-id": groupId,
|
|
1752
|
-
"data-panel-resize-handle-enabled": !disabled,
|
|
1753
|
-
"data-panel-resize-handle-id": resizeHandleId,
|
|
1754
1839
|
onBlur: () => setIsFocused(false),
|
|
1755
1840
|
onFocus: () => setIsFocused(true),
|
|
1756
1841
|
onMouseDown: event => {
|
|
@@ -1780,7 +1865,15 @@ function PanelResizeHandle({
|
|
|
1780
1865
|
...style,
|
|
1781
1866
|
...styleFromProps
|
|
1782
1867
|
},
|
|
1783
|
-
tabIndex: 0
|
|
1868
|
+
tabIndex: 0,
|
|
1869
|
+
...dataAttributes,
|
|
1870
|
+
// CSS selectors
|
|
1871
|
+
"data-panel-group-direction": direction,
|
|
1872
|
+
"data-panel-group-id": groupId,
|
|
1873
|
+
"data-resize-handle": "",
|
|
1874
|
+
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1875
|
+
"data-panel-resize-handle-enabled": !disabled,
|
|
1876
|
+
"data-panel-resize-handle-id": resizeHandleId
|
|
1784
1877
|
});
|
|
1785
1878
|
}
|
|
1786
1879
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|