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
package/CHANGELOG.md
CHANGED
|
@@ -59,7 +59,7 @@ function useUniqueId(idFromParams = null) {
|
|
|
59
59
|
if (idRef.current === null) {
|
|
60
60
|
idRef.current = "" + counter++;
|
|
61
61
|
}
|
|
62
|
-
return idFromParams
|
|
62
|
+
return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function PanelWithForwardedRef({
|
|
@@ -183,9 +183,9 @@ function PanelWithForwardedRef({
|
|
|
183
183
|
},
|
|
184
184
|
// CSS selectors
|
|
185
185
|
"data-panel": "",
|
|
186
|
+
"data-panel-id": panelId,
|
|
186
187
|
// e2e test attributes
|
|
187
188
|
"data-panel-collapsible": undefined,
|
|
188
|
-
"data-panel-id": undefined,
|
|
189
189
|
"data-panel-size": undefined
|
|
190
190
|
});
|
|
191
191
|
}
|
|
@@ -213,6 +213,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
|
|
|
213
213
|
minSizePercentage = 0,
|
|
214
214
|
minSizePixels
|
|
215
215
|
} = panelConstraints;
|
|
216
|
+
const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
|
|
217
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
218
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
219
|
+
return {
|
|
220
|
+
collapsedSizePercentage: 0,
|
|
221
|
+
defaultSizePercentage,
|
|
222
|
+
maxSizePercentage: 0,
|
|
223
|
+
minSizePercentage: 0
|
|
224
|
+
};
|
|
225
|
+
}
|
|
216
226
|
if (collapsedSizePixels != null) {
|
|
217
227
|
collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
|
|
218
228
|
}
|
|
@@ -287,6 +297,16 @@ function resizePanel({
|
|
|
287
297
|
panelIndex,
|
|
288
298
|
size
|
|
289
299
|
}) {
|
|
300
|
+
const hasPixelConstraints = panelConstraints.some(({
|
|
301
|
+
collapsedSizePixels,
|
|
302
|
+
defaultSizePixels,
|
|
303
|
+
minSizePixels,
|
|
304
|
+
maxSizePixels
|
|
305
|
+
}) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
|
|
306
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
307
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
308
|
+
return 0;
|
|
309
|
+
}
|
|
290
310
|
let {
|
|
291
311
|
collapsible
|
|
292
312
|
} = panelConstraints[panelIndex];
|
|
@@ -343,7 +363,6 @@ function adjustLayoutByDelta({
|
|
|
343
363
|
} = panelConstraints[pivotIndex];
|
|
344
364
|
const {
|
|
345
365
|
collapsedSizePercentage,
|
|
346
|
-
maxSizePercentage,
|
|
347
366
|
minSizePercentage
|
|
348
367
|
} = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
|
|
349
368
|
const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
|
|
@@ -505,6 +524,7 @@ function calculateAriaValues({
|
|
|
505
524
|
|
|
506
525
|
// A panel's effective min/max sizes also need to account for other panel's sizes.
|
|
507
526
|
panelsArray.forEach((panelData, index) => {
|
|
527
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
508
528
|
const {
|
|
509
529
|
constraints
|
|
510
530
|
} = panelData;
|
|
@@ -514,14 +534,14 @@ function calculateAriaValues({
|
|
|
514
534
|
minSizePercentage,
|
|
515
535
|
minSizePixels
|
|
516
536
|
} = constraints;
|
|
517
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
537
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
518
538
|
sizePercentage: minSizePercentage,
|
|
519
539
|
sizePixels: minSizePixels
|
|
520
|
-
}, groupSizePixels)
|
|
521
|
-
const maxSize = getPercentageSizeFromMixedSizes({
|
|
540
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
541
|
+
const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
522
542
|
sizePercentage: maxSizePercentage,
|
|
523
543
|
sizePixels: maxSizePixels
|
|
524
|
-
}, groupSizePixels)
|
|
544
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
|
|
525
545
|
if (index === pivotIndices[0]) {
|
|
526
546
|
currentMinSize = minSize;
|
|
527
547
|
currentMaxSize = maxSize;
|
|
@@ -547,7 +567,7 @@ function getResizeHandleElementsForGroup(groupId) {
|
|
|
547
567
|
function getResizeHandleElementIndex(groupId, id) {
|
|
548
568
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
549
569
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
550
|
-
return index
|
|
570
|
+
return index !== null && index !== void 0 ? index : null;
|
|
551
571
|
}
|
|
552
572
|
|
|
553
573
|
function determinePivotIndices(groupId, dragHandleId) {
|
|
@@ -556,7 +576,7 @@ function determinePivotIndices(groupId, dragHandleId) {
|
|
|
556
576
|
}
|
|
557
577
|
|
|
558
578
|
function getPanelGroupElement(id) {
|
|
559
|
-
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
579
|
+
const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
560
580
|
if (element) {
|
|
561
581
|
return element;
|
|
562
582
|
}
|
|
@@ -608,11 +628,12 @@ function getResizeHandleElement(id) {
|
|
|
608
628
|
}
|
|
609
629
|
|
|
610
630
|
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
631
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
611
632
|
const handle = getResizeHandleElement(handleId);
|
|
612
633
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
613
634
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
614
|
-
const idBefore = panelsArray[index]
|
|
615
|
-
const idAfter = panelsArray[index + 1]
|
|
635
|
+
const idBefore = (_panelsArray$index$id = (_panelsArray$index = panelsArray[index]) === null || _panelsArray$index === void 0 ? void 0 : _panelsArray$index.id) !== null && _panelsArray$index$id !== void 0 ? _panelsArray$index$id : null;
|
|
636
|
+
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
616
637
|
return [idBefore, idAfter];
|
|
617
638
|
}
|
|
618
639
|
|
|
@@ -690,11 +711,12 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
690
711
|
const panelData = panelDataArray[index];
|
|
691
712
|
const size = layout[index];
|
|
692
713
|
if (size != null) {
|
|
714
|
+
var _getPercentageSizeFro;
|
|
693
715
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
694
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
716
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
695
717
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
696
718
|
sizePixels: panelData.constraints.minSizePixels
|
|
697
|
-
}, groupSizePixels)
|
|
719
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
698
720
|
let delta = 0;
|
|
699
721
|
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
700
722
|
delta = direction === "horizontal" ? width : height;
|
|
@@ -899,10 +921,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
|
|
|
899
921
|
onResize(mixedSizes, lastNotifiedMixedSizes);
|
|
900
922
|
}
|
|
901
923
|
if (collapsible && (onCollapse || onExpand)) {
|
|
902
|
-
|
|
924
|
+
var _getPercentageSizeFro;
|
|
925
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
903
926
|
sizePercentage: constraints.collapsedSizePercentage,
|
|
904
927
|
sizePixels: constraints.collapsedSizePixels
|
|
905
|
-
}, groupSizePixels)
|
|
928
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
906
929
|
const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
|
|
907
930
|
if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
|
|
908
931
|
onExpand();
|
|
@@ -1068,8 +1091,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
|
1068
1091
|
function loadPanelLayout(autoSaveId, panels, storage) {
|
|
1069
1092
|
const state = loadSerializedPanelGroupState(autoSaveId, storage);
|
|
1070
1093
|
if (state) {
|
|
1094
|
+
var _state$key;
|
|
1071
1095
|
const key = getSerializationKey(panels);
|
|
1072
|
-
return state[key]
|
|
1096
|
+
return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
|
|
1073
1097
|
}
|
|
1074
1098
|
return null;
|
|
1075
1099
|
}
|
|
@@ -1285,6 +1309,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1285
1309
|
unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
|
|
1286
1310
|
}
|
|
1287
1311
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1312
|
+
if (groupSizePixels <= 0) {
|
|
1313
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1288
1316
|
if (unsafeLayout == null) {
|
|
1289
1317
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
1290
1318
|
groupSizePixels,
|
|
@@ -1528,7 +1556,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1528
1556
|
} = committedValuesRef.current;
|
|
1529
1557
|
const {
|
|
1530
1558
|
initialLayout
|
|
1531
|
-
} = dragState
|
|
1559
|
+
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1532
1560
|
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1533
1561
|
let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
|
|
1534
1562
|
percentage: keyboardResizeByPercentage,
|
|
@@ -1548,7 +1576,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1548
1576
|
const nextLayout = adjustLayoutByDelta({
|
|
1549
1577
|
delta,
|
|
1550
1578
|
groupSizePixels,
|
|
1551
|
-
layout: initialLayout
|
|
1579
|
+
layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
|
|
1552
1580
|
panelConstraints,
|
|
1553
1581
|
pivotIndices,
|
|
1554
1582
|
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
@@ -1691,9 +1719,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1691
1719
|
},
|
|
1692
1720
|
// CSS selectors
|
|
1693
1721
|
"data-panel-group": "",
|
|
1694
|
-
|
|
1695
|
-
"data-panel-group-
|
|
1696
|
-
"data-panel-group-id": undefined
|
|
1722
|
+
"data-panel-group-direction": direction,
|
|
1723
|
+
"data-panel-group-id": groupId
|
|
1697
1724
|
}));
|
|
1698
1725
|
}
|
|
1699
1726
|
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
@@ -1805,7 +1832,7 @@ function PanelResizeHandle({
|
|
|
1805
1832
|
stopDragging
|
|
1806
1833
|
} = panelGroupContext;
|
|
1807
1834
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1808
|
-
const isDragging = dragState
|
|
1835
|
+
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
1809
1836
|
const [isFocused, setIsFocused] = useState(false);
|
|
1810
1837
|
const [resizeHandler, setResizeHandler] = useState(null);
|
|
1811
1838
|
const stopDraggingAndBlur = useCallback(() => {
|
|
@@ -1869,13 +1896,6 @@ function PanelResizeHandle({
|
|
|
1869
1896
|
return createElement(Type, {
|
|
1870
1897
|
children,
|
|
1871
1898
|
className: classNameFromProps,
|
|
1872
|
-
// CSS selectors
|
|
1873
|
-
"data-resize-handle": "",
|
|
1874
|
-
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1875
|
-
"data-panel-group-direction": direction,
|
|
1876
|
-
"data-panel-group-id": groupId,
|
|
1877
|
-
"data-panel-resize-handle-enabled": !disabled,
|
|
1878
|
-
"data-panel-resize-handle-id": resizeHandleId,
|
|
1879
1899
|
onBlur: () => setIsFocused(false),
|
|
1880
1900
|
onFocus: () => setIsFocused(true),
|
|
1881
1901
|
onMouseDown: event => {
|
|
@@ -1905,7 +1925,14 @@ function PanelResizeHandle({
|
|
|
1905
1925
|
...style,
|
|
1906
1926
|
...styleFromProps
|
|
1907
1927
|
},
|
|
1908
|
-
tabIndex: 0
|
|
1928
|
+
tabIndex: 0,
|
|
1929
|
+
// CSS selectors
|
|
1930
|
+
"data-panel-group-direction": direction,
|
|
1931
|
+
"data-panel-group-id": groupId,
|
|
1932
|
+
"data-resize-handle": "",
|
|
1933
|
+
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
1934
|
+
"data-panel-resize-handle-enabled": !disabled,
|
|
1935
|
+
"data-panel-resize-handle-id": resizeHandleId
|
|
1909
1936
|
});
|
|
1910
1937
|
}
|
|
1911
1938
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
@@ -59,7 +59,7 @@ function useUniqueId(idFromParams = null) {
|
|
|
59
59
|
if (idRef.current === null) {
|
|
60
60
|
idRef.current = "" + counter++;
|
|
61
61
|
}
|
|
62
|
-
return idFromParams
|
|
62
|
+
return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function PanelWithForwardedRef({
|
|
@@ -189,9 +189,9 @@ function PanelWithForwardedRef({
|
|
|
189
189
|
},
|
|
190
190
|
// CSS selectors
|
|
191
191
|
"data-panel": "",
|
|
192
|
+
"data-panel-id": panelId,
|
|
192
193
|
// e2e test attributes
|
|
193
194
|
"data-panel-collapsible": collapsible || undefined ,
|
|
194
|
-
"data-panel-id": panelId ,
|
|
195
195
|
"data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
|
|
196
196
|
});
|
|
197
197
|
}
|
|
@@ -219,6 +219,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
|
|
|
219
219
|
minSizePercentage = 0,
|
|
220
220
|
minSizePixels
|
|
221
221
|
} = panelConstraints;
|
|
222
|
+
const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
|
|
223
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
224
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
225
|
+
return {
|
|
226
|
+
collapsedSizePercentage: 0,
|
|
227
|
+
defaultSizePercentage,
|
|
228
|
+
maxSizePercentage: 0,
|
|
229
|
+
minSizePercentage: 0
|
|
230
|
+
};
|
|
231
|
+
}
|
|
222
232
|
if (collapsedSizePixels != null) {
|
|
223
233
|
collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
|
|
224
234
|
}
|
|
@@ -293,6 +303,16 @@ function resizePanel({
|
|
|
293
303
|
panelIndex,
|
|
294
304
|
size
|
|
295
305
|
}) {
|
|
306
|
+
const hasPixelConstraints = panelConstraints.some(({
|
|
307
|
+
collapsedSizePixels,
|
|
308
|
+
defaultSizePixels,
|
|
309
|
+
minSizePixels,
|
|
310
|
+
maxSizePixels
|
|
311
|
+
}) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
|
|
312
|
+
if (hasPixelConstraints && groupSizePixels <= 0) {
|
|
313
|
+
console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
|
|
314
|
+
return 0;
|
|
315
|
+
}
|
|
296
316
|
let {
|
|
297
317
|
collapsible
|
|
298
318
|
} = panelConstraints[panelIndex];
|
|
@@ -349,7 +369,6 @@ function adjustLayoutByDelta({
|
|
|
349
369
|
} = panelConstraints[pivotIndex];
|
|
350
370
|
const {
|
|
351
371
|
collapsedSizePercentage,
|
|
352
|
-
maxSizePercentage,
|
|
353
372
|
minSizePercentage
|
|
354
373
|
} = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
|
|
355
374
|
const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
|
|
@@ -511,6 +530,7 @@ function calculateAriaValues({
|
|
|
511
530
|
|
|
512
531
|
// A panel's effective min/max sizes also need to account for other panel's sizes.
|
|
513
532
|
panelsArray.forEach((panelData, index) => {
|
|
533
|
+
var _getPercentageSizeFro, _getPercentageSizeFro2;
|
|
514
534
|
const {
|
|
515
535
|
constraints
|
|
516
536
|
} = panelData;
|
|
@@ -520,14 +540,14 @@ function calculateAriaValues({
|
|
|
520
540
|
minSizePercentage,
|
|
521
541
|
minSizePixels
|
|
522
542
|
} = constraints;
|
|
523
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
543
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
524
544
|
sizePercentage: minSizePercentage,
|
|
525
545
|
sizePixels: minSizePixels
|
|
526
|
-
}, groupSizePixels)
|
|
527
|
-
const maxSize = getPercentageSizeFromMixedSizes({
|
|
546
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
547
|
+
const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
|
|
528
548
|
sizePercentage: maxSizePercentage,
|
|
529
549
|
sizePixels: maxSizePixels
|
|
530
|
-
}, groupSizePixels)
|
|
550
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
|
|
531
551
|
if (index === pivotIndices[0]) {
|
|
532
552
|
currentMinSize = minSize;
|
|
533
553
|
currentMaxSize = maxSize;
|
|
@@ -553,7 +573,7 @@ function getResizeHandleElementsForGroup(groupId) {
|
|
|
553
573
|
function getResizeHandleElementIndex(groupId, id) {
|
|
554
574
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
555
575
|
const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
556
|
-
return index
|
|
576
|
+
return index !== null && index !== void 0 ? index : null;
|
|
557
577
|
}
|
|
558
578
|
|
|
559
579
|
function determinePivotIndices(groupId, dragHandleId) {
|
|
@@ -562,7 +582,7 @@ function determinePivotIndices(groupId, dragHandleId) {
|
|
|
562
582
|
}
|
|
563
583
|
|
|
564
584
|
function getPanelGroupElement(id) {
|
|
565
|
-
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
585
|
+
const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
566
586
|
if (element) {
|
|
567
587
|
return element;
|
|
568
588
|
}
|
|
@@ -614,11 +634,12 @@ function getResizeHandleElement(id) {
|
|
|
614
634
|
}
|
|
615
635
|
|
|
616
636
|
function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
|
|
637
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
617
638
|
const handle = getResizeHandleElement(handleId);
|
|
618
639
|
const handles = getResizeHandleElementsForGroup(groupId);
|
|
619
640
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
620
|
-
const idBefore = panelsArray[index]
|
|
621
|
-
const idAfter = panelsArray[index + 1]
|
|
641
|
+
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;
|
|
642
|
+
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
|
|
622
643
|
return [idBefore, idAfter];
|
|
623
644
|
}
|
|
624
645
|
|
|
@@ -706,11 +727,12 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
706
727
|
const panelData = panelDataArray[index];
|
|
707
728
|
const size = layout[index];
|
|
708
729
|
if (size != null) {
|
|
730
|
+
var _getPercentageSizeFro;
|
|
709
731
|
const groupSizePixels = getAvailableGroupSizePixels(groupId);
|
|
710
|
-
const minSize = getPercentageSizeFromMixedSizes({
|
|
732
|
+
const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
711
733
|
sizePercentage: panelData.constraints.minSizePercentage,
|
|
712
734
|
sizePixels: panelData.constraints.minSizePixels
|
|
713
|
-
}, groupSizePixels)
|
|
735
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
714
736
|
let delta = 0;
|
|
715
737
|
if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
|
|
716
738
|
delta = direction === "horizontal" ? width : height;
|
|
@@ -915,10 +937,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
|
|
|
915
937
|
onResize(mixedSizes, lastNotifiedMixedSizes);
|
|
916
938
|
}
|
|
917
939
|
if (collapsible && (onCollapse || onExpand)) {
|
|
918
|
-
|
|
940
|
+
var _getPercentageSizeFro;
|
|
941
|
+
const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
|
|
919
942
|
sizePercentage: constraints.collapsedSizePercentage,
|
|
920
943
|
sizePixels: constraints.collapsedSizePixels
|
|
921
|
-
}, groupSizePixels)
|
|
944
|
+
}, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
|
|
922
945
|
const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
|
|
923
946
|
if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
|
|
924
947
|
onExpand();
|
|
@@ -1084,8 +1107,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
|
1084
1107
|
function loadPanelLayout(autoSaveId, panels, storage) {
|
|
1085
1108
|
const state = loadSerializedPanelGroupState(autoSaveId, storage);
|
|
1086
1109
|
if (state) {
|
|
1110
|
+
var _state$key;
|
|
1087
1111
|
const key = getSerializationKey(panels);
|
|
1088
|
-
return state[key]
|
|
1112
|
+
return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
|
|
1089
1113
|
}
|
|
1090
1114
|
return null;
|
|
1091
1115
|
}
|
|
@@ -1378,6 +1402,10 @@ function PanelGroupWithForwardedRef({
|
|
|
1378
1402
|
unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
|
|
1379
1403
|
}
|
|
1380
1404
|
const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
|
|
1405
|
+
if (groupSizePixels <= 0) {
|
|
1406
|
+
// Wait until the group has rendered a non-zero size before computing layout.
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1381
1409
|
if (unsafeLayout == null) {
|
|
1382
1410
|
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
1383
1411
|
groupSizePixels,
|
|
@@ -1663,7 +1691,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1663
1691
|
} = committedValuesRef.current;
|
|
1664
1692
|
const {
|
|
1665
1693
|
initialLayout
|
|
1666
|
-
} = dragState
|
|
1694
|
+
} = dragState !== null && dragState !== void 0 ? dragState : {};
|
|
1667
1695
|
const pivotIndices = determinePivotIndices(groupId, dragHandleId);
|
|
1668
1696
|
let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
|
|
1669
1697
|
percentage: keyboardResizeByPercentage,
|
|
@@ -1683,7 +1711,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1683
1711
|
const nextLayout = adjustLayoutByDelta({
|
|
1684
1712
|
delta,
|
|
1685
1713
|
groupSizePixels,
|
|
1686
|
-
layout: initialLayout
|
|
1714
|
+
layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
|
|
1687
1715
|
panelConstraints,
|
|
1688
1716
|
pivotIndices,
|
|
1689
1717
|
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
@@ -1826,9 +1854,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1826
1854
|
},
|
|
1827
1855
|
// CSS selectors
|
|
1828
1856
|
"data-panel-group": "",
|
|
1829
|
-
|
|
1830
|
-
"data-panel-group-
|
|
1831
|
-
"data-panel-group-id": groupId
|
|
1857
|
+
"data-panel-group-direction": direction,
|
|
1858
|
+
"data-panel-group-id": groupId
|
|
1832
1859
|
}));
|
|
1833
1860
|
}
|
|
1834
1861
|
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
@@ -1940,7 +1967,7 @@ function PanelResizeHandle({
|
|
|
1940
1967
|
stopDragging
|
|
1941
1968
|
} = panelGroupContext;
|
|
1942
1969
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
1943
|
-
const isDragging = dragState
|
|
1970
|
+
const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
|
|
1944
1971
|
const [isFocused, setIsFocused] = useState(false);
|
|
1945
1972
|
const [resizeHandler, setResizeHandler] = useState(null);
|
|
1946
1973
|
const stopDraggingAndBlur = useCallback(() => {
|
|
@@ -2004,13 +2031,6 @@ function PanelResizeHandle({
|
|
|
2004
2031
|
return createElement(Type, {
|
|
2005
2032
|
children,
|
|
2006
2033
|
className: classNameFromProps,
|
|
2007
|
-
// CSS selectors
|
|
2008
|
-
"data-resize-handle": "",
|
|
2009
|
-
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
2010
|
-
"data-panel-group-direction": direction,
|
|
2011
|
-
"data-panel-group-id": groupId,
|
|
2012
|
-
"data-panel-resize-handle-enabled": !disabled,
|
|
2013
|
-
"data-panel-resize-handle-id": resizeHandleId,
|
|
2014
2034
|
onBlur: () => setIsFocused(false),
|
|
2015
2035
|
onFocus: () => setIsFocused(true),
|
|
2016
2036
|
onMouseDown: event => {
|
|
@@ -2040,7 +2060,14 @@ function PanelResizeHandle({
|
|
|
2040
2060
|
...style,
|
|
2041
2061
|
...styleFromProps
|
|
2042
2062
|
},
|
|
2043
|
-
tabIndex: 0
|
|
2063
|
+
tabIndex: 0,
|
|
2064
|
+
// CSS selectors
|
|
2065
|
+
"data-panel-group-direction": direction,
|
|
2066
|
+
"data-panel-group-id": groupId,
|
|
2067
|
+
"data-resize-handle": "",
|
|
2068
|
+
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
2069
|
+
"data-panel-resize-handle-enabled": !disabled,
|
|
2070
|
+
"data-panel-resize-handle-id": resizeHandleId
|
|
2044
2071
|
});
|
|
2045
2072
|
}
|
|
2046
2073
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|