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
|
@@ -35,7 +35,7 @@ function useUniqueId(idFromParams = null) {
|
|
|
35
35
|
if (idRef.current === null) {
|
|
36
36
|
idRef.current = "" + counter++;
|
|
37
37
|
}
|
|
38
|
-
return idFromParams
|
|
38
|
+
return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function PanelWithForwardedRef({
|
|
@@ -165,9 +165,9 @@ function PanelWithForwardedRef({
|
|
|
165
165
|
},
|
|
166
166
|
// CSS selectors
|
|
167
167
|
"data-panel": "",
|
|
168
|
+
"data-panel-id": panelId,
|
|
168
169
|
// e2e test attributes
|
|
169
170
|
"data-panel-collapsible": collapsible || undefined ,
|
|
170
|
-
"data-panel-id": panelId ,
|
|
171
171
|
"data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
|
|
172
172
|
});
|
|
173
173
|
}
|
|
@@ -195,6 +195,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
|
|
|
195
195
|
minSizePercentage = 0,
|
|
196
196
|
minSizePixels
|
|
197
197
|
} = panelConstraints;
|
|
198
|
+
const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
|
|
199
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
200
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
201
|
+
return {
|
|
202
|
+
collapsedSizePercentage: 0,
|
|
203
|
+
defaultSizePercentage,
|
|
204
|
+
maxSizePercentage: 0,
|
|
205
|
+
minSizePercentage: 0
|
|
206
|
+
};
|
|
207
|
+
}
|
|
198
208
|
if (collapsedSizePixels != null) {
|
|
199
209
|
collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
|
|
200
210
|
}
|
|
@@ -269,6 +279,16 @@ function resizePanel({
|
|
|
269
279
|
panelIndex,
|
|
270
280
|
size
|
|
271
281
|
}) {
|
|
282
|
+
const hasPixelConstraints = panelConstraints.some(({
|
|
283
|
+
collapsedSizePixels,
|
|
284
|
+
defaultSizePixels,
|
|
285
|
+
minSizePixels,
|
|
286
|
+
maxSizePixels
|
|
287
|
+
}) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
|
|
288
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
289
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
290
|
+
return 0;
|
|
291
|
+
}
|
|
272
292
|
let {
|
|
273
293
|
collapsible
|
|
274
294
|
} = panelConstraints[panelIndex];
|
|
@@ -325,7 +345,6 @@ function adjustLayoutByDelta({
|
|
|
325
345
|
} = panelConstraints[pivotIndex];
|
|
326
346
|
const {
|
|
327
347
|
collapsedSizePercentage,
|
|
328
|
-
maxSizePercentage,
|
|
329
348
|
minSizePercentage
|
|
330
349
|
} = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
|
|
331
350
|
const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
|
|
@@ -487,6 +506,7 @@ function calculateAriaValues({
|
|
|
487
506
|
|
|
488
507
|
// A panel's effective min/max sizes also need to account for other panel's sizes.
|
|
489
508
|
panelsArray.forEach((panelData, index) => {
|
|
509
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
490
510
|
const {
|
|
491
511
|
constraints
|
|
492
512
|
} = panelData;
|
|
@@ -496,14 +516,14 @@ function calculateAriaValues({
|
|
|
496
516
|
minSizePercentage,
|
|
497
517
|
minSizePixels
|
|
498
518
|
} = constraints;
|
|
499
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
519
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
500
520
|
sizePercentage: minSizePercentage,
|
|
501
521
|
sizePixels: minSizePixels
|
|
502
|
-
}, groupSizePixels)
|
|
503
|
-
const maxSize = getPercentageSizeFromMixedSizes({
|
|
522
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
523
|
+
const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
504
524
|
sizePercentage: maxSizePercentage,
|
|
505
525
|
sizePixels: maxSizePixels
|
|
506
|
-
}, groupSizePixels)
|
|
526
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
|
|
507
527
|
if (index === pivotIndices[0]) {
|
|
508
528
|
currentMinSize = minSize;
|
|
509
529
|
currentMaxSize = maxSize;
|
|
@@ -529,7 +549,7 @@ function getResizeHandleElementsForGroup(groupId) {
|
|
|
529
549
|
function getResizeHandleElementIndex(groupId, id) {
|
|
530
550
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
531
551
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
532
|
-
return index
|
|
552
|
+
return index !== null && index !== void 0 ? index : null;
|
|
533
553
|
}
|
|
534
554
|
|
|
535
555
|
function determinePivotIndices(groupId, dragHandleId) {
|
|
@@ -538,7 +558,7 @@ function determinePivotIndices(groupId, dragHandleId) {
|
|
|
538
558
|
}
|
|
539
559
|
|
|
540
560
|
function getPanelGroupElement(id) {
|
|
541
|
-
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
561
|
+
const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
542
562
|
if (element) {
|
|
543
563
|
return element;
|
|
544
564
|
}
|
|
@@ -590,11 +610,12 @@ function getResizeHandleElement(id) {
|
|
|
590
610
|
}
|
|
591
611
|
|
|
592
612
|
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
613
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
593
614
|
const handle = getResizeHandleElement(handleId);
|
|
594
615
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
595
616
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
596
|
-
const idBefore = panelsArray[index]
|
|
597
|
-
const idAfter = panelsArray[index + 1]
|
|
617
|
+
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;
|
|
618
|
+
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
598
619
|
return [idBefore, idAfter];
|
|
599
620
|
}
|
|
600
621
|
|
|
@@ -682,11 +703,12 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
682
703
|
const panelData = panelDataArray[index];
|
|
683
704
|
const size = layout[index];
|
|
684
705
|
if (size != null) {
|
|
706
|
+
var _getPercentageSizeFro;
|
|
685
707
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
686
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
708
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
687
709
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
688
710
|
sizePixels: panelData.constraints.minSizePixels
|
|
689
|
-
}, groupSizePixels)
|
|
711
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
690
712
|
let delta = 0;
|
|
691
713
|
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
692
714
|
delta = direction === "horizontal" ? width : height;
|
|
@@ -891,10 +913,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
|
|
|
891
913
|
onResize(mixedSizes, lastNotifiedMixedSizes);
|
|
892
914
|
}
|
|
893
915
|
if (collapsible && (onCollapse || onExpand)) {
|
|
894
|
-
|
|
916
|
+
var _getPercentageSizeFro;
|
|
917
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
895
918
|
sizePercentage: constraints.collapsedSizePercentage,
|
|
896
919
|
sizePixels: constraints.collapsedSizePixels
|
|
897
|
-
}, groupSizePixels)
|
|
920
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
898
921
|
const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
|
|
899
922
|
if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
|
|
900
923
|
onExpand();
|
|
@@ -1060,8 +1083,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
|
1060
1083
|
function loadPanelLayout(autoSaveId, panels, storage) {
|
|
1061
1084
|
const state = loadSerializedPanelGroupState(autoSaveId, storage);
|
|
1062
1085
|
if (state) {
|
|
1086
|
+
var _state$key;
|
|
1063
1087
|
const key = getSerializationKey(panels);
|
|
1064
|
-
return state[key]
|
|
1088
|
+
return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
|
|
1065
1089
|
}
|
|
1066
1090
|
return null;
|
|
1067
1091
|
}
|
|
@@ -1354,6 +1378,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1354
1378
|
unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
|
|
1355
1379
|
}
|
|
1356
1380
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1381
|
+
if (groupSizePixels <= 0) {
|
|
1382
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1357
1385
|
if (unsafeLayout == null) {
|
|
1358
1386
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
1359
1387
|
groupSizePixels,
|
|
@@ -1639,7 +1667,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1639
1667
|
} = committedValuesRef.current;
|
|
1640
1668
|
const {
|
|
1641
1669
|
initialLayout
|
|
1642
|
-
} = dragState
|
|
1670
|
+
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1643
1671
|
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1644
1672
|
let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
|
|
1645
1673
|
percentage: keyboardResizeByPercentage,
|
|
@@ -1659,7 +1687,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1659
1687
|
const nextLayout = adjustLayoutByDelta({
|
|
1660
1688
|
delta,
|
|
1661
1689
|
groupSizePixels,
|
|
1662
|
-
layout: initialLayout
|
|
1690
|
+
layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
|
|
1663
1691
|
panelConstraints,
|
|
1664
1692
|
pivotIndices,
|
|
1665
1693
|
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
@@ -1802,9 +1830,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1802
1830
|
},
|
|
1803
1831
|
// CSS selectors
|
|
1804
1832
|
"data-panel-group": "",
|
|
1805
|
-
|
|
1806
|
-
"data-panel-group-
|
|
1807
|
-
"data-panel-group-id": groupId
|
|
1833
|
+
"data-panel-group-direction": direction,
|
|
1834
|
+
"data-panel-group-id": groupId
|
|
1808
1835
|
}));
|
|
1809
1836
|
}
|
|
1810
1837
|
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
@@ -1916,7 +1943,7 @@ function PanelResizeHandle({
|
|
|
1916
1943
|
stopDragging
|
|
1917
1944
|
} = panelGroupContext;
|
|
1918
1945
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1919
|
-
const isDragging = dragState
|
|
1946
|
+
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
1920
1947
|
const [isFocused, setIsFocused] = useState(false);
|
|
1921
1948
|
const [resizeHandler, setResizeHandler] = useState(null);
|
|
1922
1949
|
const stopDraggingAndBlur = useCallback(() => {
|
|
@@ -1980,13 +2007,6 @@ function PanelResizeHandle({
|
|
|
1980
2007
|
return createElement(Type, {
|
|
1981
2008
|
children,
|
|
1982
2009
|
className: classNameFromProps,
|
|
1983
|
-
// CSS selectors
|
|
1984
|
-
"data-resize-handle": "",
|
|
1985
|
-
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1986
|
-
"data-panel-group-direction": direction,
|
|
1987
|
-
"data-panel-group-id": groupId,
|
|
1988
|
-
"data-panel-resize-handle-enabled": !disabled,
|
|
1989
|
-
"data-panel-resize-handle-id": resizeHandleId,
|
|
1990
2010
|
onBlur: () => setIsFocused(false),
|
|
1991
2011
|
onFocus: () => setIsFocused(true),
|
|
1992
2012
|
onMouseDown: event => {
|
|
@@ -2016,7 +2036,14 @@ function PanelResizeHandle({
|
|
|
2016
2036
|
...style,
|
|
2017
2037
|
...styleFromProps
|
|
2018
2038
|
},
|
|
2019
|
-
tabIndex: 0
|
|
2039
|
+
tabIndex: 0,
|
|
2040
|
+
// CSS selectors
|
|
2041
|
+
"data-panel-group-direction": direction,
|
|
2042
|
+
"data-panel-group-id": groupId,
|
|
2043
|
+
"data-resize-handle": "",
|
|
2044
|
+
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
2045
|
+
"data-panel-resize-handle-enabled": !disabled,
|
|
2046
|
+
"data-panel-resize-handle-id": resizeHandleId
|
|
2020
2047
|
});
|
|
2021
2048
|
}
|
|
2022
2049
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
@@ -35,7 +35,7 @@ function useUniqueId(idFromParams = null) {
|
|
|
35
35
|
if (idRef.current === null) {
|
|
36
36
|
idRef.current = "" + counter++;
|
|
37
37
|
}
|
|
38
|
-
return idFromParams
|
|
38
|
+
return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function PanelWithForwardedRef({
|
|
@@ -159,9 +159,9 @@ function PanelWithForwardedRef({
|
|
|
159
159
|
},
|
|
160
160
|
// CSS selectors
|
|
161
161
|
"data-panel": "",
|
|
162
|
+
"data-panel-id": panelId,
|
|
162
163
|
// e2e test attributes
|
|
163
164
|
"data-panel-collapsible": undefined,
|
|
164
|
-
"data-panel-id": undefined,
|
|
165
165
|
"data-panel-size": undefined
|
|
166
166
|
});
|
|
167
167
|
}
|
|
@@ -189,6 +189,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
|
|
|
189
189
|
minSizePercentage = 0,
|
|
190
190
|
minSizePixels
|
|
191
191
|
} = panelConstraints;
|
|
192
|
+
const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
|
|
193
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
194
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
195
|
+
return {
|
|
196
|
+
collapsedSizePercentage: 0,
|
|
197
|
+
defaultSizePercentage,
|
|
198
|
+
maxSizePercentage: 0,
|
|
199
|
+
minSizePercentage: 0
|
|
200
|
+
};
|
|
201
|
+
}
|
|
192
202
|
if (collapsedSizePixels != null) {
|
|
193
203
|
collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
|
|
194
204
|
}
|
|
@@ -263,6 +273,16 @@ function resizePanel({
|
|
|
263
273
|
panelIndex,
|
|
264
274
|
size
|
|
265
275
|
}) {
|
|
276
|
+
const hasPixelConstraints = panelConstraints.some(({
|
|
277
|
+
collapsedSizePixels,
|
|
278
|
+
defaultSizePixels,
|
|
279
|
+
minSizePixels,
|
|
280
|
+
maxSizePixels
|
|
281
|
+
}) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
|
|
282
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
283
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
284
|
+
return 0;
|
|
285
|
+
}
|
|
266
286
|
let {
|
|
267
287
|
collapsible
|
|
268
288
|
} = panelConstraints[panelIndex];
|
|
@@ -319,7 +339,6 @@ function adjustLayoutByDelta({
|
|
|
319
339
|
} = panelConstraints[pivotIndex];
|
|
320
340
|
const {
|
|
321
341
|
collapsedSizePercentage,
|
|
322
|
-
maxSizePercentage,
|
|
323
342
|
minSizePercentage
|
|
324
343
|
} = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
|
|
325
344
|
const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
|
|
@@ -481,6 +500,7 @@ function calculateAriaValues({
|
|
|
481
500
|
|
|
482
501
|
// A panel's effective min/max sizes also need to account for other panel's sizes.
|
|
483
502
|
panelsArray.forEach((panelData, index) => {
|
|
503
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
484
504
|
const {
|
|
485
505
|
constraints
|
|
486
506
|
} = panelData;
|
|
@@ -490,14 +510,14 @@ function calculateAriaValues({
|
|
|
490
510
|
minSizePercentage,
|
|
491
511
|
minSizePixels
|
|
492
512
|
} = constraints;
|
|
493
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
513
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
494
514
|
sizePercentage: minSizePercentage,
|
|
495
515
|
sizePixels: minSizePixels
|
|
496
|
-
}, groupSizePixels)
|
|
497
|
-
const maxSize = getPercentageSizeFromMixedSizes({
|
|
516
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
517
|
+
const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
498
518
|
sizePercentage: maxSizePercentage,
|
|
499
519
|
sizePixels: maxSizePixels
|
|
500
|
-
}, groupSizePixels)
|
|
520
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
|
|
501
521
|
if (index === pivotIndices[0]) {
|
|
502
522
|
currentMinSize = minSize;
|
|
503
523
|
currentMaxSize = maxSize;
|
|
@@ -523,7 +543,7 @@ function getResizeHandleElementsForGroup(groupId) {
|
|
|
523
543
|
function getResizeHandleElementIndex(groupId, id) {
|
|
524
544
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
525
545
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
526
|
-
return index
|
|
546
|
+
return index !== null && index !== void 0 ? index : null;
|
|
527
547
|
}
|
|
528
548
|
|
|
529
549
|
function determinePivotIndices(groupId, dragHandleId) {
|
|
@@ -532,7 +552,7 @@ function determinePivotIndices(groupId, dragHandleId) {
|
|
|
532
552
|
}
|
|
533
553
|
|
|
534
554
|
function getPanelGroupElement(id) {
|
|
535
|
-
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
555
|
+
const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
536
556
|
if (element) {
|
|
537
557
|
return element;
|
|
538
558
|
}
|
|
@@ -584,11 +604,12 @@ function getResizeHandleElement(id) {
|
|
|
584
604
|
}
|
|
585
605
|
|
|
586
606
|
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
607
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
587
608
|
const handle = getResizeHandleElement(handleId);
|
|
588
609
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
589
610
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
590
|
-
const idBefore = panelsArray[index]
|
|
591
|
-
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;
|
|
592
613
|
return [idBefore, idAfter];
|
|
593
614
|
}
|
|
594
615
|
|
|
@@ -666,11 +687,12 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
666
687
|
const panelData = panelDataArray[index];
|
|
667
688
|
const size = layout[index];
|
|
668
689
|
if (size != null) {
|
|
690
|
+
var _getPercentageSizeFro;
|
|
669
691
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
670
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
692
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
671
693
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
672
694
|
sizePixels: panelData.constraints.minSizePixels
|
|
673
|
-
}, groupSizePixels)
|
|
695
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
674
696
|
let delta = 0;
|
|
675
697
|
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
676
698
|
delta = direction === "horizontal" ? width : height;
|
|
@@ -875,10 +897,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
|
|
|
875
897
|
onResize(mixedSizes, lastNotifiedMixedSizes);
|
|
876
898
|
}
|
|
877
899
|
if (collapsible && (onCollapse || onExpand)) {
|
|
878
|
-
|
|
900
|
+
var _getPercentageSizeFro;
|
|
901
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
879
902
|
sizePercentage: constraints.collapsedSizePercentage,
|
|
880
903
|
sizePixels: constraints.collapsedSizePixels
|
|
881
|
-
}, groupSizePixels)
|
|
904
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
882
905
|
const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
|
|
883
906
|
if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
|
|
884
907
|
onExpand();
|
|
@@ -1044,8 +1067,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
|
1044
1067
|
function loadPanelLayout(autoSaveId, panels, storage) {
|
|
1045
1068
|
const state = loadSerializedPanelGroupState(autoSaveId, storage);
|
|
1046
1069
|
if (state) {
|
|
1070
|
+
var _state$key;
|
|
1047
1071
|
const key = getSerializationKey(panels);
|
|
1048
|
-
return state[key]
|
|
1072
|
+
return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
|
|
1049
1073
|
}
|
|
1050
1074
|
return null;
|
|
1051
1075
|
}
|
|
@@ -1261,6 +1285,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1261
1285
|
unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
|
|
1262
1286
|
}
|
|
1263
1287
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1288
|
+
if (groupSizePixels <= 0) {
|
|
1289
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1264
1292
|
if (unsafeLayout == null) {
|
|
1265
1293
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
1266
1294
|
groupSizePixels,
|
|
@@ -1504,7 +1532,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1504
1532
|
} = committedValuesRef.current;
|
|
1505
1533
|
const {
|
|
1506
1534
|
initialLayout
|
|
1507
|
-
} = dragState
|
|
1535
|
+
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1508
1536
|
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1509
1537
|
let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
|
|
1510
1538
|
percentage: keyboardResizeByPercentage,
|
|
@@ -1524,7 +1552,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1524
1552
|
const nextLayout = adjustLayoutByDelta({
|
|
1525
1553
|
delta,
|
|
1526
1554
|
groupSizePixels,
|
|
1527
|
-
layout: initialLayout
|
|
1555
|
+
layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
|
|
1528
1556
|
panelConstraints,
|
|
1529
1557
|
pivotIndices,
|
|
1530
1558
|
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
@@ -1667,9 +1695,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1667
1695
|
},
|
|
1668
1696
|
// CSS selectors
|
|
1669
1697
|
"data-panel-group": "",
|
|
1670
|
-
|
|
1671
|
-
"data-panel-group-
|
|
1672
|
-
"data-panel-group-id": undefined
|
|
1698
|
+
"data-panel-group-direction": direction,
|
|
1699
|
+
"data-panel-group-id": groupId
|
|
1673
1700
|
}));
|
|
1674
1701
|
}
|
|
1675
1702
|
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
@@ -1781,7 +1808,7 @@ function PanelResizeHandle({
|
|
|
1781
1808
|
stopDragging
|
|
1782
1809
|
} = panelGroupContext;
|
|
1783
1810
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1784
|
-
const isDragging = dragState
|
|
1811
|
+
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
1785
1812
|
const [isFocused, setIsFocused] = useState(false);
|
|
1786
1813
|
const [resizeHandler, setResizeHandler] = useState(null);
|
|
1787
1814
|
const stopDraggingAndBlur = useCallback(() => {
|
|
@@ -1845,13 +1872,6 @@ function PanelResizeHandle({
|
|
|
1845
1872
|
return createElement(Type, {
|
|
1846
1873
|
children,
|
|
1847
1874
|
className: classNameFromProps,
|
|
1848
|
-
// CSS selectors
|
|
1849
|
-
"data-resize-handle": "",
|
|
1850
|
-
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1851
|
-
"data-panel-group-direction": direction,
|
|
1852
|
-
"data-panel-group-id": groupId,
|
|
1853
|
-
"data-panel-resize-handle-enabled": !disabled,
|
|
1854
|
-
"data-panel-resize-handle-id": resizeHandleId,
|
|
1855
1875
|
onBlur: () => setIsFocused(false),
|
|
1856
1876
|
onFocus: () => setIsFocused(true),
|
|
1857
1877
|
onMouseDown: event => {
|
|
@@ -1881,7 +1901,14 @@ function PanelResizeHandle({
|
|
|
1881
1901
|
...style,
|
|
1882
1902
|
...styleFromProps
|
|
1883
1903
|
},
|
|
1884
|
-
tabIndex: 0
|
|
1904
|
+
tabIndex: 0,
|
|
1905
|
+
// CSS selectors
|
|
1906
|
+
"data-panel-group-direction": direction,
|
|
1907
|
+
"data-panel-group-id": groupId,
|
|
1908
|
+
"data-resize-handle": "",
|
|
1909
|
+
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1910
|
+
"data-panel-resize-handle-enabled": !disabled,
|
|
1911
|
+
"data-panel-resize-handle-id": resizeHandleId
|
|
1885
1912
|
});
|
|
1886
1913
|
}
|
|
1887
1914
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|