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
|
@@ -33,7 +33,7 @@ function useUniqueId(idFromParams = null) {
|
|
|
33
33
|
if (idRef.current === null) {
|
|
34
34
|
idRef.current = "" + counter++;
|
|
35
35
|
}
|
|
36
|
-
return idFromParams
|
|
36
|
+
return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function PanelWithForwardedRef({
|
|
@@ -42,6 +42,7 @@ function PanelWithForwardedRef({
|
|
|
42
42
|
collapsedSizePercentage,
|
|
43
43
|
collapsedSizePixels,
|
|
44
44
|
collapsible,
|
|
45
|
+
dataAttributes,
|
|
45
46
|
defaultSizePercentage,
|
|
46
47
|
defaultSizePixels,
|
|
47
48
|
forwardedRef,
|
|
@@ -138,11 +139,12 @@ function PanelWithForwardedRef({
|
|
|
138
139
|
...style,
|
|
139
140
|
...styleFromProps
|
|
140
141
|
},
|
|
142
|
+
...dataAttributes,
|
|
141
143
|
// CSS selectors
|
|
142
144
|
"data-panel": "",
|
|
145
|
+
"data-panel-id": panelId,
|
|
143
146
|
// e2e test attributes
|
|
144
147
|
"data-panel-collapsible": collapsible || undefined ,
|
|
145
|
-
"data-panel-id": panelId ,
|
|
146
148
|
"data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
|
|
147
149
|
});
|
|
148
150
|
}
|
|
@@ -170,6 +172,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
|
|
|
170
172
|
minSizePercentage = 0,
|
|
171
173
|
minSizePixels
|
|
172
174
|
} = panelConstraints;
|
|
175
|
+
const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
|
|
176
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
177
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
178
|
+
return {
|
|
179
|
+
collapsedSizePercentage: 0,
|
|
180
|
+
defaultSizePercentage,
|
|
181
|
+
maxSizePercentage: 0,
|
|
182
|
+
minSizePercentage: 0
|
|
183
|
+
};
|
|
184
|
+
}
|
|
173
185
|
if (collapsedSizePixels != null) {
|
|
174
186
|
collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
|
|
175
187
|
}
|
|
@@ -244,6 +256,16 @@ function resizePanel({
|
|
|
244
256
|
panelIndex,
|
|
245
257
|
size
|
|
246
258
|
}) {
|
|
259
|
+
const hasPixelConstraints = panelConstraints.some(({
|
|
260
|
+
collapsedSizePixels,
|
|
261
|
+
defaultSizePixels,
|
|
262
|
+
minSizePixels,
|
|
263
|
+
maxSizePixels
|
|
264
|
+
}) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
|
|
265
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
266
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
267
|
+
return 0;
|
|
268
|
+
}
|
|
247
269
|
let {
|
|
248
270
|
collapsible
|
|
249
271
|
} = panelConstraints[panelIndex];
|
|
@@ -255,7 +277,13 @@ function resizePanel({
|
|
|
255
277
|
if (minSizePercentage != null) {
|
|
256
278
|
if (fuzzyCompareNumbers(size, minSizePercentage) < 0) {
|
|
257
279
|
if (collapsible) {
|
|
258
|
-
|
|
280
|
+
// Collapsible panels should snap closed or open only once they cross the halfway point between collapsed and min size.
|
|
281
|
+
const halfwayPoint = (collapsedSizePercentage + minSizePercentage) / 2;
|
|
282
|
+
if (fuzzyCompareNumbers(size, halfwayPoint) < 0) {
|
|
283
|
+
size = collapsedSizePercentage;
|
|
284
|
+
} else {
|
|
285
|
+
size = minSizePercentage;
|
|
286
|
+
}
|
|
259
287
|
} else {
|
|
260
288
|
size = minSizePercentage;
|
|
261
289
|
}
|
|
@@ -282,61 +310,123 @@ function adjustLayoutByDelta({
|
|
|
282
310
|
const nextLayout = [...prevLayout];
|
|
283
311
|
let deltaApplied = 0;
|
|
284
312
|
|
|
313
|
+
//const DEBUG = [];
|
|
314
|
+
//DEBUG.push(`adjustLayoutByDelta() ${prevLayout.join(", ")}`);
|
|
315
|
+
//DEBUG.push(` delta: ${delta}`);
|
|
316
|
+
//DEBUG.push(` pivotIndices: ${pivotIndices.join(", ")}`);
|
|
317
|
+
//DEBUG.push(` trigger: ${trigger}`);
|
|
318
|
+
//DEBUG.push("");
|
|
319
|
+
|
|
285
320
|
// A resizing panel affects the panels before or after it.
|
|
286
321
|
//
|
|
287
|
-
// A negative delta means the panel immediately after the
|
|
322
|
+
// A negative delta means the panel(s) immediately after the resize handle should grow/expand by decreasing its offset.
|
|
288
323
|
// Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
|
|
289
324
|
//
|
|
290
|
-
// A positive delta means the panel immediately before the
|
|
291
|
-
// This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the
|
|
325
|
+
// A positive delta means the panel(s) immediately before the resize handle should "expand".
|
|
326
|
+
// This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resize handle.
|
|
292
327
|
|
|
293
|
-
// First, check the panel we're pivoting around;
|
|
294
|
-
// We should only expand or contract by as much as its constraints allow
|
|
295
328
|
{
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (
|
|
312
|
-
|
|
329
|
+
// If this is a resize triggered by a keyboard event, our logic for expanding/collapsing is different.
|
|
330
|
+
// We no longer check the halfway threshold because this may prevent the panel from expanding at all.
|
|
331
|
+
if (trigger === "keyboard") {
|
|
332
|
+
{
|
|
333
|
+
// Check if we should expand a collapsed panel
|
|
334
|
+
const index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
335
|
+
const constraints = panelConstraints[index];
|
|
336
|
+
//DEBUG.push(`edge case check 1: ${index}`);
|
|
337
|
+
//DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
|
|
338
|
+
if (constraints.collapsible) {
|
|
339
|
+
const prevSize = prevLayout[index];
|
|
340
|
+
const {
|
|
341
|
+
collapsedSizePercentage,
|
|
342
|
+
minSizePercentage
|
|
343
|
+
} = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
|
|
344
|
+
if (fuzzyNumbersEqual(prevSize, collapsedSizePercentage)) {
|
|
345
|
+
const localDelta = minSizePercentage - prevSize;
|
|
346
|
+
//DEBUG.push(` -> expand delta: ${localDelta}`);
|
|
347
|
+
|
|
348
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
|
|
349
|
+
delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
350
|
+
//DEBUG.push(` -> delta: ${delta}`);
|
|
351
|
+
}
|
|
313
352
|
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
{
|
|
357
|
+
// Check if we should collapse a panel at its minimum size
|
|
358
|
+
const index = delta < 0 ? pivotIndices[0] : pivotIndices[1];
|
|
359
|
+
const constraints = panelConstraints[index];
|
|
360
|
+
//DEBUG.push(`edge case check 2: ${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, minSizePercentage)) {
|
|
369
|
+
const localDelta = prevSize - collapsedSizePercentage;
|
|
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
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
314
378
|
}
|
|
315
379
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
380
|
+
//DEBUG.push("");
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
{
|
|
384
|
+
// Pre-calculate max available delta in the opposite direction of our pivot.
|
|
385
|
+
// This will be the maximum amount we're allowed to expand/contract the panels in the primary direction.
|
|
386
|
+
// If this amount is less than the requested delta, adjust the requested delta.
|
|
387
|
+
// If this amount is greater than the requested delta, that's useful information too–
|
|
388
|
+
// as an expanding panel might change from collapsed to min size.
|
|
389
|
+
|
|
390
|
+
const increment = delta < 0 ? 1 : -1;
|
|
391
|
+
let index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
392
|
+
let maxAvailableDelta = 0;
|
|
393
|
+
|
|
394
|
+
//DEBUG.push("pre calc...");
|
|
395
|
+
while (true) {
|
|
396
|
+
const prevSize = prevLayout[index];
|
|
397
|
+
const maxSafeSize = resizePanel({
|
|
398
|
+
groupSizePixels,
|
|
399
|
+
panelConstraints,
|
|
400
|
+
panelIndex: index,
|
|
401
|
+
size: 100
|
|
402
|
+
});
|
|
403
|
+
const delta = maxSafeSize - prevSize;
|
|
404
|
+
//DEBUG.push(` ${index}: ${prevSize} -> ${maxSafeSize}`);
|
|
405
|
+
|
|
406
|
+
maxAvailableDelta += delta;
|
|
407
|
+
index += increment;
|
|
408
|
+
if (index < 0 || index >= panelConstraints.length) {
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
327
411
|
}
|
|
412
|
+
|
|
413
|
+
//DEBUG.push(` -> max available delta: ${maxAvailableDelta}`);
|
|
414
|
+
const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
|
|
415
|
+
delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
|
|
416
|
+
//DEBUG.push(` -> adjusted delta: ${delta}`);
|
|
417
|
+
//DEBUG.push("");
|
|
328
418
|
}
|
|
329
419
|
|
|
330
|
-
// Delta added to a panel needs to be subtracted from other panels
|
|
331
|
-
// within the constraints that those panels allow
|
|
332
420
|
{
|
|
421
|
+
// Delta added to a panel needs to be subtracted from other panels (within the constraints that those panels allow).
|
|
422
|
+
|
|
333
423
|
const pivotIndex = delta < 0 ? pivotIndices[0] : pivotIndices[1];
|
|
334
424
|
let index = pivotIndex;
|
|
335
425
|
while (index >= 0 && index < panelConstraints.length) {
|
|
336
426
|
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
337
427
|
const prevSize = prevLayout[index];
|
|
338
428
|
const unsafeSize = prevSize - deltaRemaining;
|
|
339
|
-
|
|
429
|
+
const safeSize = resizePanel({
|
|
340
430
|
groupSizePixels,
|
|
341
431
|
panelConstraints,
|
|
342
432
|
panelIndex: index,
|
|
@@ -358,13 +448,18 @@ function adjustLayoutByDelta({
|
|
|
358
448
|
}
|
|
359
449
|
}
|
|
360
450
|
}
|
|
451
|
+
//DEBUG.push(`after 1: ${nextLayout.join(", ")}`);
|
|
452
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
453
|
+
//DEBUG.push("");
|
|
361
454
|
|
|
362
455
|
// If we were unable to resize any of the panels panels, return the previous state.
|
|
363
456
|
// This will essentially bailout and ignore e.g. drags past a panel's boundaries
|
|
364
457
|
if (fuzzyNumbersEqual(deltaApplied, 0)) {
|
|
458
|
+
//console.log(DEBUG.join("\n"));
|
|
365
459
|
return prevLayout;
|
|
366
460
|
}
|
|
367
461
|
{
|
|
462
|
+
// Now distribute the applied delta to the panels in the other direction
|
|
368
463
|
const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
|
|
369
464
|
const unsafeSize = prevLayout[pivotIndex] + deltaApplied;
|
|
370
465
|
const safeSize = resizePanel({
|
|
@@ -404,29 +499,21 @@ function adjustLayoutByDelta({
|
|
|
404
499
|
index++;
|
|
405
500
|
}
|
|
406
501
|
}
|
|
407
|
-
|
|
408
|
-
// If we can't redistribute, this layout is invalid;
|
|
409
|
-
// There may be an incremental layout that is valid though
|
|
410
|
-
if (!fuzzyNumbersEqual(deltaRemaining, 0)) {
|
|
411
|
-
try {
|
|
412
|
-
return adjustLayoutByDelta({
|
|
413
|
-
delta: delta < 0 ? delta + 1 : delta - 1,
|
|
414
|
-
groupSizePixels,
|
|
415
|
-
layout: prevLayout,
|
|
416
|
-
panelConstraints,
|
|
417
|
-
pivotIndices,
|
|
418
|
-
trigger
|
|
419
|
-
});
|
|
420
|
-
} catch (error) {
|
|
421
|
-
if (error instanceof RangeError) {
|
|
422
|
-
console.error(`Could not apply delta ${delta} to layout`);
|
|
423
|
-
return prevLayout;
|
|
424
|
-
}
|
|
425
|
-
} finally {
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
502
|
}
|
|
429
503
|
}
|
|
504
|
+
//DEBUG.push(`after 2: ${nextLayout.join(", ")}`);
|
|
505
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
506
|
+
//DEBUG.push("");
|
|
507
|
+
|
|
508
|
+
const totalSize = nextLayout.reduce((total, size) => size + total, 0);
|
|
509
|
+
deltaApplied = 100 - totalSize;
|
|
510
|
+
//DEBUG.push(`total size: ${totalSize}`);
|
|
511
|
+
//DEBUG.push(` deltaApplied: ${deltaApplied}`);
|
|
512
|
+
//console.log(DEBUG.join("\n"));
|
|
513
|
+
|
|
514
|
+
if (!fuzzyNumbersEqual(totalSize, 100)) {
|
|
515
|
+
return prevLayout;
|
|
516
|
+
}
|
|
430
517
|
return nextLayout;
|
|
431
518
|
}
|
|
432
519
|
|
|
@@ -456,7 +543,7 @@ function getResizeHandleElementsForGroup(groupId) {
|
|
|
456
543
|
function getResizeHandleElementIndex(groupId, id) {
|
|
457
544
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
458
545
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
459
|
-
return index
|
|
546
|
+
return index !== null && index !== void 0 ? index : null;
|
|
460
547
|
}
|
|
461
548
|
|
|
462
549
|
function determinePivotIndices(groupId, dragHandleId) {
|
|
@@ -465,7 +552,7 @@ function determinePivotIndices(groupId, dragHandleId) {
|
|
|
465
552
|
}
|
|
466
553
|
|
|
467
554
|
function getPanelGroupElement(id) {
|
|
468
|
-
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
555
|
+
const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
469
556
|
if (element) {
|
|
470
557
|
return element;
|
|
471
558
|
}
|
|
@@ -517,11 +604,12 @@ function getResizeHandleElement(id) {
|
|
|
517
604
|
}
|
|
518
605
|
|
|
519
606
|
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
607
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
520
608
|
const handle = getResizeHandleElement(handleId);
|
|
521
609
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
522
610
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
523
|
-
const idBefore = panelsArray[index]
|
|
524
|
-
const idAfter = panelsArray[index + 1]
|
|
611
|
+
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;
|
|
612
|
+
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
525
613
|
return [idBefore, idAfter];
|
|
526
614
|
}
|
|
527
615
|
|
|
@@ -568,11 +656,12 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
568
656
|
const panelData = panelDataArray[index];
|
|
569
657
|
const size = layout[index];
|
|
570
658
|
if (size != null) {
|
|
659
|
+
var _getPercentageSizeFro;
|
|
571
660
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
572
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
661
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
573
662
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
574
663
|
sizePixels: panelData.constraints.minSizePixels
|
|
575
|
-
}, groupSizePixels)
|
|
664
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
576
665
|
let delta = 0;
|
|
577
666
|
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
578
667
|
delta = direction === "horizontal" ? width : height;
|
|
@@ -739,10 +828,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
|
|
|
739
828
|
onResize(mixedSizes, lastNotifiedMixedSizes);
|
|
740
829
|
}
|
|
741
830
|
if (collapsible && (onCollapse || onExpand)) {
|
|
742
|
-
|
|
831
|
+
var _getPercentageSizeFro;
|
|
832
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
743
833
|
sizePercentage: constraints.collapsedSizePercentage,
|
|
744
834
|
sizePixels: constraints.collapsedSizePixels
|
|
745
|
-
}, groupSizePixels)
|
|
835
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
746
836
|
const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
|
|
747
837
|
if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
|
|
748
838
|
onExpand();
|
|
@@ -1064,6 +1154,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1064
1154
|
autoSaveId,
|
|
1065
1155
|
children,
|
|
1066
1156
|
className: classNameFromProps = "",
|
|
1157
|
+
dataAttributes,
|
|
1067
1158
|
direction,
|
|
1068
1159
|
forwardedRef,
|
|
1069
1160
|
id: idFromProps,
|
|
@@ -1379,7 +1470,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1379
1470
|
} = committedValuesRef.current;
|
|
1380
1471
|
const {
|
|
1381
1472
|
initialLayout
|
|
1382
|
-
} = dragState
|
|
1473
|
+
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1383
1474
|
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1384
1475
|
let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
|
|
1385
1476
|
percentage: keyboardResizeByPercentage,
|
|
@@ -1399,7 +1490,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1399
1490
|
const nextLayout = adjustLayoutByDelta({
|
|
1400
1491
|
delta,
|
|
1401
1492
|
groupSizePixels,
|
|
1402
|
-
layout: initialLayout
|
|
1493
|
+
layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
|
|
1403
1494
|
panelConstraints,
|
|
1404
1495
|
pivotIndices,
|
|
1405
1496
|
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
@@ -1540,11 +1631,11 @@ function PanelGroupWithForwardedRef({
|
|
|
1540
1631
|
...style,
|
|
1541
1632
|
...styleFromProps
|
|
1542
1633
|
},
|
|
1634
|
+
...dataAttributes,
|
|
1543
1635
|
// CSS selectors
|
|
1544
1636
|
"data-panel-group": "",
|
|
1545
|
-
|
|
1546
|
-
"data-panel-group-
|
|
1547
|
-
"data-panel-group-id": groupId
|
|
1637
|
+
"data-panel-group-direction": direction,
|
|
1638
|
+
"data-panel-group-id": groupId
|
|
1548
1639
|
}));
|
|
1549
1640
|
}
|
|
1550
1641
|
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
@@ -1628,6 +1719,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
1628
1719
|
function PanelResizeHandle({
|
|
1629
1720
|
children = null,
|
|
1630
1721
|
className: classNameFromProps = "",
|
|
1722
|
+
dataAttributes,
|
|
1631
1723
|
disabled = false,
|
|
1632
1724
|
id: idFromProps = null,
|
|
1633
1725
|
onDragging,
|
|
@@ -1656,7 +1748,7 @@ function PanelResizeHandle({
|
|
|
1656
1748
|
stopDragging
|
|
1657
1749
|
} = panelGroupContext;
|
|
1658
1750
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1659
|
-
const isDragging = dragState
|
|
1751
|
+
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
1660
1752
|
const [isFocused, setIsFocused] = useState(false);
|
|
1661
1753
|
const [resizeHandler, setResizeHandler] = useState(null);
|
|
1662
1754
|
const stopDraggingAndBlur = useCallback(() => {
|
|
@@ -1720,13 +1812,6 @@ function PanelResizeHandle({
|
|
|
1720
1812
|
return createElement(Type, {
|
|
1721
1813
|
children,
|
|
1722
1814
|
className: classNameFromProps,
|
|
1723
|
-
// CSS selectors
|
|
1724
|
-
"data-resize-handle": "",
|
|
1725
|
-
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1726
|
-
"data-panel-group-direction": direction,
|
|
1727
|
-
"data-panel-group-id": groupId,
|
|
1728
|
-
"data-panel-resize-handle-enabled": !disabled,
|
|
1729
|
-
"data-panel-resize-handle-id": resizeHandleId,
|
|
1730
1815
|
onBlur: () => setIsFocused(false),
|
|
1731
1816
|
onFocus: () => setIsFocused(true),
|
|
1732
1817
|
onMouseDown: event => {
|
|
@@ -1756,7 +1841,15 @@ function PanelResizeHandle({
|
|
|
1756
1841
|
...style,
|
|
1757
1842
|
...styleFromProps
|
|
1758
1843
|
},
|
|
1759
|
-
tabIndex: 0
|
|
1844
|
+
tabIndex: 0,
|
|
1845
|
+
...dataAttributes,
|
|
1846
|
+
// CSS selectors
|
|
1847
|
+
"data-panel-group-direction": direction,
|
|
1848
|
+
"data-panel-group-id": groupId,
|
|
1849
|
+
"data-resize-handle": "",
|
|
1850
|
+
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1851
|
+
"data-panel-resize-handle-enabled": !disabled,
|
|
1852
|
+
"data-panel-resize-handle-id": resizeHandleId
|
|
1760
1853
|
});
|
|
1761
1854
|
}
|
|
1762
1855
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|