react-resizable-panels 0.0.49 → 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 CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.50
4
+ * Improved panel size validation in `PanelGroup`.
5
+
3
6
  ## 0.0.49
4
7
  * Improved development warnings and props validation checks in `PanelGroup`.
5
8
 
@@ -951,10 +951,12 @@ function PanelGroupWithForwardedRef({
951
951
  totalDefaultSize += panel.current.defaultSize;
952
952
  }
953
953
  });
954
- if (totalDefaultSize > 100 || panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
954
+ if (totalDefaultSize > 100) {
955
+ throw new Error(`Default panel sizes cannot exceed 100%`);
956
+ } else if (panelsArray.length > 1 && panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
955
957
  throw new Error(`Invalid default sizes specified for panels`);
956
958
  } else if (totalMinSize > 100) {
957
- throw new Error(`Invalid minimum sizes specified for panels`);
959
+ throw new Error(`Minimum panel sizes cannot exceed 100%`);
958
960
  }
959
961
  setSizes(panelsArray.map(panel => {
960
962
  if (panel.current.defaultSize === null) {
@@ -958,10 +958,12 @@ function PanelGroupWithForwardedRef({
958
958
  totalDefaultSize += panel.current.defaultSize;
959
959
  }
960
960
  });
961
- if (totalDefaultSize > 100 || panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
961
+ if (totalDefaultSize > 100) {
962
+ throw new Error(`Default panel sizes cannot exceed 100%`);
963
+ } else if (panelsArray.length > 1 && panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
962
964
  throw new Error(`Invalid default sizes specified for panels`);
963
965
  } else if (totalMinSize > 100) {
964
- throw new Error(`Invalid minimum sizes specified for panels`);
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) {
@@ -934,10 +934,12 @@ function PanelGroupWithForwardedRef({
934
934
  totalDefaultSize += panel.current.defaultSize;
935
935
  }
936
936
  });
937
- if (totalDefaultSize > 100 || panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
937
+ if (totalDefaultSize > 100) {
938
+ throw new Error(`Default panel sizes cannot exceed 100%`);
939
+ } else if (panelsArray.length > 1 && panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
938
940
  throw new Error(`Invalid default sizes specified for panels`);
939
941
  } else if (totalMinSize > 100) {
940
- throw new Error(`Invalid minimum sizes specified for panels`);
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) {
@@ -927,10 +927,12 @@ function PanelGroupWithForwardedRef({
927
927
  totalDefaultSize += panel.current.defaultSize;
928
928
  }
929
929
  });
930
- if (totalDefaultSize > 100 || panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
930
+ if (totalDefaultSize > 100) {
931
+ throw new Error(`Default panel sizes cannot exceed 100%`);
932
+ } else if (panelsArray.length > 1 && panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100) {
931
933
  throw new Error(`Invalid default sizes specified for panels`);
932
934
  } else if (totalMinSize > 100) {
933
- throw new Error(`Invalid minimum sizes specified for panels`);
935
+ throw new Error(`Minimum panel sizes cannot exceed 100%`);
934
936
  }
935
937
  setSizes(panelsArray.map(panel => {
936
938
  if (panel.current.defaultSize === null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable-panels",
3
- "version": "0.0.49",
3
+ "version": "0.0.50",
4
4
  "description": "React components for resizable panel groups/layouts",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
6
6
  "license": "MIT",
package/src/PanelGroup.ts CHANGED
@@ -292,13 +292,16 @@ function PanelGroupWithForwardedRef({
292
292
  }
293
293
  });
294
294
 
295
- if (
296
- totalDefaultSize > 100 ||
297
- (panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100)
295
+ if (totalDefaultSize > 100) {
296
+ throw new Error(`Default panel sizes cannot exceed 100%`);
297
+ } else if (
298
+ panelsArray.length > 1 &&
299
+ panelsWithNullDefaultSize === 0 &&
300
+ totalDefaultSize !== 100
298
301
  ) {
299
302
  throw new Error(`Invalid default sizes specified for panels`);
300
303
  } else if (totalMinSize > 100) {
301
- throw new Error(`Invalid minimum sizes specified for panels`);
304
+ throw new Error(`Minimum panel sizes cannot exceed 100%`);
302
305
  }
303
306
 
304
307
  setSizes(