react-resizable-panels 0.0.56 → 0.0.57
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 +4 -0
- package/dist/react-resizable-panels.browser.cjs.js +57 -30
- package/dist/react-resizable-panels.browser.development.cjs.js +57 -30
- package/dist/react-resizable-panels.browser.development.esm.js +57 -30
- package/dist/react-resizable-panels.browser.esm.js +57 -30
- package/dist/react-resizable-panels.cjs.js +57 -30
- package/dist/react-resizable-panels.cjs.js.map +1 -1
- package/dist/react-resizable-panels.development.cjs.js +57 -30
- package/dist/react-resizable-panels.development.esm.js +57 -30
- package/dist/react-resizable-panels.development.node.cjs.js +46 -25
- package/dist/react-resizable-panels.development.node.esm.js +46 -25
- package/dist/react-resizable-panels.esm.js +57 -30
- package/dist/react-resizable-panels.esm.js.map +1 -1
- package/dist/react-resizable-panels.node.cjs.js +46 -25
- package/dist/react-resizable-panels.node.esm.js +46 -25
- package/package.json +3 -1
- package/src/Panel.ts +1 -1
- package/src/PanelGroup.ts +6 -4
- package/src/PanelResizeHandle.ts +12 -13
- package/src/utils/adjustLayoutByDelta.ts +1 -1
- 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 +45 -0
- package/src/utils/resizePanel.ts +19 -0
|
@@ -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({
|
|
@@ -140,9 +140,9 @@ function PanelWithForwardedRef({
|
|
|
140
140
|
},
|
|
141
141
|
// CSS selectors
|
|
142
142
|
"data-panel": "",
|
|
143
|
+
"data-panel-id": panelId,
|
|
143
144
|
// e2e test attributes
|
|
144
145
|
"data-panel-collapsible": collapsible || undefined ,
|
|
145
|
-
"data-panel-id": panelId ,
|
|
146
146
|
"data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
|
|
147
147
|
});
|
|
148
148
|
}
|
|
@@ -170,6 +170,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
|
|
|
170
170
|
minSizePercentage = 0,
|
|
171
171
|
minSizePixels
|
|
172
172
|
} = panelConstraints;
|
|
173
|
+
const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
|
|
174
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
175
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
176
|
+
return {
|
|
177
|
+
collapsedSizePercentage: 0,
|
|
178
|
+
defaultSizePercentage,
|
|
179
|
+
maxSizePercentage: 0,
|
|
180
|
+
minSizePercentage: 0
|
|
181
|
+
};
|
|
182
|
+
}
|
|
173
183
|
if (collapsedSizePixels != null) {
|
|
174
184
|
collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
|
|
175
185
|
}
|
|
@@ -244,6 +254,16 @@ function resizePanel({
|
|
|
244
254
|
panelIndex,
|
|
245
255
|
size
|
|
246
256
|
}) {
|
|
257
|
+
const hasPixelConstraints = panelConstraints.some(({
|
|
258
|
+
collapsedSizePixels,
|
|
259
|
+
defaultSizePixels,
|
|
260
|
+
minSizePixels,
|
|
261
|
+
maxSizePixels
|
|
262
|
+
}) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
|
|
263
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
264
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
265
|
+
return 0;
|
|
266
|
+
}
|
|
247
267
|
let {
|
|
248
268
|
collapsible
|
|
249
269
|
} = panelConstraints[panelIndex];
|
|
@@ -300,7 +320,6 @@ function adjustLayoutByDelta({
|
|
|
300
320
|
} = panelConstraints[pivotIndex];
|
|
301
321
|
const {
|
|
302
322
|
collapsedSizePercentage,
|
|
303
|
-
maxSizePercentage,
|
|
304
323
|
minSizePercentage
|
|
305
324
|
} = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
|
|
306
325
|
const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
|
|
@@ -456,7 +475,7 @@ function getResizeHandleElementsForGroup(groupId) {
|
|
|
456
475
|
function getResizeHandleElementIndex(groupId, id) {
|
|
457
476
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
458
477
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
459
|
-
return index
|
|
478
|
+
return index !== null && index !== void 0 ? index : null;
|
|
460
479
|
}
|
|
461
480
|
|
|
462
481
|
function determinePivotIndices(groupId, dragHandleId) {
|
|
@@ -465,7 +484,7 @@ function determinePivotIndices(groupId, dragHandleId) {
|
|
|
465
484
|
}
|
|
466
485
|
|
|
467
486
|
function getPanelGroupElement(id) {
|
|
468
|
-
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
487
|
+
const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
469
488
|
if (element) {
|
|
470
489
|
return element;
|
|
471
490
|
}
|
|
@@ -517,11 +536,12 @@ function getResizeHandleElement(id) {
|
|
|
517
536
|
}
|
|
518
537
|
|
|
519
538
|
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
539
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
520
540
|
const handle = getResizeHandleElement(handleId);
|
|
521
541
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
522
542
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
523
|
-
const idBefore = panelsArray[index]
|
|
524
|
-
const idAfter = panelsArray[index + 1]
|
|
543
|
+
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;
|
|
544
|
+
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
545
|
return [idBefore, idAfter];
|
|
526
546
|
}
|
|
527
547
|
|
|
@@ -568,11 +588,12 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
568
588
|
const panelData = panelDataArray[index];
|
|
569
589
|
const size = layout[index];
|
|
570
590
|
if (size != null) {
|
|
591
|
+
var _getPercentageSizeFro;
|
|
571
592
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
572
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
593
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
573
594
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
574
595
|
sizePixels: panelData.constraints.minSizePixels
|
|
575
|
-
}, groupSizePixels)
|
|
596
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
576
597
|
let delta = 0;
|
|
577
598
|
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
578
599
|
delta = direction === "horizontal" ? width : height;
|
|
@@ -739,10 +760,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
|
|
|
739
760
|
onResize(mixedSizes, lastNotifiedMixedSizes);
|
|
740
761
|
}
|
|
741
762
|
if (collapsible && (onCollapse || onExpand)) {
|
|
742
|
-
|
|
763
|
+
var _getPercentageSizeFro;
|
|
764
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
743
765
|
sizePercentage: constraints.collapsedSizePercentage,
|
|
744
766
|
sizePixels: constraints.collapsedSizePixels
|
|
745
|
-
}, groupSizePixels)
|
|
767
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
746
768
|
const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
|
|
747
769
|
if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
|
|
748
770
|
onExpand();
|
|
@@ -1379,7 +1401,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1379
1401
|
} = committedValuesRef.current;
|
|
1380
1402
|
const {
|
|
1381
1403
|
initialLayout
|
|
1382
|
-
} = dragState
|
|
1404
|
+
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1383
1405
|
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1384
1406
|
let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
|
|
1385
1407
|
percentage: keyboardResizeByPercentage,
|
|
@@ -1399,7 +1421,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1399
1421
|
const nextLayout = adjustLayoutByDelta({
|
|
1400
1422
|
delta,
|
|
1401
1423
|
groupSizePixels,
|
|
1402
|
-
layout: initialLayout
|
|
1424
|
+
layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
|
|
1403
1425
|
panelConstraints,
|
|
1404
1426
|
pivotIndices,
|
|
1405
1427
|
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
@@ -1542,9 +1564,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1542
1564
|
},
|
|
1543
1565
|
// CSS selectors
|
|
1544
1566
|
"data-panel-group": "",
|
|
1545
|
-
|
|
1546
|
-
"data-panel-group-
|
|
1547
|
-
"data-panel-group-id": groupId
|
|
1567
|
+
"data-panel-group-direction": direction,
|
|
1568
|
+
"data-panel-group-id": groupId
|
|
1548
1569
|
}));
|
|
1549
1570
|
}
|
|
1550
1571
|
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
@@ -1656,7 +1677,7 @@ function PanelResizeHandle({
|
|
|
1656
1677
|
stopDragging
|
|
1657
1678
|
} = panelGroupContext;
|
|
1658
1679
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1659
|
-
const isDragging = dragState
|
|
1680
|
+
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
1660
1681
|
const [isFocused, setIsFocused] = useState(false);
|
|
1661
1682
|
const [resizeHandler, setResizeHandler] = useState(null);
|
|
1662
1683
|
const stopDraggingAndBlur = useCallback(() => {
|
|
@@ -1720,13 +1741,6 @@ function PanelResizeHandle({
|
|
|
1720
1741
|
return createElement(Type, {
|
|
1721
1742
|
children,
|
|
1722
1743
|
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
1744
|
onBlur: () => setIsFocused(false),
|
|
1731
1745
|
onFocus: () => setIsFocused(true),
|
|
1732
1746
|
onMouseDown: event => {
|
|
@@ -1756,7 +1770,14 @@ function PanelResizeHandle({
|
|
|
1756
1770
|
...style,
|
|
1757
1771
|
...styleFromProps
|
|
1758
1772
|
},
|
|
1759
|
-
tabIndex: 0
|
|
1773
|
+
tabIndex: 0,
|
|
1774
|
+
// CSS selectors
|
|
1775
|
+
"data-panel-group-direction": direction,
|
|
1776
|
+
"data-panel-group-id": groupId,
|
|
1777
|
+
"data-resize-handle": "",
|
|
1778
|
+
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1779
|
+
"data-panel-resize-handle-enabled": !disabled,
|
|
1780
|
+
"data-panel-resize-handle-id": resizeHandleId
|
|
1760
1781
|
});
|
|
1761
1782
|
}
|
|
1762
1783
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
@@ -37,7 +37,7 @@ function useUniqueId(idFromParams = null) {
|
|
|
37
37
|
if (idRef.current === null) {
|
|
38
38
|
idRef.current = "" + counter++;
|
|
39
39
|
}
|
|
40
|
-
return idFromParams
|
|
40
|
+
return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function PanelWithForwardedRef({
|
|
@@ -161,9 +161,9 @@ function PanelWithForwardedRef({
|
|
|
161
161
|
},
|
|
162
162
|
// CSS selectors
|
|
163
163
|
"data-panel": "",
|
|
164
|
+
"data-panel-id": panelId,
|
|
164
165
|
// e2e test attributes
|
|
165
166
|
"data-panel-collapsible": undefined,
|
|
166
|
-
"data-panel-id": undefined,
|
|
167
167
|
"data-panel-size": undefined
|
|
168
168
|
});
|
|
169
169
|
}
|
|
@@ -191,6 +191,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
|
|
|
191
191
|
minSizePercentage = 0,
|
|
192
192
|
minSizePixels
|
|
193
193
|
} = panelConstraints;
|
|
194
|
+
const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
|
|
195
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
196
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
197
|
+
return {
|
|
198
|
+
collapsedSizePercentage: 0,
|
|
199
|
+
defaultSizePercentage,
|
|
200
|
+
maxSizePercentage: 0,
|
|
201
|
+
minSizePercentage: 0
|
|
202
|
+
};
|
|
203
|
+
}
|
|
194
204
|
if (collapsedSizePixels != null) {
|
|
195
205
|
collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
|
|
196
206
|
}
|
|
@@ -265,6 +275,16 @@ function resizePanel({
|
|
|
265
275
|
panelIndex,
|
|
266
276
|
size
|
|
267
277
|
}) {
|
|
278
|
+
const hasPixelConstraints = panelConstraints.some(({
|
|
279
|
+
collapsedSizePixels,
|
|
280
|
+
defaultSizePixels,
|
|
281
|
+
minSizePixels,
|
|
282
|
+
maxSizePixels
|
|
283
|
+
}) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
|
|
284
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
285
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
286
|
+
return 0;
|
|
287
|
+
}
|
|
268
288
|
let {
|
|
269
289
|
collapsible
|
|
270
290
|
} = panelConstraints[panelIndex];
|
|
@@ -321,7 +341,6 @@ function adjustLayoutByDelta({
|
|
|
321
341
|
} = panelConstraints[pivotIndex];
|
|
322
342
|
const {
|
|
323
343
|
collapsedSizePercentage,
|
|
324
|
-
maxSizePercentage,
|
|
325
344
|
minSizePercentage
|
|
326
345
|
} = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
|
|
327
346
|
const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
|
|
@@ -483,6 +502,7 @@ function calculateAriaValues({
|
|
|
483
502
|
|
|
484
503
|
// A panel's effective min/max sizes also need to account for other panel's sizes.
|
|
485
504
|
panelsArray.forEach((panelData, index) => {
|
|
505
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
486
506
|
const {
|
|
487
507
|
constraints
|
|
488
508
|
} = panelData;
|
|
@@ -492,14 +512,14 @@ function calculateAriaValues({
|
|
|
492
512
|
minSizePercentage,
|
|
493
513
|
minSizePixels
|
|
494
514
|
} = constraints;
|
|
495
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
515
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
496
516
|
sizePercentage: minSizePercentage,
|
|
497
517
|
sizePixels: minSizePixels
|
|
498
|
-
}, groupSizePixels)
|
|
499
|
-
const maxSize = getPercentageSizeFromMixedSizes({
|
|
518
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
519
|
+
const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
500
520
|
sizePercentage: maxSizePercentage,
|
|
501
521
|
sizePixels: maxSizePixels
|
|
502
|
-
}, groupSizePixels)
|
|
522
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
|
|
503
523
|
if (index === pivotIndices[0]) {
|
|
504
524
|
currentMinSize = minSize;
|
|
505
525
|
currentMaxSize = maxSize;
|
|
@@ -525,7 +545,7 @@ function getResizeHandleElementsForGroup(groupId) {
|
|
|
525
545
|
function getResizeHandleElementIndex(groupId, id) {
|
|
526
546
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
527
547
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
528
|
-
return index
|
|
548
|
+
return index !== null && index !== void 0 ? index : null;
|
|
529
549
|
}
|
|
530
550
|
|
|
531
551
|
function determinePivotIndices(groupId, dragHandleId) {
|
|
@@ -534,7 +554,7 @@ function determinePivotIndices(groupId, dragHandleId) {
|
|
|
534
554
|
}
|
|
535
555
|
|
|
536
556
|
function getPanelGroupElement(id) {
|
|
537
|
-
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
557
|
+
const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
538
558
|
if (element) {
|
|
539
559
|
return element;
|
|
540
560
|
}
|
|
@@ -586,11 +606,12 @@ function getResizeHandleElement(id) {
|
|
|
586
606
|
}
|
|
587
607
|
|
|
588
608
|
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
609
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
589
610
|
const handle = getResizeHandleElement(handleId);
|
|
590
611
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
591
612
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
592
|
-
const idBefore = panelsArray[index]
|
|
593
|
-
const idAfter = panelsArray[index + 1]
|
|
613
|
+
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;
|
|
614
|
+
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
594
615
|
return [idBefore, idAfter];
|
|
595
616
|
}
|
|
596
617
|
|
|
@@ -668,11 +689,12 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
668
689
|
const panelData = panelDataArray[index];
|
|
669
690
|
const size = layout[index];
|
|
670
691
|
if (size != null) {
|
|
692
|
+
var _getPercentageSizeFro;
|
|
671
693
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
672
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
694
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
673
695
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
674
696
|
sizePixels: panelData.constraints.minSizePixels
|
|
675
|
-
}, groupSizePixels)
|
|
697
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
676
698
|
let delta = 0;
|
|
677
699
|
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
678
700
|
delta = direction === "horizontal" ? width : height;
|
|
@@ -877,10 +899,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
|
|
|
877
899
|
onResize(mixedSizes, lastNotifiedMixedSizes);
|
|
878
900
|
}
|
|
879
901
|
if (collapsible && (onCollapse || onExpand)) {
|
|
880
|
-
|
|
902
|
+
var _getPercentageSizeFro;
|
|
903
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
881
904
|
sizePercentage: constraints.collapsedSizePercentage,
|
|
882
905
|
sizePixels: constraints.collapsedSizePixels
|
|
883
|
-
}, groupSizePixels)
|
|
906
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
884
907
|
const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
|
|
885
908
|
if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
|
|
886
909
|
onExpand();
|
|
@@ -1046,8 +1069,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
|
1046
1069
|
function loadPanelLayout(autoSaveId, panels, storage) {
|
|
1047
1070
|
const state = loadSerializedPanelGroupState(autoSaveId, storage);
|
|
1048
1071
|
if (state) {
|
|
1072
|
+
var _state$key;
|
|
1049
1073
|
const key = getSerializationKey(panels);
|
|
1050
|
-
return state[key]
|
|
1074
|
+
return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
|
|
1051
1075
|
}
|
|
1052
1076
|
return null;
|
|
1053
1077
|
}
|
|
@@ -1263,6 +1287,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1263
1287
|
unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
|
|
1264
1288
|
}
|
|
1265
1289
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1290
|
+
if (groupSizePixels <= 0) {
|
|
1291
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1266
1294
|
if (unsafeLayout == null) {
|
|
1267
1295
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
1268
1296
|
groupSizePixels,
|
|
@@ -1506,7 +1534,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1506
1534
|
} = committedValuesRef.current;
|
|
1507
1535
|
const {
|
|
1508
1536
|
initialLayout
|
|
1509
|
-
} = dragState
|
|
1537
|
+
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1510
1538
|
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1511
1539
|
let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
|
|
1512
1540
|
percentage: keyboardResizeByPercentage,
|
|
@@ -1526,7 +1554,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1526
1554
|
const nextLayout = adjustLayoutByDelta({
|
|
1527
1555
|
delta,
|
|
1528
1556
|
groupSizePixels,
|
|
1529
|
-
layout: initialLayout
|
|
1557
|
+
layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
|
|
1530
1558
|
panelConstraints,
|
|
1531
1559
|
pivotIndices,
|
|
1532
1560
|
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
@@ -1669,9 +1697,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1669
1697
|
},
|
|
1670
1698
|
// CSS selectors
|
|
1671
1699
|
"data-panel-group": "",
|
|
1672
|
-
|
|
1673
|
-
"data-panel-group-
|
|
1674
|
-
"data-panel-group-id": undefined
|
|
1700
|
+
"data-panel-group-direction": direction,
|
|
1701
|
+
"data-panel-group-id": groupId
|
|
1675
1702
|
}));
|
|
1676
1703
|
}
|
|
1677
1704
|
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
@@ -1783,7 +1810,7 @@ function PanelResizeHandle({
|
|
|
1783
1810
|
stopDragging
|
|
1784
1811
|
} = panelGroupContext;
|
|
1785
1812
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1786
|
-
const isDragging = dragState
|
|
1813
|
+
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
1787
1814
|
const [isFocused, setIsFocused] = useState(false);
|
|
1788
1815
|
const [resizeHandler, setResizeHandler] = useState(null);
|
|
1789
1816
|
const stopDraggingAndBlur = useCallback(() => {
|
|
@@ -1847,13 +1874,6 @@ function PanelResizeHandle({
|
|
|
1847
1874
|
return createElement(Type, {
|
|
1848
1875
|
children,
|
|
1849
1876
|
className: classNameFromProps,
|
|
1850
|
-
// CSS selectors
|
|
1851
|
-
"data-resize-handle": "",
|
|
1852
|
-
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1853
|
-
"data-panel-group-direction": direction,
|
|
1854
|
-
"data-panel-group-id": groupId,
|
|
1855
|
-
"data-panel-resize-handle-enabled": !disabled,
|
|
1856
|
-
"data-panel-resize-handle-id": resizeHandleId,
|
|
1857
1877
|
onBlur: () => setIsFocused(false),
|
|
1858
1878
|
onFocus: () => setIsFocused(true),
|
|
1859
1879
|
onMouseDown: event => {
|
|
@@ -1883,7 +1903,14 @@ function PanelResizeHandle({
|
|
|
1883
1903
|
...style,
|
|
1884
1904
|
...styleFromProps
|
|
1885
1905
|
},
|
|
1886
|
-
tabIndex: 0
|
|
1906
|
+
tabIndex: 0,
|
|
1907
|
+
// CSS selectors
|
|
1908
|
+
"data-panel-group-direction": direction,
|
|
1909
|
+
"data-panel-group-id": groupId,
|
|
1910
|
+
"data-resize-handle": "",
|
|
1911
|
+
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1912
|
+
"data-panel-resize-handle-enabled": !disabled,
|
|
1913
|
+
"data-panel-resize-handle-id": resizeHandleId
|
|
1887
1914
|
});
|
|
1888
1915
|
}
|
|
1889
1916
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|