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,
|
|
@@ -151,11 +152,12 @@ function PanelWithForwardedRef({
|
|
|
151
152
|
...style,
|
|
152
153
|
...styleFromProps
|
|
153
154
|
},
|
|
155
|
+
...dataAttributes,
|
|
154
156
|
// CSS selectors
|
|
155
157
|
"data-panel": "",
|
|
158
|
+
"data-panel-id": panelId,
|
|
156
159
|
// e2e test attributes
|
|
157
160
|
"data-panel-collapsible": undefined,
|
|
158
|
-
"data-panel-id": undefined,
|
|
159
161
|
"data-panel-size": undefined
|
|
160
162
|
});
|
|
161
163
|
}
|
|
@@ -183,6 +185,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
|
|
|
183
185
|
minSizePercentage = 0,
|
|
184
186
|
minSizePixels
|
|
185
187
|
} = panelConstraints;
|
|
188
|
+
const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
|
|
189
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
190
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
191
|
+
return {
|
|
192
|
+
collapsedSizePercentage: 0,
|
|
193
|
+
defaultSizePercentage,
|
|
194
|
+
maxSizePercentage: 0,
|
|
195
|
+
minSizePercentage: 0
|
|
196
|
+
};
|
|
197
|
+
}
|
|
186
198
|
if (collapsedSizePixels != null) {
|
|
187
199
|
collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
|
|
188
200
|
}
|
|
@@ -257,6 +269,16 @@ function resizePanel({
|
|
|
257
269
|
panelIndex,
|
|
258
270
|
size
|
|
259
271
|
}) {
|
|
272
|
+
const hasPixelConstraints = panelConstraints.some(({
|
|
273
|
+
collapsedSizePixels,
|
|
274
|
+
defaultSizePixels,
|
|
275
|
+
minSizePixels,
|
|
276
|
+
maxSizePixels
|
|
277
|
+
}) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
|
|
278
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
279
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
280
|
+
return 0;
|
|
281
|
+
}
|
|
260
282
|
let {
|
|
261
283
|
collapsible
|
|
262
284
|
} = panelConstraints[panelIndex];
|
|
@@ -268,7 +290,13 @@ function resizePanel({
|
|
|
268
290
|
if (minSizePercentage != null) {
|
|
269
291
|
if (fuzzyCompareNumbers(size, minSizePercentage) < 0) {
|
|
270
292
|
if (collapsible) {
|
|
271
|
-
|
|
293
|
+
// Collapsible panels should snap closed or open only once they cross the halfway point between collapsed and min size.
|
|
294
|
+
const halfwayPoint = (collapsedSizePercentage + minSizePercentage) / 2;
|
|
295
|
+
if (fuzzyCompareNumbers(size, halfwayPoint) < 0) {
|
|
296
|
+
size = collapsedSizePercentage;
|
|
297
|
+
} else {
|
|
298
|
+
size = minSizePercentage;
|
|
299
|
+
}
|
|
272
300
|
} else {
|
|
273
301
|
size = minSizePercentage;
|
|
274
302
|
}
|
|
@@ -295,61 +323,123 @@ function adjustLayoutByDelta({
|
|
|
295
323
|
const nextLayout = [...prevLayout];
|
|
296
324
|
let deltaApplied = 0;
|
|
297
325
|
|
|
326
|
+
//const DEBUG = [];
|
|
327
|
+
//DEBUG.push(`adjustLayoutByDelta() ${prevLayout.join(", ")}`);
|
|
328
|
+
//DEBUG.push(` delta: ${delta}`);
|
|
329
|
+
//DEBUG.push(` pivotIndices: ${pivotIndices.join(", ")}`);
|
|
330
|
+
//DEBUG.push(` trigger: ${trigger}`);
|
|
331
|
+
//DEBUG.push("");
|
|
332
|
+
|
|
298
333
|
// A resizing panel affects the panels before or after it.
|
|
299
334
|
//
|
|
300
|
-
// A negative delta means the panel immediately after the
|
|
335
|
+
// A negative delta means the panel(s) immediately after the resize handle should grow/expand by decreasing its offset.
|
|
301
336
|
// Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
|
|
302
337
|
//
|
|
303
|
-
// A positive delta means the panel immediately before the
|
|
304
|
-
// This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the
|
|
338
|
+
// A positive delta means the panel(s) immediately before the resize handle should "expand".
|
|
339
|
+
// This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resize handle.
|
|
305
340
|
|
|
306
|
-
// First, check the panel we're pivoting around;
|
|
307
|
-
// We should only expand or contract by as much as its constraints allow
|
|
308
341
|
{
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
if (
|
|
325
|
-
|
|
342
|
+
// If this is a resize triggered by a keyboard event, our logic for expanding/collapsing is different.
|
|
343
|
+
// We no longer check the halfway threshold because this may prevent the panel from expanding at all.
|
|
344
|
+
if (trigger === "keyboard") {
|
|
345
|
+
{
|
|
346
|
+
// Check if we should expand a collapsed panel
|
|
347
|
+
const index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
348
|
+
const constraints = panelConstraints[index];
|
|
349
|
+
//DEBUG.push(`edge case check 1: ${index}`);
|
|
350
|
+
//DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
|
|
351
|
+
if (constraints.collapsible) {
|
|
352
|
+
const prevSize = prevLayout[index];
|
|
353
|
+
const {
|
|
354
|
+
collapsedSizePercentage,
|
|
355
|
+
minSizePercentage
|
|
356
|
+
} = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
|
|
357
|
+
if (fuzzyNumbersEqual(prevSize, collapsedSizePercentage)) {
|
|
358
|
+
const localDelta = minSizePercentage - prevSize;
|
|
359
|
+
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
360
|
+
|
|
361
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
|
|
362
|
+
delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
363
|
+
//DEBUG.push(` -> delta: ${delta}`);
|
|
364
|
+
}
|
|
326
365
|
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
{
|
|
370
|
+
// Check if we should collapse a panel at its minimum size
|
|
371
|
+
const index = delta < 0 ? pivotIndices[0] : pivotIndices[1];
|
|
372
|
+
const constraints = panelConstraints[index];
|
|
373
|
+
//DEBUG.push(`edge case check 2: ${index}`);
|
|
374
|
+
//DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
|
|
375
|
+
if (constraints.collapsible) {
|
|
376
|
+
const prevSize = prevLayout[index];
|
|
377
|
+
const {
|
|
378
|
+
collapsedSizePercentage,
|
|
379
|
+
minSizePercentage
|
|
380
|
+
} = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
|
|
381
|
+
if (fuzzyNumbersEqual(prevSize, minSizePercentage)) {
|
|
382
|
+
const localDelta = prevSize - collapsedSizePercentage;
|
|
383
|
+
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
384
|
+
|
|
385
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
|
|
386
|
+
delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
387
|
+
//DEBUG.push(` -> delta: ${delta}`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
327
391
|
}
|
|
328
392
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
393
|
+
//DEBUG.push("");
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
{
|
|
397
|
+
// Pre-calculate max available delta in the opposite direction of our pivot.
|
|
398
|
+
// This will be the maximum amount we're allowed to expand/contract the panels in the primary direction.
|
|
399
|
+
// If this amount is less than the requested delta, adjust the requested delta.
|
|
400
|
+
// If this amount is greater than the requested delta, that's useful information too–
|
|
401
|
+
// as an expanding panel might change from collapsed to min size.
|
|
402
|
+
|
|
403
|
+
const increment = delta < 0 ? 1 : -1;
|
|
404
|
+
let index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
405
|
+
let maxAvailableDelta = 0;
|
|
406
|
+
|
|
407
|
+
//DEBUG.push("pre calc...");
|
|
408
|
+
while (true) {
|
|
409
|
+
const prevSize = prevLayout[index];
|
|
410
|
+
const maxSafeSize = resizePanel({
|
|
411
|
+
groupSizePixels,
|
|
412
|
+
panelConstraints,
|
|
413
|
+
panelIndex: index,
|
|
414
|
+
size: 100
|
|
415
|
+
});
|
|
416
|
+
const delta = maxSafeSize - prevSize;
|
|
417
|
+
//DEBUG.push(` ${index}: ${prevSize} -> ${maxSafeSize}`);
|
|
418
|
+
|
|
419
|
+
maxAvailableDelta += delta;
|
|
420
|
+
index += increment;
|
|
421
|
+
if (index < 0 || index >= panelConstraints.length) {
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
340
424
|
}
|
|
425
|
+
|
|
426
|
+
//DEBUG.push(` -> max available delta: ${maxAvailableDelta}`);
|
|
427
|
+
const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
|
|
428
|
+
delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
|
|
429
|
+
//DEBUG.push(` -> adjusted delta: ${delta}`);
|
|
430
|
+
//DEBUG.push("");
|
|
341
431
|
}
|
|
342
432
|
|
|
343
|
-
// Delta added to a panel needs to be subtracted from other panels
|
|
344
|
-
// within the constraints that those panels allow
|
|
345
433
|
{
|
|
434
|
+
// Delta added to a panel needs to be subtracted from other panels (within the constraints that those panels allow).
|
|
435
|
+
|
|
346
436
|
const pivotIndex = delta < 0 ? pivotIndices[0] : pivotIndices[1];
|
|
347
437
|
let index = pivotIndex;
|
|
348
438
|
while (index >= 0 && index < panelConstraints.length) {
|
|
349
439
|
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
350
440
|
const prevSize = prevLayout[index];
|
|
351
441
|
const unsafeSize = prevSize - deltaRemaining;
|
|
352
|
-
|
|
442
|
+
const safeSize = resizePanel({
|
|
353
443
|
groupSizePixels,
|
|
354
444
|
panelConstraints,
|
|
355
445
|
panelIndex: index,
|
|
@@ -371,13 +461,18 @@ function adjustLayoutByDelta({
|
|
|
371
461
|
}
|
|
372
462
|
}
|
|
373
463
|
}
|
|
464
|
+
//DEBUG.push(`after 1: ${nextLayout.join(", ")}`);
|
|
465
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
466
|
+
//DEBUG.push("");
|
|
374
467
|
|
|
375
468
|
// If we were unable to resize any of the panels panels, return the previous state.
|
|
376
469
|
// This will essentially bailout and ignore e.g. drags past a panel's boundaries
|
|
377
470
|
if (fuzzyNumbersEqual(deltaApplied, 0)) {
|
|
471
|
+
//console.log(DEBUG.join("\n"));
|
|
378
472
|
return prevLayout;
|
|
379
473
|
}
|
|
380
474
|
{
|
|
475
|
+
// Now distribute the applied delta to the panels in the other direction
|
|
381
476
|
const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
382
477
|
const unsafeSize = prevLayout[pivotIndex] + deltaApplied;
|
|
383
478
|
const safeSize = resizePanel({
|
|
@@ -417,29 +512,21 @@ function adjustLayoutByDelta({
|
|
|
417
512
|
index++;
|
|
418
513
|
}
|
|
419
514
|
}
|
|
420
|
-
|
|
421
|
-
// If we can't redistribute, this layout is invalid;
|
|
422
|
-
// There may be an incremental layout that is valid though
|
|
423
|
-
if (!fuzzyNumbersEqual(deltaRemaining, 0)) {
|
|
424
|
-
try {
|
|
425
|
-
return adjustLayoutByDelta({
|
|
426
|
-
delta: delta < 0 ? delta + 1 : delta - 1,
|
|
427
|
-
groupSizePixels,
|
|
428
|
-
layout: prevLayout,
|
|
429
|
-
panelConstraints,
|
|
430
|
-
pivotIndices,
|
|
431
|
-
trigger
|
|
432
|
-
});
|
|
433
|
-
} catch (error) {
|
|
434
|
-
if (error instanceof RangeError) {
|
|
435
|
-
console.error(`Could not apply delta ${delta} to layout`);
|
|
436
|
-
return prevLayout;
|
|
437
|
-
}
|
|
438
|
-
} finally {
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
515
|
}
|
|
442
516
|
}
|
|
517
|
+
//DEBUG.push(`after 2: ${nextLayout.join(", ")}`);
|
|
518
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
519
|
+
//DEBUG.push("");
|
|
520
|
+
|
|
521
|
+
const totalSize = nextLayout.reduce((total, size) => size + total, 0);
|
|
522
|
+
deltaApplied = 100 - totalSize;
|
|
523
|
+
//DEBUG.push(`total size: ${totalSize}`);
|
|
524
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
525
|
+
//console.log(DEBUG.join("\n"));
|
|
526
|
+
|
|
527
|
+
if (!fuzzyNumbersEqual(totalSize, 100)) {
|
|
528
|
+
return prevLayout;
|
|
529
|
+
}
|
|
443
530
|
return nextLayout;
|
|
444
531
|
}
|
|
445
532
|
|
|
@@ -469,7 +556,7 @@ function getResizeHandleElementsForGroup(groupId) {
|
|
|
469
556
|
function getResizeHandleElementIndex(groupId, id) {
|
|
470
557
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
471
558
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
472
|
-
return index
|
|
559
|
+
return index !== null && index !== void 0 ? index : null;
|
|
473
560
|
}
|
|
474
561
|
|
|
475
562
|
function determinePivotIndices(groupId, dragHandleId) {
|
|
@@ -478,7 +565,7 @@ function determinePivotIndices(groupId, dragHandleId) {
|
|
|
478
565
|
}
|
|
479
566
|
|
|
480
567
|
function getPanelGroupElement(id) {
|
|
481
|
-
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
568
|
+
const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
482
569
|
if (element) {
|
|
483
570
|
return element;
|
|
484
571
|
}
|
|
@@ -530,11 +617,12 @@ function getResizeHandleElement(id) {
|
|
|
530
617
|
}
|
|
531
618
|
|
|
532
619
|
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
620
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
533
621
|
const handle = getResizeHandleElement(handleId);
|
|
534
622
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
535
623
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
536
|
-
const idBefore = panelsArray[index]
|
|
537
|
-
const idAfter = panelsArray[index + 1]
|
|
624
|
+
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;
|
|
625
|
+
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
538
626
|
return [idBefore, idAfter];
|
|
539
627
|
}
|
|
540
628
|
|
|
@@ -581,11 +669,12 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
581
669
|
const panelData = panelDataArray[index];
|
|
582
670
|
const size = layout[index];
|
|
583
671
|
if (size != null) {
|
|
672
|
+
var _getPercentageSizeFro;
|
|
584
673
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
585
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
674
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
586
675
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
587
676
|
sizePixels: panelData.constraints.minSizePixels
|
|
588
|
-
}, groupSizePixels)
|
|
677
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
589
678
|
let delta = 0;
|
|
590
679
|
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
591
680
|
delta = direction === "horizontal" ? width : height;
|
|
@@ -752,10 +841,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
|
|
|
752
841
|
onResize(mixedSizes, lastNotifiedMixedSizes);
|
|
753
842
|
}
|
|
754
843
|
if (collapsible && (onCollapse || onExpand)) {
|
|
755
|
-
|
|
844
|
+
var _getPercentageSizeFro;
|
|
845
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
756
846
|
sizePercentage: constraints.collapsedSizePercentage,
|
|
757
847
|
sizePixels: constraints.collapsedSizePixels
|
|
758
|
-
}, groupSizePixels)
|
|
848
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
759
849
|
const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
|
|
760
850
|
if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
|
|
761
851
|
onExpand();
|
|
@@ -1000,6 +1090,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1000
1090
|
autoSaveId,
|
|
1001
1091
|
children,
|
|
1002
1092
|
className: classNameFromProps = "",
|
|
1093
|
+
dataAttributes,
|
|
1003
1094
|
direction,
|
|
1004
1095
|
forwardedRef,
|
|
1005
1096
|
id: idFromProps,
|
|
@@ -1273,7 +1364,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1273
1364
|
} = committedValuesRef.current;
|
|
1274
1365
|
const {
|
|
1275
1366
|
initialLayout
|
|
1276
|
-
} = dragState
|
|
1367
|
+
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1277
1368
|
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1278
1369
|
let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
|
|
1279
1370
|
percentage: keyboardResizeByPercentage,
|
|
@@ -1293,7 +1384,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1293
1384
|
const nextLayout = adjustLayoutByDelta({
|
|
1294
1385
|
delta,
|
|
1295
1386
|
groupSizePixels,
|
|
1296
|
-
layout: initialLayout
|
|
1387
|
+
layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
|
|
1297
1388
|
panelConstraints,
|
|
1298
1389
|
pivotIndices,
|
|
1299
1390
|
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
@@ -1434,11 +1525,11 @@ function PanelGroupWithForwardedRef({
|
|
|
1434
1525
|
...style,
|
|
1435
1526
|
...styleFromProps
|
|
1436
1527
|
},
|
|
1528
|
+
...dataAttributes,
|
|
1437
1529
|
// CSS selectors
|
|
1438
1530
|
"data-panel-group": "",
|
|
1439
|
-
|
|
1440
|
-
"data-panel-group-
|
|
1441
|
-
"data-panel-group-id": undefined
|
|
1531
|
+
"data-panel-group-direction": direction,
|
|
1532
|
+
"data-panel-group-id": groupId
|
|
1442
1533
|
}));
|
|
1443
1534
|
}
|
|
1444
1535
|
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
@@ -1522,6 +1613,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1522
1613
|
function PanelResizeHandle({
|
|
1523
1614
|
children = null,
|
|
1524
1615
|
className: classNameFromProps = "",
|
|
1616
|
+
dataAttributes,
|
|
1525
1617
|
disabled = false,
|
|
1526
1618
|
id: idFromProps = null,
|
|
1527
1619
|
onDragging,
|
|
@@ -1550,7 +1642,7 @@ function PanelResizeHandle({
|
|
|
1550
1642
|
stopDragging
|
|
1551
1643
|
} = panelGroupContext;
|
|
1552
1644
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1553
|
-
const isDragging = dragState
|
|
1645
|
+
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
1554
1646
|
const [isFocused, setIsFocused] = useState(false);
|
|
1555
1647
|
const [resizeHandler, setResizeHandler] = useState(null);
|
|
1556
1648
|
const stopDraggingAndBlur = useCallback(() => {
|
|
@@ -1614,13 +1706,6 @@ function PanelResizeHandle({
|
|
|
1614
1706
|
return createElement(Type, {
|
|
1615
1707
|
children,
|
|
1616
1708
|
className: classNameFromProps,
|
|
1617
|
-
// CSS selectors
|
|
1618
|
-
"data-resize-handle": "",
|
|
1619
|
-
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1620
|
-
"data-panel-group-direction": direction,
|
|
1621
|
-
"data-panel-group-id": groupId,
|
|
1622
|
-
"data-panel-resize-handle-enabled": !disabled,
|
|
1623
|
-
"data-panel-resize-handle-id": resizeHandleId,
|
|
1624
1709
|
onBlur: () => setIsFocused(false),
|
|
1625
1710
|
onFocus: () => setIsFocused(true),
|
|
1626
1711
|
onMouseDown: event => {
|
|
@@ -1650,7 +1735,15 @@ function PanelResizeHandle({
|
|
|
1650
1735
|
...style,
|
|
1651
1736
|
...styleFromProps
|
|
1652
1737
|
},
|
|
1653
|
-
tabIndex: 0
|
|
1738
|
+
tabIndex: 0,
|
|
1739
|
+
...dataAttributes,
|
|
1740
|
+
// CSS selectors
|
|
1741
|
+
"data-panel-group-direction": direction,
|
|
1742
|
+
"data-panel-group-id": groupId,
|
|
1743
|
+
"data-resize-handle": "",
|
|
1744
|
+
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1745
|
+
"data-panel-resize-handle-enabled": !disabled,
|
|
1746
|
+
"data-panel-resize-handle-id": resizeHandleId
|
|
1654
1747
|
});
|
|
1655
1748
|
}
|
|
1656
1749
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|