react-resizable-panels 2.1.1 → 2.1.2
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 +3 -0
- package/dist/react-resizable-panels.browser.cjs.js +1 -1
- package/dist/react-resizable-panels.browser.development.cjs.js +1 -1
- package/dist/react-resizable-panels.browser.development.esm.js +1 -1
- package/dist/react-resizable-panels.browser.esm.js +1 -1
- package/dist/react-resizable-panels.cjs.js +1 -1
- package/dist/react-resizable-panels.development.cjs.js +1 -1
- package/dist/react-resizable-panels.development.esm.js +1 -1
- package/dist/react-resizable-panels.development.node.cjs.js +1 -1
- package/dist/react-resizable-panels.development.node.esm.js +1 -1
- package/dist/react-resizable-panels.esm.js +1 -1
- package/dist/react-resizable-panels.node.cjs.js +1 -1
- package/dist/react-resizable-panels.node.esm.js +1 -1
- package/package.json +4 -1
- package/src/PanelGroup.test.tsx +21 -0
- package/src/utils/validatePanelGroupLayout.ts +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1542,7 +1542,7 @@ function validatePanelGroupLayout({
|
|
|
1542
1542
|
// Validate layout expectations
|
|
1543
1543
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1544
1544
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1545
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1545
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1546
1546
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1547
1547
|
const unsafeSize = nextLayout[index];
|
|
1548
1548
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
@@ -1601,7 +1601,7 @@ function validatePanelGroupLayout({
|
|
|
1601
1601
|
// Validate layout expectations
|
|
1602
1602
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1603
1603
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1604
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1604
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1605
1605
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1606
1606
|
// (especially if the amount is small)
|
|
1607
1607
|
{
|
|
@@ -1577,7 +1577,7 @@ function validatePanelGroupLayout({
|
|
|
1577
1577
|
// Validate layout expectations
|
|
1578
1578
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1579
1579
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1580
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1580
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1581
1581
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1582
1582
|
// (especially if the amount is small)
|
|
1583
1583
|
{
|
|
@@ -1518,7 +1518,7 @@ function validatePanelGroupLayout({
|
|
|
1518
1518
|
// Validate layout expectations
|
|
1519
1519
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1520
1520
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1521
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1521
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1522
1522
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1523
1523
|
const unsafeSize = nextLayout[index];
|
|
1524
1524
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
@@ -1544,7 +1544,7 @@ function validatePanelGroupLayout({
|
|
|
1544
1544
|
// Validate layout expectations
|
|
1545
1545
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1546
1546
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1547
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1547
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1548
1548
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1549
1549
|
const unsafeSize = nextLayout[index];
|
|
1550
1550
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
@@ -1608,7 +1608,7 @@ function validatePanelGroupLayout({
|
|
|
1608
1608
|
// Validate layout expectations
|
|
1609
1609
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1610
1610
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1611
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1611
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1612
1612
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1613
1613
|
// (especially if the amount is small)
|
|
1614
1614
|
{
|
|
@@ -1584,7 +1584,7 @@ function validatePanelGroupLayout({
|
|
|
1584
1584
|
// Validate layout expectations
|
|
1585
1585
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1586
1586
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1587
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1587
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1588
1588
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1589
1589
|
// (especially if the amount is small)
|
|
1590
1590
|
{
|
|
@@ -1440,7 +1440,7 @@ function validatePanelGroupLayout({
|
|
|
1440
1440
|
// Validate layout expectations
|
|
1441
1441
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1442
1442
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1443
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1443
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1444
1444
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1445
1445
|
// (especially if the amount is small)
|
|
1446
1446
|
{
|
|
@@ -1416,7 +1416,7 @@ function validatePanelGroupLayout({
|
|
|
1416
1416
|
// Validate layout expectations
|
|
1417
1417
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1418
1418
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1419
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1419
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1420
1420
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
1421
1421
|
// (especially if the amount is small)
|
|
1422
1422
|
{
|
|
@@ -1520,7 +1520,7 @@ function validatePanelGroupLayout({
|
|
|
1520
1520
|
// Validate layout expectations
|
|
1521
1521
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1522
1522
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1523
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1523
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1524
1524
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1525
1525
|
const unsafeSize = nextLayout[index];
|
|
1526
1526
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
@@ -1386,7 +1386,7 @@ function validatePanelGroupLayout({
|
|
|
1386
1386
|
// Validate layout expectations
|
|
1387
1387
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1388
1388
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1389
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1389
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1390
1390
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1391
1391
|
const unsafeSize = nextLayout[index];
|
|
1392
1392
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
@@ -1362,7 +1362,7 @@ function validatePanelGroupLayout({
|
|
|
1362
1362
|
// Validate layout expectations
|
|
1363
1363
|
if (nextLayout.length !== panelConstraints.length) {
|
|
1364
1364
|
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
|
|
1365
|
-
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
|
|
1365
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
1366
1366
|
for (let index = 0; index < panelConstraints.length; index++) {
|
|
1367
1367
|
const unsafeSize = nextLayout[index];
|
|
1368
1368
|
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-resizable-panels",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "React components for resizable panel groups/layouts",
|
|
5
5
|
"author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,6 +61,9 @@
|
|
|
61
61
|
},
|
|
62
62
|
"types": "dist/react-resizable-panels.cjs.d.ts",
|
|
63
63
|
"scripts": {
|
|
64
|
+
"clear": "pnpm run clear:builds & pnpm run clear:node_modules",
|
|
65
|
+
"clear:builds": "rm -rf ./packages/*/dist",
|
|
66
|
+
"clear:node_modules": "rm -rf ./node_modules",
|
|
64
67
|
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
65
68
|
"test": "jest --config=jest.config.js",
|
|
66
69
|
"test:watch": "jest --config=jest.config.js --watch",
|
package/src/PanelGroup.test.tsx
CHANGED
|
@@ -418,5 +418,26 @@ describe("PanelGroup", () => {
|
|
|
418
418
|
ref.current?.setLayout([60, 80]);
|
|
419
419
|
});
|
|
420
420
|
});
|
|
421
|
+
|
|
422
|
+
it("should warn about an empty layout", () => {
|
|
423
|
+
act(() => {
|
|
424
|
+
root.render(
|
|
425
|
+
<PanelGroup direction="horizontal" id="group-without-handle">
|
|
426
|
+
<Panel />
|
|
427
|
+
</PanelGroup>
|
|
428
|
+
);
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// Since the layout is empty, no warning is expected (even though the sizes won't total 100%)
|
|
432
|
+
|
|
433
|
+
act(() => {
|
|
434
|
+
root.render(
|
|
435
|
+
<PanelGroup
|
|
436
|
+
direction="horizontal"
|
|
437
|
+
id="group-without-handle"
|
|
438
|
+
></PanelGroup>
|
|
439
|
+
);
|
|
440
|
+
});
|
|
441
|
+
});
|
|
421
442
|
});
|
|
422
443
|
});
|
|
@@ -25,7 +25,10 @@ export function validatePanelGroupLayout({
|
|
|
25
25
|
.map((size) => `${size}%`)
|
|
26
26
|
.join(", ")}`
|
|
27
27
|
);
|
|
28
|
-
} else if (
|
|
28
|
+
} else if (
|
|
29
|
+
!fuzzyNumbersEqual(nextLayoutTotalSize, 100) &&
|
|
30
|
+
nextLayout.length > 0
|
|
31
|
+
) {
|
|
29
32
|
// This is not ideal so we should warn about it, but it may be recoverable in some cases
|
|
30
33
|
// (especially if the amount is small)
|
|
31
34
|
if (isDevelopment) {
|