react-resizable-panels 0.0.48 → 0.0.50
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 +6 -0
- package/dist/react-resizable-panels.cjs.js +4 -12
- package/dist/react-resizable-panels.development.cjs.js +8 -4
- package/dist/react-resizable-panels.development.esm.js +8 -4
- package/dist/react-resizable-panels.esm.js +4 -12
- package/package.json +1 -1
- package/src/PanelGroup.ts +15 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.50
|
|
4
|
+
* Improved panel size validation in `PanelGroup`.
|
|
5
|
+
|
|
6
|
+
## 0.0.49
|
|
7
|
+
* Improved development warnings and props validation checks in `PanelGroup`.
|
|
8
|
+
|
|
3
9
|
## 0.0.48
|
|
4
10
|
* [148](https://github.com/bvaughn/react-resizable-panels/pull/148): Build release bundle with Preconstruct
|
|
5
11
|
|
|
@@ -762,13 +762,6 @@ function savePanelGroupLayout(autoSaveId, panels, sizes, storage) {
|
|
|
762
762
|
}
|
|
763
763
|
}
|
|
764
764
|
|
|
765
|
-
function isServerRendering() {
|
|
766
|
-
try {
|
|
767
|
-
return typeof window === undefined;
|
|
768
|
-
} catch (error) {}
|
|
769
|
-
return true;
|
|
770
|
-
}
|
|
771
|
-
|
|
772
765
|
const debounceMap = {};
|
|
773
766
|
|
|
774
767
|
// PanelGroup might be rendering in a server-side environment where localStorage is not available
|
|
@@ -959,9 +952,11 @@ function PanelGroupWithForwardedRef({
|
|
|
959
952
|
}
|
|
960
953
|
});
|
|
961
954
|
if (totalDefaultSize > 100) {
|
|
962
|
-
throw new Error(`
|
|
955
|
+
throw new Error(`Default panel sizes cannot exceed 100%`);
|
|
956
|
+
} else if (panelsArray.length > 1 && panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
|
|
957
|
+
throw new Error(`Invalid default sizes specified for panels`);
|
|
963
958
|
} else if (totalMinSize > 100) {
|
|
964
|
-
throw new Error(`
|
|
959
|
+
throw new Error(`Minimum panel sizes cannot exceed 100%`);
|
|
965
960
|
}
|
|
966
961
|
setSizes(panelsArray.map(panel => {
|
|
967
962
|
if (panel.current.defaultSize === null) {
|
|
@@ -995,9 +990,6 @@ function PanelGroupWithForwardedRef({
|
|
|
995
990
|
// This includes server rendering.
|
|
996
991
|
// At this point the best we can do is render everything with the same size.
|
|
997
992
|
if (panels.size === 0) {
|
|
998
|
-
if (isServerRendering() && defaultSize == null) {
|
|
999
|
-
console.warn(`WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`);
|
|
1000
|
-
}
|
|
1001
993
|
return {
|
|
1002
994
|
flexBasis: 0,
|
|
1003
995
|
flexGrow: defaultSize != null ? defaultSize : undefined,
|
|
@@ -959,9 +959,11 @@ function PanelGroupWithForwardedRef({
|
|
|
959
959
|
}
|
|
960
960
|
});
|
|
961
961
|
if (totalDefaultSize > 100) {
|
|
962
|
-
throw new Error(`
|
|
962
|
+
throw new Error(`Default panel sizes cannot exceed 100%`);
|
|
963
|
+
} else if (panelsArray.length > 1 && panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
|
|
964
|
+
throw new Error(`Invalid default sizes specified for panels`);
|
|
963
965
|
} else if (totalMinSize > 100) {
|
|
964
|
-
throw new Error(`
|
|
966
|
+
throw new Error(`Minimum panel sizes cannot exceed 100%`);
|
|
965
967
|
}
|
|
966
968
|
setSizes(panelsArray.map(panel => {
|
|
967
969
|
if (panel.current.defaultSize === null) {
|
|
@@ -995,8 +997,10 @@ function PanelGroupWithForwardedRef({
|
|
|
995
997
|
// This includes server rendering.
|
|
996
998
|
// At this point the best we can do is render everything with the same size.
|
|
997
999
|
if (panels.size === 0) {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
+
{
|
|
1001
|
+
if (isServerRendering() && defaultSize == null) {
|
|
1002
|
+
console.warn(`WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`);
|
|
1003
|
+
}
|
|
1000
1004
|
}
|
|
1001
1005
|
return {
|
|
1002
1006
|
flexBasis: 0,
|
|
@@ -935,9 +935,11 @@ function PanelGroupWithForwardedRef({
|
|
|
935
935
|
}
|
|
936
936
|
});
|
|
937
937
|
if (totalDefaultSize > 100) {
|
|
938
|
-
throw new Error(`
|
|
938
|
+
throw new Error(`Default panel sizes cannot exceed 100%`);
|
|
939
|
+
} else if (panelsArray.length > 1 && panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
|
|
940
|
+
throw new Error(`Invalid default sizes specified for panels`);
|
|
939
941
|
} else if (totalMinSize > 100) {
|
|
940
|
-
throw new Error(`
|
|
942
|
+
throw new Error(`Minimum panel sizes cannot exceed 100%`);
|
|
941
943
|
}
|
|
942
944
|
setSizes(panelsArray.map(panel => {
|
|
943
945
|
if (panel.current.defaultSize === null) {
|
|
@@ -971,8 +973,10 @@ function PanelGroupWithForwardedRef({
|
|
|
971
973
|
// This includes server rendering.
|
|
972
974
|
// At this point the best we can do is render everything with the same size.
|
|
973
975
|
if (panels.size === 0) {
|
|
974
|
-
|
|
975
|
-
|
|
976
|
+
{
|
|
977
|
+
if (isServerRendering() && defaultSize == null) {
|
|
978
|
+
console.warn(`WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`);
|
|
979
|
+
}
|
|
976
980
|
}
|
|
977
981
|
return {
|
|
978
982
|
flexBasis: 0,
|
|
@@ -738,13 +738,6 @@ function savePanelGroupLayout(autoSaveId, panels, sizes, storage) {
|
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
740
|
|
|
741
|
-
function isServerRendering() {
|
|
742
|
-
try {
|
|
743
|
-
return typeof window === undefined;
|
|
744
|
-
} catch (error) {}
|
|
745
|
-
return true;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
741
|
const debounceMap = {};
|
|
749
742
|
|
|
750
743
|
// PanelGroup might be rendering in a server-side environment where localStorage is not available
|
|
@@ -935,9 +928,11 @@ function PanelGroupWithForwardedRef({
|
|
|
935
928
|
}
|
|
936
929
|
});
|
|
937
930
|
if (totalDefaultSize > 100) {
|
|
938
|
-
throw new Error(`
|
|
931
|
+
throw new Error(`Default panel sizes cannot exceed 100%`);
|
|
932
|
+
} else if (panelsArray.length > 1 && panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
|
|
933
|
+
throw new Error(`Invalid default sizes specified for panels`);
|
|
939
934
|
} else if (totalMinSize > 100) {
|
|
940
|
-
throw new Error(`
|
|
935
|
+
throw new Error(`Minimum panel sizes cannot exceed 100%`);
|
|
941
936
|
}
|
|
942
937
|
setSizes(panelsArray.map(panel => {
|
|
943
938
|
if (panel.current.defaultSize === null) {
|
|
@@ -971,9 +966,6 @@ function PanelGroupWithForwardedRef({
|
|
|
971
966
|
// This includes server rendering.
|
|
972
967
|
// At this point the best we can do is render everything with the same size.
|
|
973
968
|
if (panels.size === 0) {
|
|
974
|
-
if (isServerRendering() && defaultSize == null) {
|
|
975
|
-
console.warn(`WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`);
|
|
976
|
-
}
|
|
977
969
|
return {
|
|
978
970
|
flexBasis: 0,
|
|
979
971
|
flexGrow: defaultSize != null ? defaultSize : undefined,
|
package/package.json
CHANGED
package/src/PanelGroup.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDevelopment } from "#is-development";
|
|
1
2
|
import {
|
|
2
3
|
createElement,
|
|
3
4
|
CSSProperties,
|
|
@@ -292,13 +293,15 @@ function PanelGroupWithForwardedRef({
|
|
|
292
293
|
});
|
|
293
294
|
|
|
294
295
|
if (totalDefaultSize > 100) {
|
|
295
|
-
throw new Error(
|
|
296
|
-
|
|
297
|
-
|
|
296
|
+
throw new Error(`Default panel sizes cannot exceed 100%`);
|
|
297
|
+
} else if (
|
|
298
|
+
panelsArray.length > 1 &&
|
|
299
|
+
panelsWithNullDefaultSize === 0 &&
|
|
300
|
+
totalDefaultSize !== 100
|
|
301
|
+
) {
|
|
302
|
+
throw new Error(`Invalid default sizes specified for panels`);
|
|
298
303
|
} else if (totalMinSize > 100) {
|
|
299
|
-
throw new Error(
|
|
300
|
-
`The sum of the minSize of all panels in a group cannot exceed 100.`
|
|
301
|
-
);
|
|
304
|
+
throw new Error(`Minimum panel sizes cannot exceed 100%`);
|
|
302
305
|
}
|
|
303
306
|
|
|
304
307
|
setSizes(
|
|
@@ -338,10 +341,12 @@ function PanelGroupWithForwardedRef({
|
|
|
338
341
|
// This includes server rendering.
|
|
339
342
|
// At this point the best we can do is render everything with the same size.
|
|
340
343
|
if (panels.size === 0) {
|
|
341
|
-
if (
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
344
|
+
if (isDevelopment) {
|
|
345
|
+
if (isServerRendering() && defaultSize == null) {
|
|
346
|
+
console.warn(
|
|
347
|
+
`WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`
|
|
348
|
+
);
|
|
349
|
+
}
|
|
345
350
|
}
|
|
346
351
|
|
|
347
352
|
return {
|