react-resizable-panels 0.0.43 → 0.0.45
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/dist/react-resizable-panels.d.ts.map +1 -1
- package/dist/react-resizable-panels.js +89 -73
- package/dist/react-resizable-panels.js.map +1 -1
- package/dist/react-resizable-panels.module.js +89 -73
- package/dist/react-resizable-panels.module.js.map +1 -1
- package/package.json +1 -1
- package/src/Panel.ts +41 -30
- package/src/PanelContexts.ts +1 -1
- package/src/PanelGroup.ts +31 -15
- package/src/hooks/useWindowSplitterBehavior.ts +7 -7
- package/src/types.ts +14 -10
- package/src/utils/coordinates.ts +5 -5
- package/src/utils/group.ts +20 -18
- package/src/utils/serialization.ts +1 -1
- package/src/utils/ssr.ts +7 -0
|
@@ -12,7 +12,6 @@ const { createElement: $ef07efbe5fa7d87e$export$c8a8987d4410bf2d , createContext
|
|
|
12
12
|
const $ef07efbe5fa7d87e$export$f680877a34711e37 = $jhddX$react["useId".toString()];
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
const $3f95d3e171760903$var$canUseEffectHooks = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
17
16
|
const $3f95d3e171760903$var$useIsomorphicLayoutEffect = $3f95d3e171760903$var$canUseEffectHooks ? (0, $ef07efbe5fa7d87e$export$e5c5a5f917a5871c) : ()=>{};
|
|
18
17
|
var $3f95d3e171760903$export$2e2bcd8739ae039 = $3f95d3e171760903$var$useIsomorphicLayoutEffect;
|
|
@@ -30,6 +29,7 @@ function $e504a2438473eda9$export$2e2bcd8739ae039(idFromParams = null) {
|
|
|
30
29
|
|
|
31
30
|
|
|
32
31
|
|
|
32
|
+
|
|
33
33
|
const $af466b485b9d515d$export$7d8c6d083caec74a = (0, $ef07efbe5fa7d87e$export$fd42f52fd3ae1109)(null);
|
|
34
34
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
35
35
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
@@ -61,37 +61,40 @@ function $c33df6d7c39fd3ee$var$PanelWithForwardedRef({ children: children = null
|
|
|
61
61
|
defaultSize = minSize;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
const style = getPanelStyle(panelId, defaultSize);
|
|
65
|
+
const committedValuesRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
|
|
66
|
+
size: $c33df6d7c39fd3ee$var$parseSizeFromStyle(style)
|
|
67
|
+
});
|
|
68
|
+
const panelDataRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
|
|
69
|
+
callbacksRef: callbacksRef,
|
|
70
|
+
collapsible: collapsible,
|
|
71
|
+
defaultSize: defaultSize,
|
|
72
|
+
id: panelId,
|
|
73
|
+
maxSize: maxSize,
|
|
74
|
+
minSize: minSize,
|
|
75
|
+
order: order
|
|
76
|
+
});
|
|
64
77
|
(0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
committedValuesRef.current.size = $c33df6d7c39fd3ee$var$parseSizeFromStyle(style);
|
|
79
|
+
panelDataRef.current.callbacksRef = callbacksRef;
|
|
80
|
+
panelDataRef.current.collapsible = collapsible;
|
|
81
|
+
panelDataRef.current.defaultSize = defaultSize;
|
|
82
|
+
panelDataRef.current.id = panelId;
|
|
83
|
+
panelDataRef.current.maxSize = maxSize;
|
|
84
|
+
panelDataRef.current.minSize = minSize;
|
|
85
|
+
panelDataRef.current.order = order;
|
|
86
|
+
});
|
|
87
|
+
(0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
|
|
88
|
+
registerPanel(panelId, panelDataRef);
|
|
75
89
|
return ()=>{
|
|
76
90
|
unregisterPanel(panelId);
|
|
77
91
|
};
|
|
78
92
|
}, [
|
|
79
|
-
collapsible,
|
|
80
|
-
defaultSize,
|
|
81
|
-
panelId,
|
|
82
|
-
maxSize,
|
|
83
|
-
minSize,
|
|
84
93
|
order,
|
|
94
|
+
panelId,
|
|
85
95
|
registerPanel,
|
|
86
96
|
unregisterPanel
|
|
87
97
|
]);
|
|
88
|
-
const style = getPanelStyle(panelId);
|
|
89
|
-
const committedValuesRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
|
|
90
|
-
size: $c33df6d7c39fd3ee$var$parseSizeFromStyle(style)
|
|
91
|
-
});
|
|
92
|
-
(0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
|
|
93
|
-
committedValuesRef.current.size = $c33df6d7c39fd3ee$var$parseSizeFromStyle(style);
|
|
94
|
-
});
|
|
95
98
|
(0, $ef07efbe5fa7d87e$export$d5a552a76deda3c2)(forwardedRef, ()=>({
|
|
96
99
|
collapse: ()=>collapsePanel(panelId),
|
|
97
100
|
expand: ()=>expandPanel(panelId),
|
|
@@ -166,7 +169,7 @@ function $d6f7e4c3aa9e02d7$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
166
169
|
// Max-bounds check the panel being expanded first.
|
|
167
170
|
{
|
|
168
171
|
const pivotId = delta < 0 ? idAfter : idBefore;
|
|
169
|
-
const index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
172
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
|
|
170
173
|
const panel = panelsArray[index];
|
|
171
174
|
const baseSize = baseSizes[index];
|
|
172
175
|
const nextSize = $d6f7e4c3aa9e02d7$var$safeResizePanel(panel, Math.abs(delta), baseSize, event);
|
|
@@ -178,14 +181,14 @@ function $d6f7e4c3aa9e02d7$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
178
181
|
}
|
|
179
182
|
}
|
|
180
183
|
let pivotId = delta < 0 ? idBefore : idAfter;
|
|
181
|
-
let index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
184
|
+
let index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
|
|
182
185
|
while(true){
|
|
183
186
|
const panel = panelsArray[index];
|
|
184
187
|
const baseSize = baseSizes[index];
|
|
185
188
|
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
186
189
|
const nextSize = $d6f7e4c3aa9e02d7$var$safeResizePanel(panel, 0 - deltaRemaining, baseSize, event);
|
|
187
190
|
if (baseSize !== nextSize) {
|
|
188
|
-
if (nextSize === 0 && baseSize > 0) panelSizeBeforeCollapse.set(panel.id, baseSize);
|
|
191
|
+
if (nextSize === 0 && baseSize > 0) panelSizeBeforeCollapse.set(panel.current.id, baseSize);
|
|
189
192
|
deltaApplied += baseSize - nextSize;
|
|
190
193
|
nextSizes[index] = nextSize;
|
|
191
194
|
if (deltaApplied.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)).localeCompare(Math.abs(delta).toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)), undefined, {
|
|
@@ -203,7 +206,7 @@ function $d6f7e4c3aa9e02d7$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
203
206
|
if (deltaApplied === 0) return baseSizes;
|
|
204
207
|
// Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
|
|
205
208
|
pivotId = delta < 0 ? idAfter : idBefore;
|
|
206
|
-
index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
209
|
+
index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
|
|
207
210
|
nextSizes[index] = baseSizes[index] + deltaApplied;
|
|
208
211
|
return nextSizes;
|
|
209
212
|
}
|
|
@@ -211,7 +214,7 @@ function $d6f7e4c3aa9e02d7$export$b8e48269e4faa934(panelsArray, prevSizes, nextS
|
|
|
211
214
|
nextSizes.forEach((nextSize, index)=>{
|
|
212
215
|
const prevSize = prevSizes[index];
|
|
213
216
|
if (prevSize !== nextSize) {
|
|
214
|
-
const { callbacksRef: callbacksRef , collapsible: collapsible } = panelsArray[index];
|
|
217
|
+
const { callbacksRef: callbacksRef , collapsible: collapsible } = panelsArray[index].current;
|
|
215
218
|
const { onCollapse: onCollapse , onResize: onResize } = callbacksRef.current;
|
|
216
219
|
if (onResize) onResize(nextSize);
|
|
217
220
|
if (collapsible && onCollapse) {
|
|
@@ -228,14 +231,14 @@ function $d6f7e4c3aa9e02d7$export$5a5b0c1d38c23c3b(id, panelsArray) {
|
|
|
228
231
|
null,
|
|
229
232
|
null
|
|
230
233
|
];
|
|
231
|
-
const index = panelsArray.findIndex((panel)=>panel.id === id);
|
|
234
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === id);
|
|
232
235
|
if (index < 0) return [
|
|
233
236
|
null,
|
|
234
237
|
null
|
|
235
238
|
];
|
|
236
239
|
const isLastPanel = index === panelsArray.length - 1;
|
|
237
|
-
const idBefore = isLastPanel ? panelsArray[index - 1].id : id;
|
|
238
|
-
const idAfter = isLastPanel ? id : panelsArray[index + 1].id;
|
|
240
|
+
const idBefore = isLastPanel ? panelsArray[index - 1].current.id : id;
|
|
241
|
+
const idAfter = isLastPanel ? id : panelsArray[index + 1].current.id;
|
|
239
242
|
return [
|
|
240
243
|
idBefore,
|
|
241
244
|
idAfter
|
|
@@ -244,7 +247,7 @@ function $d6f7e4c3aa9e02d7$export$5a5b0c1d38c23c3b(id, panelsArray) {
|
|
|
244
247
|
function $d6f7e4c3aa9e02d7$export$6f43503e166de6fb(panels, id, sizes) {
|
|
245
248
|
if (panels.size === 1) return "100";
|
|
246
249
|
const panelsArray = $d6f7e4c3aa9e02d7$export$a861c0ad45885494(panels);
|
|
247
|
-
const index = panelsArray.findIndex((panel)=>panel.id === id);
|
|
250
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === id);
|
|
248
251
|
const size = sizes[index];
|
|
249
252
|
if (size == null) return "0";
|
|
250
253
|
return size.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879));
|
|
@@ -276,14 +279,14 @@ function $d6f7e4c3aa9e02d7$export$ae14931f0a0256a3(groupId) {
|
|
|
276
279
|
return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
|
|
277
280
|
}
|
|
278
281
|
function $d6f7e4c3aa9e02d7$export$68d3a33c21dfbe27(groupId, handleId, panelsArray) {
|
|
279
|
-
var _panelsArray_index, _panelsArray_;
|
|
282
|
+
var _panelsArray_index, _panelsArray_index_current, _panelsArray_, _panelsArray__current;
|
|
280
283
|
const handle = $d6f7e4c3aa9e02d7$export$2e27d3a347680388(handleId);
|
|
281
284
|
const handles = $d6f7e4c3aa9e02d7$export$ae14931f0a0256a3(groupId);
|
|
282
285
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
283
|
-
var
|
|
284
|
-
const idBefore = (
|
|
285
|
-
var
|
|
286
|
-
const idAfter = (
|
|
286
|
+
var _panelsArray_index_current_id;
|
|
287
|
+
const idBefore = (_panelsArray_index_current_id = (_panelsArray_index = panelsArray[index]) === null || _panelsArray_index === void 0 ? void 0 : (_panelsArray_index_current = _panelsArray_index.current) === null || _panelsArray_index_current === void 0 ? void 0 : _panelsArray_index_current.id) !== null && _panelsArray_index_current_id !== void 0 ? _panelsArray_index_current_id : null;
|
|
288
|
+
var _panelsArray__current_id;
|
|
289
|
+
const idAfter = (_panelsArray__current_id = (_panelsArray_ = panelsArray[index + 1]) === null || _panelsArray_ === void 0 ? void 0 : (_panelsArray__current = _panelsArray_.current) === null || _panelsArray__current === void 0 ? void 0 : _panelsArray__current.id) !== null && _panelsArray__current_id !== void 0 ? _panelsArray__current_id : null;
|
|
287
290
|
return [
|
|
288
291
|
idBefore,
|
|
289
292
|
idAfter
|
|
@@ -291,8 +294,8 @@ function $d6f7e4c3aa9e02d7$export$68d3a33c21dfbe27(groupId, handleId, panelsArra
|
|
|
291
294
|
}
|
|
292
295
|
function $d6f7e4c3aa9e02d7$export$a861c0ad45885494(panels) {
|
|
293
296
|
return Array.from(panels.values()).sort((panelA, panelB)=>{
|
|
294
|
-
const orderA = panelA.order;
|
|
295
|
-
const orderB = panelB.order;
|
|
297
|
+
const orderA = panelA.current.order;
|
|
298
|
+
const orderB = panelB.current.order;
|
|
296
299
|
if (orderA == null && orderB == null) return 0;
|
|
297
300
|
else if (orderA == null) return -1;
|
|
298
301
|
else if (orderB == null) return 1;
|
|
@@ -301,7 +304,7 @@ function $d6f7e4c3aa9e02d7$export$a861c0ad45885494(panels) {
|
|
|
301
304
|
}
|
|
302
305
|
function $d6f7e4c3aa9e02d7$var$safeResizePanel(panel, delta, prevSize, event) {
|
|
303
306
|
const nextSizeUnsafe = prevSize + delta;
|
|
304
|
-
if (panel.collapsible) {
|
|
307
|
+
if (panel.current.collapsible) {
|
|
305
308
|
if (prevSize > 0) {
|
|
306
309
|
if (nextSizeUnsafe <= 0) return 0;
|
|
307
310
|
} else {
|
|
@@ -311,11 +314,11 @@ function $d6f7e4c3aa9e02d7$var$safeResizePanel(panel, delta, prevSize, event) {
|
|
|
311
314
|
// Keyboard events should expand a collapsed panel to the min size,
|
|
312
315
|
// but mouse events should wait until the panel has reached its min size
|
|
313
316
|
// to avoid a visual flickering when dragging between collapsed and min size.
|
|
314
|
-
if (nextSizeUnsafe < panel.minSize) return 0;
|
|
317
|
+
if (nextSizeUnsafe < panel.current.minSize) return 0;
|
|
315
318
|
}
|
|
316
319
|
}
|
|
317
320
|
}
|
|
318
|
-
const nextSize = Math.min(panel.maxSize, Math.max(panel.minSize, nextSizeUnsafe));
|
|
321
|
+
const nextSize = Math.min(panel.current.maxSize, Math.max(panel.current.minSize, nextSizeUnsafe));
|
|
319
322
|
return nextSize;
|
|
320
323
|
}
|
|
321
324
|
|
|
@@ -345,12 +348,12 @@ function $4a90471e7083b52f$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
345
348
|
let totalMaxSize = 0;
|
|
346
349
|
// A panel's effective min/max sizes also need to account for other panel's sizes.
|
|
347
350
|
panelsArray.forEach((panelData)=>{
|
|
348
|
-
if (panelData.id === idBefore) {
|
|
349
|
-
maxSize = panelData.maxSize;
|
|
350
|
-
minSize = panelData.minSize;
|
|
351
|
+
if (panelData.current.id === idBefore) {
|
|
352
|
+
maxSize = panelData.current.maxSize;
|
|
353
|
+
minSize = panelData.current.minSize;
|
|
351
354
|
} else {
|
|
352
|
-
totalMinSize += panelData.minSize;
|
|
353
|
-
totalMaxSize += panelData.maxSize;
|
|
355
|
+
totalMinSize += panelData.current.minSize;
|
|
356
|
+
totalMaxSize += panelData.current.maxSize;
|
|
354
357
|
}
|
|
355
358
|
});
|
|
356
359
|
const ariaValueMax = Math.min(maxSize, 100 - totalMinSize);
|
|
@@ -365,13 +368,13 @@ function $4a90471e7083b52f$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
365
368
|
case "Enter":
|
|
366
369
|
{
|
|
367
370
|
event.preventDefault();
|
|
368
|
-
const index = panelsArray.findIndex((panel)=>panel.id === idBefore);
|
|
371
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === idBefore);
|
|
369
372
|
if (index >= 0) {
|
|
370
373
|
const panelData = panelsArray[index];
|
|
371
374
|
const size = sizes[index];
|
|
372
375
|
if (size != null) {
|
|
373
376
|
let delta = 0;
|
|
374
|
-
if (size.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)) <= panelData.minSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
|
|
377
|
+
if (size.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)) <= panelData.current.minSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
|
|
375
378
|
else delta = -(direction === "horizontal" ? width : height);
|
|
376
379
|
const nextSizes = (0, $d6f7e4c3aa9e02d7$export$f50bae335f53943c)(event, panels, idBefore, idAfter, delta, sizes, panelSizeBeforeCollapse.current, null);
|
|
377
380
|
if (sizes !== nextSizes) setSizes(nextSizes);
|
|
@@ -511,11 +514,11 @@ function $8f51c2d77bf1da88$export$354b17c0684607ed(event, groupId, handleId, pan
|
|
|
511
514
|
// If expanding from collapsed, they should snap back to their minSize.
|
|
512
515
|
const [idBefore, idAfter] = (0, $d6f7e4c3aa9e02d7$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
|
|
513
516
|
const targetPanelId = movement < 0 ? idBefore : idAfter;
|
|
514
|
-
const targetPanelIndex = panelsArray.findIndex((panel)=>panel.id === targetPanelId);
|
|
517
|
+
const targetPanelIndex = panelsArray.findIndex((panel)=>panel.current.id === targetPanelId);
|
|
515
518
|
const targetPanel = panelsArray[targetPanelIndex];
|
|
516
|
-
if (targetPanel.collapsible) {
|
|
519
|
+
if (targetPanel.current.collapsible) {
|
|
517
520
|
const baseSize = baseSizes[targetPanelIndex];
|
|
518
|
-
if (baseSize === 0 || baseSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)) === targetPanel.minSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879))) movement = movement < 0 ? -targetPanel.minSize * groupSizeInPixels : targetPanel.minSize * groupSizeInPixels;
|
|
521
|
+
if (baseSize === 0 || baseSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)) === targetPanel.current.minSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879))) movement = movement < 0 ? -targetPanel.current.minSize * groupSizeInPixels : targetPanel.current.minSize * groupSizeInPixels;
|
|
519
522
|
}
|
|
520
523
|
return movement;
|
|
521
524
|
} else return $8f51c2d77bf1da88$export$ec391ce65b083ed4(event, handleId, direction, dragOffset, dragHandleRect);
|
|
@@ -587,7 +590,7 @@ function $f7d932e9304c1581$export$2e2bcd8739ae039(callback, durationMs = 10) {
|
|
|
587
590
|
// Pre-sorting by minSize allows remembering layouts even if panels are re-ordered/dragged.
|
|
588
591
|
function $6889c3a3ed41cfd1$var$getSerializationKey(panels) {
|
|
589
592
|
return panels.map((panel)=>{
|
|
590
|
-
const { minSize: minSize , order: order } = panel;
|
|
593
|
+
const { minSize: minSize , order: order } = panel.current;
|
|
591
594
|
return order ? `${order}:${minSize}` : `${minSize}`;
|
|
592
595
|
}).sort((a, b)=>a.localeCompare(b)).join(",");
|
|
593
596
|
}
|
|
@@ -622,6 +625,14 @@ function $6889c3a3ed41cfd1$export$af183b313c61be4f(autoSaveId, panels, sizes, st
|
|
|
622
625
|
}
|
|
623
626
|
|
|
624
627
|
|
|
628
|
+
function $88f8826b36ffc83f$export$1aa6024f7a345313() {
|
|
629
|
+
try {
|
|
630
|
+
return window, false;
|
|
631
|
+
} catch (error) {}
|
|
632
|
+
return true;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
|
|
625
636
|
const $3daa5d4c086ea816$var$debounceMap = {};
|
|
626
637
|
function $3daa5d4c086ea816$var$throwServerError() {
|
|
627
638
|
throw new Error('PanelGroup "storage" prop required for server rendering.');
|
|
@@ -730,15 +741,15 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
730
741
|
// e.g. if Panel A has a maxSize of 40 then Panels A and B can't both have an implicit default size of 50.
|
|
731
742
|
// For now, these logic edge cases are left to the user to handle via props.
|
|
732
743
|
panelsArray.forEach((panel)=>{
|
|
733
|
-
totalMinSize += panel.minSize;
|
|
734
|
-
if (panel.defaultSize === null) panelsWithNullDefaultSize++;
|
|
735
|
-
else totalDefaultSize += panel.defaultSize;
|
|
744
|
+
totalMinSize += panel.current.minSize;
|
|
745
|
+
if (panel.current.defaultSize === null) panelsWithNullDefaultSize++;
|
|
746
|
+
else totalDefaultSize += panel.current.defaultSize;
|
|
736
747
|
});
|
|
737
748
|
if (totalDefaultSize > 100) throw new Error(`The sum of the defaultSize of all panels in a group cannot exceed 100.`);
|
|
738
749
|
else if (totalMinSize > 100) throw new Error(`The sum of the minSize of all panels in a group cannot exceed 100.`);
|
|
739
750
|
setSizes(panelsArray.map((panel)=>{
|
|
740
|
-
if (panel.defaultSize === null) return (100 - totalDefaultSize) / panelsWithNullDefaultSize;
|
|
741
|
-
return panel.defaultSize;
|
|
751
|
+
if (panel.current.defaultSize === null) return (100 - totalDefaultSize) / panelsWithNullDefaultSize;
|
|
752
|
+
return panel.current.defaultSize;
|
|
742
753
|
}));
|
|
743
754
|
}
|
|
744
755
|
}, [
|
|
@@ -761,18 +772,21 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
761
772
|
sizes,
|
|
762
773
|
storage
|
|
763
774
|
]);
|
|
764
|
-
const getPanelStyle = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id)=>{
|
|
775
|
+
const getPanelStyle = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id, defaultSize)=>{
|
|
765
776
|
const { panels: panels } = committedValuesRef.current;
|
|
766
777
|
// Before mounting, Panels will not yet have registered themselves.
|
|
767
778
|
// This includes server rendering.
|
|
768
779
|
// At this point the best we can do is render everything with the same size.
|
|
769
|
-
if (panels.size === 0)
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
780
|
+
if (panels.size === 0) {
|
|
781
|
+
if ((0, $88f8826b36ffc83f$export$1aa6024f7a345313)() && defaultSize == null) console.warn(`WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`);
|
|
782
|
+
return {
|
|
783
|
+
flexBasis: 0,
|
|
784
|
+
flexGrow: defaultSize != null ? defaultSize : undefined,
|
|
785
|
+
flexShrink: 1,
|
|
786
|
+
// Without this, Panel sizes may be unintentionally overridden by their content.
|
|
787
|
+
overflow: "hidden"
|
|
788
|
+
};
|
|
789
|
+
}
|
|
776
790
|
const flexGrow = (0, $d6f7e4c3aa9e02d7$export$6f43503e166de6fb)(panels, id, sizes);
|
|
777
791
|
return {
|
|
778
792
|
flexBasis: 0,
|
|
@@ -789,11 +803,11 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
789
803
|
disablePointerEventsDuringResize,
|
|
790
804
|
sizes
|
|
791
805
|
]);
|
|
792
|
-
const registerPanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id,
|
|
806
|
+
const registerPanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id, panelRef)=>{
|
|
793
807
|
setPanels((prevPanels)=>{
|
|
794
808
|
if (prevPanels.has(id)) return prevPanels;
|
|
795
809
|
const nextPanels = new Map(prevPanels);
|
|
796
|
-
nextPanels.set(id,
|
|
810
|
+
nextPanels.set(id, panelRef);
|
|
797
811
|
return nextPanels;
|
|
798
812
|
});
|
|
799
813
|
}, []);
|
|
@@ -804,11 +818,13 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
804
818
|
const panelsArray = (0, $d6f7e4c3aa9e02d7$export$a861c0ad45885494)(panels);
|
|
805
819
|
const [idBefore, idAfter] = (0, $d6f7e4c3aa9e02d7$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
|
|
806
820
|
if (idBefore == null || idAfter == null) return;
|
|
807
|
-
|
|
821
|
+
let movement = (0, $8f51c2d77bf1da88$export$354b17c0684607ed)(event, groupId, handleId, panelsArray, direction, prevSizes, initialDragStateRef.current);
|
|
808
822
|
if (movement === 0) return;
|
|
809
823
|
const groupElement = (0, $d6f7e4c3aa9e02d7$export$5e67632cf3550a9c)(groupId);
|
|
810
824
|
const rect = groupElement.getBoundingClientRect();
|
|
811
825
|
const isHorizontal = direction === "horizontal";
|
|
826
|
+
// Support RTL layouts
|
|
827
|
+
if (document.dir === "rtl" && isHorizontal) movement = -movement;
|
|
812
828
|
const size = isHorizontal ? rect.width : rect.height;
|
|
813
829
|
const delta = movement / size * 100;
|
|
814
830
|
const nextSizes = (0, $d6f7e4c3aa9e02d7$export$f50bae335f53943c)(event, panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current, initialDragStateRef.current);
|
|
@@ -851,7 +867,7 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
851
867
|
const collapsePanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id)=>{
|
|
852
868
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
853
869
|
const panel = panels.get(id);
|
|
854
|
-
if (panel == null || !panel.collapsible) return;
|
|
870
|
+
if (panel == null || !panel.current.collapsible) return;
|
|
855
871
|
const panelsArray = (0, $d6f7e4c3aa9e02d7$export$a861c0ad45885494)(panels);
|
|
856
872
|
const index = panelsArray.indexOf(panel);
|
|
857
873
|
if (index < 0) return;
|
|
@@ -874,7 +890,7 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
874
890
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
875
891
|
const panel = panels.get(id);
|
|
876
892
|
if (panel == null) return;
|
|
877
|
-
const sizeBeforeCollapse = panelSizeBeforeCollapse.current.get(id) || panel.minSize;
|
|
893
|
+
const sizeBeforeCollapse = panelSizeBeforeCollapse.current.get(id) || panel.current.minSize;
|
|
878
894
|
if (!sizeBeforeCollapse) return;
|
|
879
895
|
const panelsArray = (0, $d6f7e4c3aa9e02d7$export$a861c0ad45885494)(panels);
|
|
880
896
|
const index = panelsArray.indexOf(panel);
|
|
@@ -902,8 +918,8 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
902
918
|
if (index < 0) return;
|
|
903
919
|
const currentSize = prevSizes[index];
|
|
904
920
|
if (currentSize === nextSize) return;
|
|
905
|
-
if (panel.collapsible && nextSize === 0) ;
|
|
906
|
-
else nextSize = Math.min(panel.maxSize, Math.max(panel.minSize, nextSize));
|
|
921
|
+
if (panel.current.collapsible && nextSize === 0) ;
|
|
922
|
+
else nextSize = Math.min(panel.current.maxSize, Math.max(panel.current.minSize, nextSize));
|
|
907
923
|
const [idBefore, idAfter] = (0, $d6f7e4c3aa9e02d7$export$5a5b0c1d38c23c3b)(id, panelsArray);
|
|
908
924
|
if (idBefore == null || idAfter == null) return;
|
|
909
925
|
const isLastPanel = index === panelsArray.length - 1;
|