react-resizable-panels 1.0.3 → 1.0.5
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 +8 -0
- package/README.md +11 -14
- package/dist/react-resizable-panels.browser.cjs.js +10 -6
- package/dist/react-resizable-panels.browser.development.cjs.js +10 -6
- package/dist/react-resizable-panels.browser.development.esm.js +10 -6
- package/dist/react-resizable-panels.browser.esm.js +10 -6
- package/dist/react-resizable-panels.cjs.js +10 -6
- package/dist/react-resizable-panels.development.cjs.js +10 -6
- package/dist/react-resizable-panels.development.esm.js +10 -6
- package/dist/react-resizable-panels.development.node.cjs.js +10 -6
- package/dist/react-resizable-panels.development.node.esm.js +10 -6
- package/dist/react-resizable-panels.esm.js +10 -6
- package/dist/react-resizable-panels.node.cjs.js +10 -6
- package/dist/react-resizable-panels.node.esm.js +10 -6
- package/package.json +1 -1
- package/src/Panel.test.tsx +12 -0
- package/src/Panel.ts +1 -1
- package/src/PanelGroup.ts +7 -6
- package/src/PanelGroupContext.ts +4 -1
- package/src/utils/computePanelFlexBoxStyle.ts +7 -3
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -26,26 +26,23 @@ import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
|
|
|
26
26
|
|
|
27
27
|
### `PanelGroup`
|
|
28
28
|
|
|
29
|
-
| prop
|
|
30
|
-
|
|
|
31
|
-
| `autoSaveId`
|
|
32
|
-
| `children`
|
|
33
|
-
| `className`
|
|
34
|
-
| `direction`
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
39
|
-
| `
|
|
40
|
-
| `tagName` | `?string = "div"` | HTML element tag name for root element |
|
|
29
|
+
| prop | type | description |
|
|
30
|
+
| :----------- | :--------------------------- | :--------------------------------------------------------------- |
|
|
31
|
+
| `autoSaveId` | `?string` | Unique id used to auto-save group arrangement via `localStorage` |
|
|
32
|
+
| `children` | `ReactNode` | Arbitrary React element(s) |
|
|
33
|
+
| `className` | `?string` | Class name to attach to root element |
|
|
34
|
+
| `direction` | `"horizontal" \| "vertical"` | Group orientation |
|
|
35
|
+
| `id` | `?string` | Group id; falls back to `useId` when not provided |
|
|
36
|
+
| `onLayout` | `?(sizes: number[]) => void` | Called when group layout changes |
|
|
37
|
+
| `storage` | `?PanelGroupStorage` | Custom storage API; defaults to `localStorage` <sup>1</sup> |
|
|
38
|
+
| `style` | `?CSSProperties` | CSS style to attach to root element |
|
|
39
|
+
| `tagName` | `?string = "div"` | HTML element tag name for root element |
|
|
41
40
|
|
|
42
41
|
<sup>1</sup>: Storage API must define the following _synchronous_ methods:
|
|
43
42
|
|
|
44
43
|
- `getItem: (name:string) => string`
|
|
45
44
|
- `setItem: (name: string, value: string) => void`
|
|
46
45
|
|
|
47
|
-
<sup>2</sup>: This behavior is disabled by default because it can interfere with scrollbar styles, but it can be useful in the edge case where a `Panel` contains an `<iframe>`
|
|
48
|
-
|
|
49
46
|
`PanelGroup` components also expose an imperative API for manual resizing:
|
|
50
47
|
| method | description
|
|
51
48
|
| :-------------------------------- | :---
|
|
@@ -163,7 +163,7 @@ function PanelWithForwardedRef({
|
|
|
163
163
|
resizePanel(panelDataRef.current, size);
|
|
164
164
|
}
|
|
165
165
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
166
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
166
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
167
167
|
return createElement(Type, {
|
|
168
168
|
...rest,
|
|
169
169
|
children,
|
|
@@ -858,6 +858,7 @@ function compareLayouts(a, b) {
|
|
|
858
858
|
|
|
859
859
|
// the % of the group's overall space this panel should occupy.
|
|
860
860
|
function computePanelFlexBoxStyle({
|
|
861
|
+
defaultSize,
|
|
861
862
|
dragState,
|
|
862
863
|
layout,
|
|
863
864
|
panelData,
|
|
@@ -866,10 +867,12 @@ function computePanelFlexBoxStyle({
|
|
|
866
867
|
}) {
|
|
867
868
|
const size = layout[panelIndex];
|
|
868
869
|
let flexGrow;
|
|
869
|
-
if (
|
|
870
|
-
flexGrow = "1";
|
|
871
|
-
} else if (size == null) {
|
|
870
|
+
if (size == null) {
|
|
872
871
|
// Initial render (before panels have registered themselves)
|
|
872
|
+
// In order to support server rendering, fall back to default size if provided
|
|
873
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
874
|
+
} else if (panelData.length === 1) {
|
|
875
|
+
// Special case: Single panel group should always fill full width/height
|
|
873
876
|
flexGrow = "1";
|
|
874
877
|
} else {
|
|
875
878
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1306,12 +1309,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1306
1309
|
}, []);
|
|
1307
1310
|
|
|
1308
1311
|
// This API should never read from committedValuesRef
|
|
1309
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1312
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1310
1313
|
const {
|
|
1311
1314
|
panelDataArray
|
|
1312
1315
|
} = eagerValuesRef.current;
|
|
1313
1316
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1314
1317
|
return computePanelFlexBoxStyle({
|
|
1318
|
+
defaultSize,
|
|
1315
1319
|
dragState,
|
|
1316
1320
|
layout,
|
|
1317
1321
|
panelData: panelDataArray,
|
|
@@ -1326,7 +1330,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1326
1330
|
panelDataArray
|
|
1327
1331
|
} = eagerValuesRef.current;
|
|
1328
1332
|
const {
|
|
1329
|
-
collapsedSize,
|
|
1333
|
+
collapsedSize = 0,
|
|
1330
1334
|
collapsible,
|
|
1331
1335
|
panelSize
|
|
1332
1336
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
@@ -169,7 +169,7 @@ function PanelWithForwardedRef({
|
|
|
169
169
|
resizePanel(panelDataRef.current, size);
|
|
170
170
|
}
|
|
171
171
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
172
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
172
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
173
173
|
return createElement(Type, {
|
|
174
174
|
...rest,
|
|
175
175
|
children,
|
|
@@ -874,6 +874,7 @@ function compareLayouts(a, b) {
|
|
|
874
874
|
|
|
875
875
|
// the % of the group's overall space this panel should occupy.
|
|
876
876
|
function computePanelFlexBoxStyle({
|
|
877
|
+
defaultSize,
|
|
877
878
|
dragState,
|
|
878
879
|
layout,
|
|
879
880
|
panelData,
|
|
@@ -882,10 +883,12 @@ function computePanelFlexBoxStyle({
|
|
|
882
883
|
}) {
|
|
883
884
|
const size = layout[panelIndex];
|
|
884
885
|
let flexGrow;
|
|
885
|
-
if (
|
|
886
|
-
flexGrow = "1";
|
|
887
|
-
} else if (size == null) {
|
|
886
|
+
if (size == null) {
|
|
888
887
|
// Initial render (before panels have registered themselves)
|
|
888
|
+
// In order to support server rendering, fall back to default size if provided
|
|
889
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
890
|
+
} else if (panelData.length === 1) {
|
|
891
|
+
// Special case: Single panel group should always fill full width/height
|
|
889
892
|
flexGrow = "1";
|
|
890
893
|
} else {
|
|
891
894
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1411,12 +1414,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1411
1414
|
}, []);
|
|
1412
1415
|
|
|
1413
1416
|
// This API should never read from committedValuesRef
|
|
1414
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1417
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1415
1418
|
const {
|
|
1416
1419
|
panelDataArray
|
|
1417
1420
|
} = eagerValuesRef.current;
|
|
1418
1421
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1419
1422
|
return computePanelFlexBoxStyle({
|
|
1423
|
+
defaultSize,
|
|
1420
1424
|
dragState,
|
|
1421
1425
|
layout,
|
|
1422
1426
|
panelData: panelDataArray,
|
|
@@ -1431,7 +1435,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1431
1435
|
panelDataArray
|
|
1432
1436
|
} = eagerValuesRef.current;
|
|
1433
1437
|
const {
|
|
1434
|
-
collapsedSize,
|
|
1438
|
+
collapsedSize = 0,
|
|
1435
1439
|
collapsible,
|
|
1436
1440
|
panelSize
|
|
1437
1441
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
@@ -145,7 +145,7 @@ function PanelWithForwardedRef({
|
|
|
145
145
|
resizePanel(panelDataRef.current, size);
|
|
146
146
|
}
|
|
147
147
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
148
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
148
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
149
149
|
return createElement(Type, {
|
|
150
150
|
...rest,
|
|
151
151
|
children,
|
|
@@ -850,6 +850,7 @@ function compareLayouts(a, b) {
|
|
|
850
850
|
|
|
851
851
|
// the % of the group's overall space this panel should occupy.
|
|
852
852
|
function computePanelFlexBoxStyle({
|
|
853
|
+
defaultSize,
|
|
853
854
|
dragState,
|
|
854
855
|
layout,
|
|
855
856
|
panelData,
|
|
@@ -858,10 +859,12 @@ function computePanelFlexBoxStyle({
|
|
|
858
859
|
}) {
|
|
859
860
|
const size = layout[panelIndex];
|
|
860
861
|
let flexGrow;
|
|
861
|
-
if (
|
|
862
|
-
flexGrow = "1";
|
|
863
|
-
} else if (size == null) {
|
|
862
|
+
if (size == null) {
|
|
864
863
|
// Initial render (before panels have registered themselves)
|
|
864
|
+
// In order to support server rendering, fall back to default size if provided
|
|
865
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
866
|
+
} else if (panelData.length === 1) {
|
|
867
|
+
// Special case: Single panel group should always fill full width/height
|
|
865
868
|
flexGrow = "1";
|
|
866
869
|
} else {
|
|
867
870
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1387,12 +1390,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1387
1390
|
}, []);
|
|
1388
1391
|
|
|
1389
1392
|
// This API should never read from committedValuesRef
|
|
1390
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1393
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1391
1394
|
const {
|
|
1392
1395
|
panelDataArray
|
|
1393
1396
|
} = eagerValuesRef.current;
|
|
1394
1397
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1395
1398
|
return computePanelFlexBoxStyle({
|
|
1399
|
+
defaultSize,
|
|
1396
1400
|
dragState,
|
|
1397
1401
|
layout,
|
|
1398
1402
|
panelData: panelDataArray,
|
|
@@ -1407,7 +1411,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1407
1411
|
panelDataArray
|
|
1408
1412
|
} = eagerValuesRef.current;
|
|
1409
1413
|
const {
|
|
1410
|
-
collapsedSize,
|
|
1414
|
+
collapsedSize = 0,
|
|
1411
1415
|
collapsible,
|
|
1412
1416
|
panelSize
|
|
1413
1417
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
@@ -139,7 +139,7 @@ function PanelWithForwardedRef({
|
|
|
139
139
|
resizePanel(panelDataRef.current, size);
|
|
140
140
|
}
|
|
141
141
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
142
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
142
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
143
143
|
return createElement(Type, {
|
|
144
144
|
...rest,
|
|
145
145
|
children,
|
|
@@ -834,6 +834,7 @@ function compareLayouts(a, b) {
|
|
|
834
834
|
|
|
835
835
|
// the % of the group's overall space this panel should occupy.
|
|
836
836
|
function computePanelFlexBoxStyle({
|
|
837
|
+
defaultSize,
|
|
837
838
|
dragState,
|
|
838
839
|
layout,
|
|
839
840
|
panelData,
|
|
@@ -842,10 +843,12 @@ function computePanelFlexBoxStyle({
|
|
|
842
843
|
}) {
|
|
843
844
|
const size = layout[panelIndex];
|
|
844
845
|
let flexGrow;
|
|
845
|
-
if (
|
|
846
|
-
flexGrow = "1";
|
|
847
|
-
} else if (size == null) {
|
|
846
|
+
if (size == null) {
|
|
848
847
|
// Initial render (before panels have registered themselves)
|
|
848
|
+
// In order to support server rendering, fall back to default size if provided
|
|
849
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
850
|
+
} else if (panelData.length === 1) {
|
|
851
|
+
// Special case: Single panel group should always fill full width/height
|
|
849
852
|
flexGrow = "1";
|
|
850
853
|
} else {
|
|
851
854
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1282,12 +1285,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1282
1285
|
}, []);
|
|
1283
1286
|
|
|
1284
1287
|
// This API should never read from committedValuesRef
|
|
1285
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1288
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1286
1289
|
const {
|
|
1287
1290
|
panelDataArray
|
|
1288
1291
|
} = eagerValuesRef.current;
|
|
1289
1292
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1290
1293
|
return computePanelFlexBoxStyle({
|
|
1294
|
+
defaultSize,
|
|
1291
1295
|
dragState,
|
|
1292
1296
|
layout,
|
|
1293
1297
|
panelData: panelDataArray,
|
|
@@ -1302,7 +1306,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1302
1306
|
panelDataArray
|
|
1303
1307
|
} = eagerValuesRef.current;
|
|
1304
1308
|
const {
|
|
1305
|
-
collapsedSize,
|
|
1309
|
+
collapsedSize = 0,
|
|
1306
1310
|
collapsible,
|
|
1307
1311
|
panelSize
|
|
1308
1312
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
@@ -165,7 +165,7 @@ function PanelWithForwardedRef({
|
|
|
165
165
|
resizePanel(panelDataRef.current, size);
|
|
166
166
|
}
|
|
167
167
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
168
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
168
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
169
169
|
return createElement(Type, {
|
|
170
170
|
...rest,
|
|
171
171
|
children,
|
|
@@ -860,6 +860,7 @@ function compareLayouts(a, b) {
|
|
|
860
860
|
|
|
861
861
|
// the % of the group's overall space this panel should occupy.
|
|
862
862
|
function computePanelFlexBoxStyle({
|
|
863
|
+
defaultSize,
|
|
863
864
|
dragState,
|
|
864
865
|
layout,
|
|
865
866
|
panelData,
|
|
@@ -868,10 +869,12 @@ function computePanelFlexBoxStyle({
|
|
|
868
869
|
}) {
|
|
869
870
|
const size = layout[panelIndex];
|
|
870
871
|
let flexGrow;
|
|
871
|
-
if (
|
|
872
|
-
flexGrow = "1";
|
|
873
|
-
} else if (size == null) {
|
|
872
|
+
if (size == null) {
|
|
874
873
|
// Initial render (before panels have registered themselves)
|
|
874
|
+
// In order to support server rendering, fall back to default size if provided
|
|
875
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
876
|
+
} else if (panelData.length === 1) {
|
|
877
|
+
// Special case: Single panel group should always fill full width/height
|
|
875
878
|
flexGrow = "1";
|
|
876
879
|
} else {
|
|
877
880
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1308,12 +1311,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1308
1311
|
}, []);
|
|
1309
1312
|
|
|
1310
1313
|
// This API should never read from committedValuesRef
|
|
1311
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1314
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1312
1315
|
const {
|
|
1313
1316
|
panelDataArray
|
|
1314
1317
|
} = eagerValuesRef.current;
|
|
1315
1318
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1316
1319
|
return computePanelFlexBoxStyle({
|
|
1320
|
+
defaultSize,
|
|
1317
1321
|
dragState,
|
|
1318
1322
|
layout,
|
|
1319
1323
|
panelData: panelDataArray,
|
|
@@ -1328,7 +1332,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1328
1332
|
panelDataArray
|
|
1329
1333
|
} = eagerValuesRef.current;
|
|
1330
1334
|
const {
|
|
1331
|
-
collapsedSize,
|
|
1335
|
+
collapsedSize = 0,
|
|
1332
1336
|
collapsible,
|
|
1333
1337
|
panelSize
|
|
1334
1338
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
@@ -176,7 +176,7 @@ function PanelWithForwardedRef({
|
|
|
176
176
|
resizePanel(panelDataRef.current, size);
|
|
177
177
|
}
|
|
178
178
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
179
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
179
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
180
180
|
return createElement(Type, {
|
|
181
181
|
...rest,
|
|
182
182
|
children,
|
|
@@ -881,6 +881,7 @@ function compareLayouts(a, b) {
|
|
|
881
881
|
|
|
882
882
|
// the % of the group's overall space this panel should occupy.
|
|
883
883
|
function computePanelFlexBoxStyle({
|
|
884
|
+
defaultSize,
|
|
884
885
|
dragState,
|
|
885
886
|
layout,
|
|
886
887
|
panelData,
|
|
@@ -889,10 +890,12 @@ function computePanelFlexBoxStyle({
|
|
|
889
890
|
}) {
|
|
890
891
|
const size = layout[panelIndex];
|
|
891
892
|
let flexGrow;
|
|
892
|
-
if (
|
|
893
|
-
flexGrow = "1";
|
|
894
|
-
} else if (size == null) {
|
|
893
|
+
if (size == null) {
|
|
895
894
|
// Initial render (before panels have registered themselves)
|
|
895
|
+
// In order to support server rendering, fall back to default size if provided
|
|
896
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
897
|
+
} else if (panelData.length === 1) {
|
|
898
|
+
// Special case: Single panel group should always fill full width/height
|
|
896
899
|
flexGrow = "1";
|
|
897
900
|
} else {
|
|
898
901
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1418,12 +1421,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1418
1421
|
}, []);
|
|
1419
1422
|
|
|
1420
1423
|
// This API should never read from committedValuesRef
|
|
1421
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1424
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1422
1425
|
const {
|
|
1423
1426
|
panelDataArray
|
|
1424
1427
|
} = eagerValuesRef.current;
|
|
1425
1428
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1426
1429
|
return computePanelFlexBoxStyle({
|
|
1430
|
+
defaultSize,
|
|
1427
1431
|
dragState,
|
|
1428
1432
|
layout,
|
|
1429
1433
|
panelData: panelDataArray,
|
|
@@ -1438,7 +1442,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1438
1442
|
panelDataArray
|
|
1439
1443
|
} = eagerValuesRef.current;
|
|
1440
1444
|
const {
|
|
1441
|
-
collapsedSize,
|
|
1445
|
+
collapsedSize = 0,
|
|
1442
1446
|
collapsible,
|
|
1443
1447
|
panelSize
|
|
1444
1448
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
@@ -152,7 +152,7 @@ function PanelWithForwardedRef({
|
|
|
152
152
|
resizePanel(panelDataRef.current, size);
|
|
153
153
|
}
|
|
154
154
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
155
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
155
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
156
156
|
return createElement(Type, {
|
|
157
157
|
...rest,
|
|
158
158
|
children,
|
|
@@ -857,6 +857,7 @@ function compareLayouts(a, b) {
|
|
|
857
857
|
|
|
858
858
|
// the % of the group's overall space this panel should occupy.
|
|
859
859
|
function computePanelFlexBoxStyle({
|
|
860
|
+
defaultSize,
|
|
860
861
|
dragState,
|
|
861
862
|
layout,
|
|
862
863
|
panelData,
|
|
@@ -865,10 +866,12 @@ function computePanelFlexBoxStyle({
|
|
|
865
866
|
}) {
|
|
866
867
|
const size = layout[panelIndex];
|
|
867
868
|
let flexGrow;
|
|
868
|
-
if (
|
|
869
|
-
flexGrow = "1";
|
|
870
|
-
} else if (size == null) {
|
|
869
|
+
if (size == null) {
|
|
871
870
|
// Initial render (before panels have registered themselves)
|
|
871
|
+
// In order to support server rendering, fall back to default size if provided
|
|
872
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
873
|
+
} else if (panelData.length === 1) {
|
|
874
|
+
// Special case: Single panel group should always fill full width/height
|
|
872
875
|
flexGrow = "1";
|
|
873
876
|
} else {
|
|
874
877
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1394,12 +1397,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1394
1397
|
}, []);
|
|
1395
1398
|
|
|
1396
1399
|
// This API should never read from committedValuesRef
|
|
1397
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1400
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1398
1401
|
const {
|
|
1399
1402
|
panelDataArray
|
|
1400
1403
|
} = eagerValuesRef.current;
|
|
1401
1404
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1402
1405
|
return computePanelFlexBoxStyle({
|
|
1406
|
+
defaultSize,
|
|
1403
1407
|
dragState,
|
|
1404
1408
|
layout,
|
|
1405
1409
|
panelData: panelDataArray,
|
|
@@ -1414,7 +1418,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1414
1418
|
panelDataArray
|
|
1415
1419
|
} = eagerValuesRef.current;
|
|
1416
1420
|
const {
|
|
1417
|
-
collapsedSize,
|
|
1421
|
+
collapsedSize = 0,
|
|
1418
1422
|
collapsible,
|
|
1419
1423
|
panelSize
|
|
1420
1424
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
@@ -148,7 +148,7 @@ function PanelWithForwardedRef({
|
|
|
148
148
|
resizePanel(panelDataRef.current, size);
|
|
149
149
|
}
|
|
150
150
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
151
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
151
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
152
152
|
return createElement(Type, {
|
|
153
153
|
...rest,
|
|
154
154
|
children,
|
|
@@ -732,6 +732,7 @@ function compareLayouts(a, b) {
|
|
|
732
732
|
|
|
733
733
|
// the % of the group's overall space this panel should occupy.
|
|
734
734
|
function computePanelFlexBoxStyle({
|
|
735
|
+
defaultSize,
|
|
735
736
|
dragState,
|
|
736
737
|
layout,
|
|
737
738
|
panelData,
|
|
@@ -740,10 +741,12 @@ function computePanelFlexBoxStyle({
|
|
|
740
741
|
}) {
|
|
741
742
|
const size = layout[panelIndex];
|
|
742
743
|
let flexGrow;
|
|
743
|
-
if (
|
|
744
|
-
flexGrow = "1";
|
|
745
|
-
} else if (size == null) {
|
|
744
|
+
if (size == null) {
|
|
746
745
|
// Initial render (before panels have registered themselves)
|
|
746
|
+
// In order to support server rendering, fall back to default size if provided
|
|
747
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
748
|
+
} else if (panelData.length === 1) {
|
|
749
|
+
// Special case: Single panel group should always fill full width/height
|
|
747
750
|
flexGrow = "1";
|
|
748
751
|
} else {
|
|
749
752
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1255,12 +1258,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1255
1258
|
}, []);
|
|
1256
1259
|
|
|
1257
1260
|
// This API should never read from committedValuesRef
|
|
1258
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1261
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1259
1262
|
const {
|
|
1260
1263
|
panelDataArray
|
|
1261
1264
|
} = eagerValuesRef.current;
|
|
1262
1265
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1263
1266
|
return computePanelFlexBoxStyle({
|
|
1267
|
+
defaultSize,
|
|
1264
1268
|
dragState,
|
|
1265
1269
|
layout,
|
|
1266
1270
|
panelData: panelDataArray,
|
|
@@ -1275,7 +1279,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1275
1279
|
panelDataArray
|
|
1276
1280
|
} = eagerValuesRef.current;
|
|
1277
1281
|
const {
|
|
1278
|
-
collapsedSize,
|
|
1282
|
+
collapsedSize = 0,
|
|
1279
1283
|
collapsible,
|
|
1280
1284
|
panelSize
|
|
1281
1285
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
@@ -124,7 +124,7 @@ function PanelWithForwardedRef({
|
|
|
124
124
|
resizePanel(panelDataRef.current, size);
|
|
125
125
|
}
|
|
126
126
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
127
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
127
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
128
128
|
return createElement(Type, {
|
|
129
129
|
...rest,
|
|
130
130
|
children,
|
|
@@ -708,6 +708,7 @@ function compareLayouts(a, b) {
|
|
|
708
708
|
|
|
709
709
|
// the % of the group's overall space this panel should occupy.
|
|
710
710
|
function computePanelFlexBoxStyle({
|
|
711
|
+
defaultSize,
|
|
711
712
|
dragState,
|
|
712
713
|
layout,
|
|
713
714
|
panelData,
|
|
@@ -716,10 +717,12 @@ function computePanelFlexBoxStyle({
|
|
|
716
717
|
}) {
|
|
717
718
|
const size = layout[panelIndex];
|
|
718
719
|
let flexGrow;
|
|
719
|
-
if (
|
|
720
|
-
flexGrow = "1";
|
|
721
|
-
} else if (size == null) {
|
|
720
|
+
if (size == null) {
|
|
722
721
|
// Initial render (before panels have registered themselves)
|
|
722
|
+
// In order to support server rendering, fall back to default size if provided
|
|
723
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
724
|
+
} else if (panelData.length === 1) {
|
|
725
|
+
// Special case: Single panel group should always fill full width/height
|
|
723
726
|
flexGrow = "1";
|
|
724
727
|
} else {
|
|
725
728
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1231,12 +1234,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1231
1234
|
}, []);
|
|
1232
1235
|
|
|
1233
1236
|
// This API should never read from committedValuesRef
|
|
1234
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1237
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1235
1238
|
const {
|
|
1236
1239
|
panelDataArray
|
|
1237
1240
|
} = eagerValuesRef.current;
|
|
1238
1241
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1239
1242
|
return computePanelFlexBoxStyle({
|
|
1243
|
+
defaultSize,
|
|
1240
1244
|
dragState,
|
|
1241
1245
|
layout,
|
|
1242
1246
|
panelData: panelDataArray,
|
|
@@ -1251,7 +1255,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1251
1255
|
panelDataArray
|
|
1252
1256
|
} = eagerValuesRef.current;
|
|
1253
1257
|
const {
|
|
1254
|
-
collapsedSize,
|
|
1258
|
+
collapsedSize = 0,
|
|
1255
1259
|
collapsible,
|
|
1256
1260
|
panelSize
|
|
1257
1261
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
@@ -141,7 +141,7 @@ function PanelWithForwardedRef({
|
|
|
141
141
|
resizePanel(panelDataRef.current, size);
|
|
142
142
|
}
|
|
143
143
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
144
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
144
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
145
145
|
return createElement(Type, {
|
|
146
146
|
...rest,
|
|
147
147
|
children,
|
|
@@ -836,6 +836,7 @@ function compareLayouts(a, b) {
|
|
|
836
836
|
|
|
837
837
|
// the % of the group's overall space this panel should occupy.
|
|
838
838
|
function computePanelFlexBoxStyle({
|
|
839
|
+
defaultSize,
|
|
839
840
|
dragState,
|
|
840
841
|
layout,
|
|
841
842
|
panelData,
|
|
@@ -844,10 +845,12 @@ function computePanelFlexBoxStyle({
|
|
|
844
845
|
}) {
|
|
845
846
|
const size = layout[panelIndex];
|
|
846
847
|
let flexGrow;
|
|
847
|
-
if (
|
|
848
|
-
flexGrow = "1";
|
|
849
|
-
} else if (size == null) {
|
|
848
|
+
if (size == null) {
|
|
850
849
|
// Initial render (before panels have registered themselves)
|
|
850
|
+
// In order to support server rendering, fall back to default size if provided
|
|
851
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
852
|
+
} else if (panelData.length === 1) {
|
|
853
|
+
// Special case: Single panel group should always fill full width/height
|
|
851
854
|
flexGrow = "1";
|
|
852
855
|
} else {
|
|
853
856
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1284,12 +1287,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1284
1287
|
}, []);
|
|
1285
1288
|
|
|
1286
1289
|
// This API should never read from committedValuesRef
|
|
1287
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1290
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1288
1291
|
const {
|
|
1289
1292
|
panelDataArray
|
|
1290
1293
|
} = eagerValuesRef.current;
|
|
1291
1294
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1292
1295
|
return computePanelFlexBoxStyle({
|
|
1296
|
+
defaultSize,
|
|
1293
1297
|
dragState,
|
|
1294
1298
|
layout,
|
|
1295
1299
|
panelData: panelDataArray,
|
|
@@ -1304,7 +1308,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1304
1308
|
panelDataArray
|
|
1305
1309
|
} = eagerValuesRef.current;
|
|
1306
1310
|
const {
|
|
1307
|
-
collapsedSize,
|
|
1311
|
+
collapsedSize = 0,
|
|
1308
1312
|
collapsible,
|
|
1309
1313
|
panelSize
|
|
1310
1314
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
@@ -137,7 +137,7 @@ function PanelWithForwardedRef({
|
|
|
137
137
|
resizePanel(panelDataRef.current, size);
|
|
138
138
|
}
|
|
139
139
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
140
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
140
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
141
141
|
return createElement(Type, {
|
|
142
142
|
...rest,
|
|
143
143
|
children,
|
|
@@ -721,6 +721,7 @@ function compareLayouts(a, b) {
|
|
|
721
721
|
|
|
722
722
|
// the % of the group's overall space this panel should occupy.
|
|
723
723
|
function computePanelFlexBoxStyle({
|
|
724
|
+
defaultSize,
|
|
724
725
|
dragState,
|
|
725
726
|
layout,
|
|
726
727
|
panelData,
|
|
@@ -729,10 +730,12 @@ function computePanelFlexBoxStyle({
|
|
|
729
730
|
}) {
|
|
730
731
|
const size = layout[panelIndex];
|
|
731
732
|
let flexGrow;
|
|
732
|
-
if (
|
|
733
|
-
flexGrow = "1";
|
|
734
|
-
} else if (size == null) {
|
|
733
|
+
if (size == null) {
|
|
735
734
|
// Initial render (before panels have registered themselves)
|
|
735
|
+
// In order to support server rendering, fall back to default size if provided
|
|
736
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
737
|
+
} else if (panelData.length === 1) {
|
|
738
|
+
// Special case: Single panel group should always fill full width/height
|
|
736
739
|
flexGrow = "1";
|
|
737
740
|
} else {
|
|
738
741
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1155,12 +1158,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1155
1158
|
}, []);
|
|
1156
1159
|
|
|
1157
1160
|
// This API should never read from committedValuesRef
|
|
1158
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1161
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1159
1162
|
const {
|
|
1160
1163
|
panelDataArray
|
|
1161
1164
|
} = eagerValuesRef.current;
|
|
1162
1165
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1163
1166
|
return computePanelFlexBoxStyle({
|
|
1167
|
+
defaultSize,
|
|
1164
1168
|
dragState,
|
|
1165
1169
|
layout,
|
|
1166
1170
|
panelData: panelDataArray,
|
|
@@ -1175,7 +1179,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1175
1179
|
panelDataArray
|
|
1176
1180
|
} = eagerValuesRef.current;
|
|
1177
1181
|
const {
|
|
1178
|
-
collapsedSize,
|
|
1182
|
+
collapsedSize = 0,
|
|
1179
1183
|
collapsible,
|
|
1180
1184
|
panelSize
|
|
1181
1185
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
@@ -113,7 +113,7 @@ function PanelWithForwardedRef({
|
|
|
113
113
|
resizePanel(panelDataRef.current, size);
|
|
114
114
|
}
|
|
115
115
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
116
|
-
const style = getPanelStyle(panelDataRef.current);
|
|
116
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
117
117
|
return createElement(Type, {
|
|
118
118
|
...rest,
|
|
119
119
|
children,
|
|
@@ -697,6 +697,7 @@ function compareLayouts(a, b) {
|
|
|
697
697
|
|
|
698
698
|
// the % of the group's overall space this panel should occupy.
|
|
699
699
|
function computePanelFlexBoxStyle({
|
|
700
|
+
defaultSize,
|
|
700
701
|
dragState,
|
|
701
702
|
layout,
|
|
702
703
|
panelData,
|
|
@@ -705,10 +706,12 @@ function computePanelFlexBoxStyle({
|
|
|
705
706
|
}) {
|
|
706
707
|
const size = layout[panelIndex];
|
|
707
708
|
let flexGrow;
|
|
708
|
-
if (
|
|
709
|
-
flexGrow = "1";
|
|
710
|
-
} else if (size == null) {
|
|
709
|
+
if (size == null) {
|
|
711
710
|
// Initial render (before panels have registered themselves)
|
|
711
|
+
// In order to support server rendering, fall back to default size if provided
|
|
712
|
+
flexGrow = defaultSize !== null && defaultSize !== void 0 ? defaultSize : "1";
|
|
713
|
+
} else if (panelData.length === 1) {
|
|
714
|
+
// Special case: Single panel group should always fill full width/height
|
|
712
715
|
flexGrow = "1";
|
|
713
716
|
} else {
|
|
714
717
|
flexGrow = size.toPrecision(precision);
|
|
@@ -1131,12 +1134,13 @@ function PanelGroupWithForwardedRef({
|
|
|
1131
1134
|
}, []);
|
|
1132
1135
|
|
|
1133
1136
|
// This API should never read from committedValuesRef
|
|
1134
|
-
const getPanelStyle = useCallback(panelData => {
|
|
1137
|
+
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1135
1138
|
const {
|
|
1136
1139
|
panelDataArray
|
|
1137
1140
|
} = eagerValuesRef.current;
|
|
1138
1141
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
1139
1142
|
return computePanelFlexBoxStyle({
|
|
1143
|
+
defaultSize,
|
|
1140
1144
|
dragState,
|
|
1141
1145
|
layout,
|
|
1142
1146
|
panelData: panelDataArray,
|
|
@@ -1151,7 +1155,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1151
1155
|
panelDataArray
|
|
1152
1156
|
} = eagerValuesRef.current;
|
|
1153
1157
|
const {
|
|
1154
|
-
collapsedSize,
|
|
1158
|
+
collapsedSize = 0,
|
|
1155
1159
|
collapsible,
|
|
1156
1160
|
panelSize
|
|
1157
1161
|
} = panelDataHelper(panelDataArray, panelData, layout);
|
package/package.json
CHANGED
package/src/Panel.test.tsx
CHANGED
|
@@ -89,13 +89,19 @@ describe("PanelGroup", () => {
|
|
|
89
89
|
assert(mostRecentLayout);
|
|
90
90
|
|
|
91
91
|
verifyExpandedPanelGroupLayout(mostRecentLayout, [50, 50]);
|
|
92
|
+
expect(leftPanelRef.current?.isCollapsed()).toBe(false);
|
|
93
|
+
expect(rightPanelRef.current?.isCollapsed()).toBe(false);
|
|
92
94
|
act(() => {
|
|
93
95
|
leftPanelRef.current?.collapse();
|
|
94
96
|
});
|
|
97
|
+
expect(leftPanelRef.current?.isCollapsed()).toBe(true);
|
|
98
|
+
expect(rightPanelRef.current?.isCollapsed()).toBe(false);
|
|
95
99
|
verifyExpandedPanelGroupLayout(mostRecentLayout, [0, 100]);
|
|
96
100
|
act(() => {
|
|
97
101
|
leftPanelRef.current?.expand();
|
|
98
102
|
});
|
|
103
|
+
expect(leftPanelRef.current?.isCollapsed()).toBe(false);
|
|
104
|
+
expect(rightPanelRef.current?.isCollapsed()).toBe(false);
|
|
99
105
|
verifyExpandedPanelGroupLayout(mostRecentLayout, [50, 50]);
|
|
100
106
|
});
|
|
101
107
|
|
|
@@ -103,14 +109,20 @@ describe("PanelGroup", () => {
|
|
|
103
109
|
assert(mostRecentLayout);
|
|
104
110
|
|
|
105
111
|
verifyExpandedPanelGroupLayout(mostRecentLayout, [50, 50]);
|
|
112
|
+
expect(leftPanelRef.current?.isCollapsed()).toBe(false);
|
|
113
|
+
expect(rightPanelRef.current?.isCollapsed()).toBe(false);
|
|
106
114
|
act(() => {
|
|
107
115
|
rightPanelRef.current?.collapse();
|
|
108
116
|
});
|
|
109
117
|
verifyExpandedPanelGroupLayout(mostRecentLayout, [100, 0]);
|
|
118
|
+
expect(leftPanelRef.current?.isCollapsed()).toBe(false);
|
|
119
|
+
expect(rightPanelRef.current?.isCollapsed()).toBe(true);
|
|
110
120
|
act(() => {
|
|
111
121
|
rightPanelRef.current?.expand();
|
|
112
122
|
});
|
|
113
123
|
verifyExpandedPanelGroupLayout(mostRecentLayout, [50, 50]);
|
|
124
|
+
expect(leftPanelRef.current?.isCollapsed()).toBe(false);
|
|
125
|
+
expect(rightPanelRef.current?.isCollapsed()).toBe(false);
|
|
114
126
|
});
|
|
115
127
|
|
|
116
128
|
it("should re-expand to the most recent size before collapsing", () => {
|
package/src/Panel.ts
CHANGED
package/src/PanelGroup.ts
CHANGED
|
@@ -435,12 +435,13 @@ function PanelGroupWithForwardedRef({
|
|
|
435
435
|
|
|
436
436
|
// This API should never read from committedValuesRef
|
|
437
437
|
const getPanelStyle = useCallback(
|
|
438
|
-
(panelData: PanelData) => {
|
|
438
|
+
(panelData: PanelData, defaultSize: number | undefined) => {
|
|
439
439
|
const { panelDataArray } = eagerValuesRef.current;
|
|
440
440
|
|
|
441
441
|
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
442
442
|
|
|
443
443
|
return computePanelFlexBoxStyle({
|
|
444
|
+
defaultSize,
|
|
444
445
|
dragState,
|
|
445
446
|
layout,
|
|
446
447
|
panelData: panelDataArray,
|
|
@@ -454,11 +455,11 @@ function PanelGroupWithForwardedRef({
|
|
|
454
455
|
const isPanelCollapsed = useCallback((panelData: PanelData) => {
|
|
455
456
|
const { layout, panelDataArray } = eagerValuesRef.current;
|
|
456
457
|
|
|
457
|
-
const {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
);
|
|
458
|
+
const {
|
|
459
|
+
collapsedSize = 0,
|
|
460
|
+
collapsible,
|
|
461
|
+
panelSize,
|
|
462
|
+
} = panelDataHelper(panelDataArray, panelData, layout);
|
|
462
463
|
|
|
463
464
|
return collapsible === true && panelSize === collapsedSize;
|
|
464
465
|
}, []);
|
package/src/PanelGroupContext.ts
CHANGED
|
@@ -17,7 +17,10 @@ export const PanelGroupContext = createContext<{
|
|
|
17
17
|
dragState: DragState | null;
|
|
18
18
|
expandPanel: (panelData: PanelData) => void;
|
|
19
19
|
getPanelSize: (panelData: PanelData) => number;
|
|
20
|
-
getPanelStyle: (
|
|
20
|
+
getPanelStyle: (
|
|
21
|
+
panelData: PanelData,
|
|
22
|
+
defaultSize: number | undefined
|
|
23
|
+
) => CSSProperties;
|
|
21
24
|
groupId: string;
|
|
22
25
|
isPanelCollapsed: (panelData: PanelData) => boolean;
|
|
23
26
|
isPanelExpanded: (panelData: PanelData) => boolean;
|
|
@@ -6,12 +6,14 @@ import { CSSProperties } from "../vendor/react";
|
|
|
6
6
|
|
|
7
7
|
// the % of the group's overall space this panel should occupy.
|
|
8
8
|
export function computePanelFlexBoxStyle({
|
|
9
|
+
defaultSize,
|
|
9
10
|
dragState,
|
|
10
11
|
layout,
|
|
11
12
|
panelData,
|
|
12
13
|
panelIndex,
|
|
13
14
|
precision = 3,
|
|
14
15
|
}: {
|
|
16
|
+
defaultSize: number | undefined;
|
|
15
17
|
layout: number[];
|
|
16
18
|
dragState: DragState | null;
|
|
17
19
|
panelData: PanelData[];
|
|
@@ -21,10 +23,12 @@ export function computePanelFlexBoxStyle({
|
|
|
21
23
|
const size = layout[panelIndex];
|
|
22
24
|
|
|
23
25
|
let flexGrow;
|
|
24
|
-
if (
|
|
25
|
-
flexGrow = "1";
|
|
26
|
-
} else if (size == null) {
|
|
26
|
+
if (size == null) {
|
|
27
27
|
// Initial render (before panels have registered themselves)
|
|
28
|
+
// In order to support server rendering, fall back to default size if provided
|
|
29
|
+
flexGrow = defaultSize ?? "1";
|
|
30
|
+
} else if (panelData.length === 1) {
|
|
31
|
+
// Special case: Single panel group should always fill full width/height
|
|
28
32
|
flexGrow = "1";
|
|
29
33
|
} else {
|
|
30
34
|
flexGrow = size.toPrecision(precision);
|