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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.45
|
|
4
|
+
* SSR: Avoid layout shift by using `defaultSize` to set initial `flex-grow` style
|
|
5
|
+
* SSR: Warn if `Panel` is server-rendered without a `defaultSize` prop
|
|
6
|
+
* [#135](https://github.com/bvaughn/react-resizable-panels/issues/135): Support RTL layouts
|
|
7
|
+
|
|
8
|
+
## 0.0.44
|
|
9
|
+
* [#142](https://github.com/bvaughn/react-resizable-panels/pull/142): Avoid re-registering Panel when props change; this should reduce the number of scenarios requiring the `order` prop
|
|
10
|
+
|
|
3
11
|
## 0.0.43
|
|
4
12
|
* Add imperative `getLayout` API to `PanelGroup`
|
|
5
13
|
* [#139](https://github.com/bvaughn/react-resizable-panels/pull/139): Fix edge case bug where simultaneous `localStorage` updates to multiple saved groups would drop some values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";AGEA,iBAAwB,YAAY,GAAG,UAAU,CAAC;AAElD,gCAAgC;IAC9B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;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,EAChC,QAAe,EACf,SAAS,EAAE,kBAAuB,EAClC,QAAgB,EAChB,EAAE,EAAE,WAAkB,EACtB,UAAU,EACV,KAAK,EAAE,cAAmB,EAC1B,OAAO,EAAE,IAAY,GACtB,EAAE,sBAAsB,0FAoJxB","sources":["packages/react-resizable-panels/src/src/vendor/react.ts","packages/react-resizable-panels/src/src/hooks/useIsomorphicEffect.ts","packages/react-resizable-panels/src/src/hooks/useUniqueId.ts","packages/react-resizable-panels/src/src/types.ts","packages/react-resizable-panels/src/src/PanelContexts.ts","packages/react-resizable-panels/src/src/Panel.ts","packages/react-resizable-panels/src/src/constants.ts","packages/react-resizable-panels/src/src/utils/group.ts","packages/react-resizable-panels/src/src/utils/assert.ts","packages/react-resizable-panels/src/src/hooks/useWindowSplitterBehavior.ts","packages/react-resizable-panels/src/src/utils/arrays.ts","packages/react-resizable-panels/src/src/utils/coordinates.ts","packages/react-resizable-panels/src/src/utils/cursor.ts","packages/react-resizable-panels/src/src/utils/debounce.ts","packages/react-resizable-panels/src/src/utils/serialization.ts","packages/react-resizable-panels/src/src/utils/ssr.ts","packages/react-resizable-panels/src/src/PanelGroup.ts","packages/react-resizable-panels/src/src/PanelResizeHandle.ts","packages/react-resizable-panels/src/src/index.ts","packages/react-resizable-panels/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"import { Panel } from \"./Panel\";\nimport { PanelGroup } from \"./PanelGroup\";\nimport { PanelResizeHandle } from \"./PanelResizeHandle\";\n\nimport type { ImperativePanelHandle, PanelProps } from \"./Panel\";\nimport type { ImperativePanelGroupHandle, PanelGroupProps } from \"./PanelGroup\";\nimport type { PanelResizeHandleProps } from \"./PanelResizeHandle\";\nimport type { PanelGroupStorage } from \"./types\";\n\nexport {\n // TypeScript types\n ImperativePanelGroupHandle,\n ImperativePanelHandle,\n Panel,\n PanelGroup,\n PanelGroupProps,\n PanelGroupStorage,\n PanelProps,\n PanelResizeHandle,\n PanelResizeHandleProps,\n};\n"],"names":[],"version":3,"file":"react-resizable-panels.d.ts.map"}
|
|
@@ -19,7 +19,6 @@ const { createElement: $6e687094f9ca8395$export$c8a8987d4410bf2d , createContext
|
|
|
19
19
|
const $6e687094f9ca8395$export$f680877a34711e37 = $2IMI0$react["useId".toString()];
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
const $129b5b9a317dcc10$var$canUseEffectHooks = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
24
23
|
const $129b5b9a317dcc10$var$useIsomorphicLayoutEffect = $129b5b9a317dcc10$var$canUseEffectHooks ? (0, $6e687094f9ca8395$export$e5c5a5f917a5871c) : ()=>{};
|
|
25
24
|
var $129b5b9a317dcc10$export$2e2bcd8739ae039 = $129b5b9a317dcc10$var$useIsomorphicLayoutEffect;
|
|
@@ -37,6 +36,7 @@ function $b1693d8d8f570e9c$export$2e2bcd8739ae039(idFromParams = null) {
|
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
|
|
39
|
+
|
|
40
40
|
const $b9cf028330e7f243$export$7d8c6d083caec74a = (0, $6e687094f9ca8395$export$fd42f52fd3ae1109)(null);
|
|
41
41
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
42
42
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
@@ -68,37 +68,40 @@ function $45da0e827c614f1d$var$PanelWithForwardedRef({ children: children = null
|
|
|
68
68
|
defaultSize = minSize;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
const style = getPanelStyle(panelId, defaultSize);
|
|
72
|
+
const committedValuesRef = (0, $6e687094f9ca8395$export$b8f5890fc79d6aca)({
|
|
73
|
+
size: $45da0e827c614f1d$var$parseSizeFromStyle(style)
|
|
74
|
+
});
|
|
75
|
+
const panelDataRef = (0, $6e687094f9ca8395$export$b8f5890fc79d6aca)({
|
|
76
|
+
callbacksRef: callbacksRef,
|
|
77
|
+
collapsible: collapsible,
|
|
78
|
+
defaultSize: defaultSize,
|
|
79
|
+
id: panelId,
|
|
80
|
+
maxSize: maxSize,
|
|
81
|
+
minSize: minSize,
|
|
82
|
+
order: order
|
|
83
|
+
});
|
|
71
84
|
(0, $129b5b9a317dcc10$export$2e2bcd8739ae039)(()=>{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
committedValuesRef.current.size = $45da0e827c614f1d$var$parseSizeFromStyle(style);
|
|
86
|
+
panelDataRef.current.callbacksRef = callbacksRef;
|
|
87
|
+
panelDataRef.current.collapsible = collapsible;
|
|
88
|
+
panelDataRef.current.defaultSize = defaultSize;
|
|
89
|
+
panelDataRef.current.id = panelId;
|
|
90
|
+
panelDataRef.current.maxSize = maxSize;
|
|
91
|
+
panelDataRef.current.minSize = minSize;
|
|
92
|
+
panelDataRef.current.order = order;
|
|
93
|
+
});
|
|
94
|
+
(0, $129b5b9a317dcc10$export$2e2bcd8739ae039)(()=>{
|
|
95
|
+
registerPanel(panelId, panelDataRef);
|
|
82
96
|
return ()=>{
|
|
83
97
|
unregisterPanel(panelId);
|
|
84
98
|
};
|
|
85
99
|
}, [
|
|
86
|
-
collapsible,
|
|
87
|
-
defaultSize,
|
|
88
|
-
panelId,
|
|
89
|
-
maxSize,
|
|
90
|
-
minSize,
|
|
91
100
|
order,
|
|
101
|
+
panelId,
|
|
92
102
|
registerPanel,
|
|
93
103
|
unregisterPanel
|
|
94
104
|
]);
|
|
95
|
-
const style = getPanelStyle(panelId);
|
|
96
|
-
const committedValuesRef = (0, $6e687094f9ca8395$export$b8f5890fc79d6aca)({
|
|
97
|
-
size: $45da0e827c614f1d$var$parseSizeFromStyle(style)
|
|
98
|
-
});
|
|
99
|
-
(0, $129b5b9a317dcc10$export$2e2bcd8739ae039)(()=>{
|
|
100
|
-
committedValuesRef.current.size = $45da0e827c614f1d$var$parseSizeFromStyle(style);
|
|
101
|
-
});
|
|
102
105
|
(0, $6e687094f9ca8395$export$d5a552a76deda3c2)(forwardedRef, ()=>({
|
|
103
106
|
collapse: ()=>collapsePanel(panelId),
|
|
104
107
|
expand: ()=>expandPanel(panelId),
|
|
@@ -173,7 +176,7 @@ function $cda3cc4b1114cf23$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
173
176
|
// Max-bounds check the panel being expanded first.
|
|
174
177
|
{
|
|
175
178
|
const pivotId = delta < 0 ? idAfter : idBefore;
|
|
176
|
-
const index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
179
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
|
|
177
180
|
const panel = panelsArray[index];
|
|
178
181
|
const baseSize = baseSizes[index];
|
|
179
182
|
const nextSize = $cda3cc4b1114cf23$var$safeResizePanel(panel, Math.abs(delta), baseSize, event);
|
|
@@ -185,14 +188,14 @@ function $cda3cc4b1114cf23$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
185
188
|
}
|
|
186
189
|
}
|
|
187
190
|
let pivotId = delta < 0 ? idBefore : idAfter;
|
|
188
|
-
let index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
191
|
+
let index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
|
|
189
192
|
while(true){
|
|
190
193
|
const panel = panelsArray[index];
|
|
191
194
|
const baseSize = baseSizes[index];
|
|
192
195
|
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
193
196
|
const nextSize = $cda3cc4b1114cf23$var$safeResizePanel(panel, 0 - deltaRemaining, baseSize, event);
|
|
194
197
|
if (baseSize !== nextSize) {
|
|
195
|
-
if (nextSize === 0 && baseSize > 0) panelSizeBeforeCollapse.set(panel.id, baseSize);
|
|
198
|
+
if (nextSize === 0 && baseSize > 0) panelSizeBeforeCollapse.set(panel.current.id, baseSize);
|
|
196
199
|
deltaApplied += baseSize - nextSize;
|
|
197
200
|
nextSizes[index] = nextSize;
|
|
198
201
|
if (deltaApplied.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)).localeCompare(Math.abs(delta).toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)), undefined, {
|
|
@@ -210,7 +213,7 @@ function $cda3cc4b1114cf23$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
210
213
|
if (deltaApplied === 0) return baseSizes;
|
|
211
214
|
// Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
|
|
212
215
|
pivotId = delta < 0 ? idAfter : idBefore;
|
|
213
|
-
index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
216
|
+
index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
|
|
214
217
|
nextSizes[index] = baseSizes[index] + deltaApplied;
|
|
215
218
|
return nextSizes;
|
|
216
219
|
}
|
|
@@ -218,7 +221,7 @@ function $cda3cc4b1114cf23$export$b8e48269e4faa934(panelsArray, prevSizes, nextS
|
|
|
218
221
|
nextSizes.forEach((nextSize, index)=>{
|
|
219
222
|
const prevSize = prevSizes[index];
|
|
220
223
|
if (prevSize !== nextSize) {
|
|
221
|
-
const { callbacksRef: callbacksRef , collapsible: collapsible } = panelsArray[index];
|
|
224
|
+
const { callbacksRef: callbacksRef , collapsible: collapsible } = panelsArray[index].current;
|
|
222
225
|
const { onCollapse: onCollapse , onResize: onResize } = callbacksRef.current;
|
|
223
226
|
if (onResize) onResize(nextSize);
|
|
224
227
|
if (collapsible && onCollapse) {
|
|
@@ -235,14 +238,14 @@ function $cda3cc4b1114cf23$export$5a5b0c1d38c23c3b(id, panelsArray) {
|
|
|
235
238
|
null,
|
|
236
239
|
null
|
|
237
240
|
];
|
|
238
|
-
const index = panelsArray.findIndex((panel)=>panel.id === id);
|
|
241
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === id);
|
|
239
242
|
if (index < 0) return [
|
|
240
243
|
null,
|
|
241
244
|
null
|
|
242
245
|
];
|
|
243
246
|
const isLastPanel = index === panelsArray.length - 1;
|
|
244
|
-
const idBefore = isLastPanel ? panelsArray[index - 1].id : id;
|
|
245
|
-
const idAfter = isLastPanel ? id : panelsArray[index + 1].id;
|
|
247
|
+
const idBefore = isLastPanel ? panelsArray[index - 1].current.id : id;
|
|
248
|
+
const idAfter = isLastPanel ? id : panelsArray[index + 1].current.id;
|
|
246
249
|
return [
|
|
247
250
|
idBefore,
|
|
248
251
|
idAfter
|
|
@@ -251,7 +254,7 @@ function $cda3cc4b1114cf23$export$5a5b0c1d38c23c3b(id, panelsArray) {
|
|
|
251
254
|
function $cda3cc4b1114cf23$export$6f43503e166de6fb(panels, id, sizes) {
|
|
252
255
|
if (panels.size === 1) return "100";
|
|
253
256
|
const panelsArray = $cda3cc4b1114cf23$export$a861c0ad45885494(panels);
|
|
254
|
-
const index = panelsArray.findIndex((panel)=>panel.id === id);
|
|
257
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === id);
|
|
255
258
|
const size = sizes[index];
|
|
256
259
|
if (size == null) return "0";
|
|
257
260
|
return size.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879));
|
|
@@ -283,14 +286,14 @@ function $cda3cc4b1114cf23$export$ae14931f0a0256a3(groupId) {
|
|
|
283
286
|
return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
|
|
284
287
|
}
|
|
285
288
|
function $cda3cc4b1114cf23$export$68d3a33c21dfbe27(groupId, handleId, panelsArray) {
|
|
286
|
-
var _panelsArray_index, _panelsArray_;
|
|
289
|
+
var _panelsArray_index, _panelsArray_index_current, _panelsArray_, _panelsArray__current;
|
|
287
290
|
const handle = $cda3cc4b1114cf23$export$2e27d3a347680388(handleId);
|
|
288
291
|
const handles = $cda3cc4b1114cf23$export$ae14931f0a0256a3(groupId);
|
|
289
292
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
290
|
-
var
|
|
291
|
-
const idBefore = (
|
|
292
|
-
var
|
|
293
|
-
const idAfter = (
|
|
293
|
+
var _panelsArray_index_current_id;
|
|
294
|
+
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;
|
|
295
|
+
var _panelsArray__current_id;
|
|
296
|
+
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;
|
|
294
297
|
return [
|
|
295
298
|
idBefore,
|
|
296
299
|
idAfter
|
|
@@ -298,8 +301,8 @@ function $cda3cc4b1114cf23$export$68d3a33c21dfbe27(groupId, handleId, panelsArra
|
|
|
298
301
|
}
|
|
299
302
|
function $cda3cc4b1114cf23$export$a861c0ad45885494(panels) {
|
|
300
303
|
return Array.from(panels.values()).sort((panelA, panelB)=>{
|
|
301
|
-
const orderA = panelA.order;
|
|
302
|
-
const orderB = panelB.order;
|
|
304
|
+
const orderA = panelA.current.order;
|
|
305
|
+
const orderB = panelB.current.order;
|
|
303
306
|
if (orderA == null && orderB == null) return 0;
|
|
304
307
|
else if (orderA == null) return -1;
|
|
305
308
|
else if (orderB == null) return 1;
|
|
@@ -308,7 +311,7 @@ function $cda3cc4b1114cf23$export$a861c0ad45885494(panels) {
|
|
|
308
311
|
}
|
|
309
312
|
function $cda3cc4b1114cf23$var$safeResizePanel(panel, delta, prevSize, event) {
|
|
310
313
|
const nextSizeUnsafe = prevSize + delta;
|
|
311
|
-
if (panel.collapsible) {
|
|
314
|
+
if (panel.current.collapsible) {
|
|
312
315
|
if (prevSize > 0) {
|
|
313
316
|
if (nextSizeUnsafe <= 0) return 0;
|
|
314
317
|
} else {
|
|
@@ -318,11 +321,11 @@ function $cda3cc4b1114cf23$var$safeResizePanel(panel, delta, prevSize, event) {
|
|
|
318
321
|
// Keyboard events should expand a collapsed panel to the min size,
|
|
319
322
|
// but mouse events should wait until the panel has reached its min size
|
|
320
323
|
// to avoid a visual flickering when dragging between collapsed and min size.
|
|
321
|
-
if (nextSizeUnsafe < panel.minSize) return 0;
|
|
324
|
+
if (nextSizeUnsafe < panel.current.minSize) return 0;
|
|
322
325
|
}
|
|
323
326
|
}
|
|
324
327
|
}
|
|
325
|
-
const nextSize = Math.min(panel.maxSize, Math.max(panel.minSize, nextSizeUnsafe));
|
|
328
|
+
const nextSize = Math.min(panel.current.maxSize, Math.max(panel.current.minSize, nextSizeUnsafe));
|
|
326
329
|
return nextSize;
|
|
327
330
|
}
|
|
328
331
|
|
|
@@ -352,12 +355,12 @@ function $a695670cc57a5969$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
352
355
|
let totalMaxSize = 0;
|
|
353
356
|
// A panel's effective min/max sizes also need to account for other panel's sizes.
|
|
354
357
|
panelsArray.forEach((panelData)=>{
|
|
355
|
-
if (panelData.id === idBefore) {
|
|
356
|
-
maxSize = panelData.maxSize;
|
|
357
|
-
minSize = panelData.minSize;
|
|
358
|
+
if (panelData.current.id === idBefore) {
|
|
359
|
+
maxSize = panelData.current.maxSize;
|
|
360
|
+
minSize = panelData.current.minSize;
|
|
358
361
|
} else {
|
|
359
|
-
totalMinSize += panelData.minSize;
|
|
360
|
-
totalMaxSize += panelData.maxSize;
|
|
362
|
+
totalMinSize += panelData.current.minSize;
|
|
363
|
+
totalMaxSize += panelData.current.maxSize;
|
|
361
364
|
}
|
|
362
365
|
});
|
|
363
366
|
const ariaValueMax = Math.min(maxSize, 100 - totalMinSize);
|
|
@@ -372,13 +375,13 @@ function $a695670cc57a5969$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
372
375
|
case "Enter":
|
|
373
376
|
{
|
|
374
377
|
event.preventDefault();
|
|
375
|
-
const index = panelsArray.findIndex((panel)=>panel.id === idBefore);
|
|
378
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === idBefore);
|
|
376
379
|
if (index >= 0) {
|
|
377
380
|
const panelData = panelsArray[index];
|
|
378
381
|
const size = sizes[index];
|
|
379
382
|
if (size != null) {
|
|
380
383
|
let delta = 0;
|
|
381
|
-
if (size.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)) <= panelData.minSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
|
|
384
|
+
if (size.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)) <= panelData.current.minSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
|
|
382
385
|
else delta = -(direction === "horizontal" ? width : height);
|
|
383
386
|
const nextSizes = (0, $cda3cc4b1114cf23$export$f50bae335f53943c)(event, panels, idBefore, idAfter, delta, sizes, panelSizeBeforeCollapse.current, null);
|
|
384
387
|
if (sizes !== nextSizes) setSizes(nextSizes);
|
|
@@ -518,11 +521,11 @@ function $47eee9224cfec8e8$export$354b17c0684607ed(event, groupId, handleId, pan
|
|
|
518
521
|
// If expanding from collapsed, they should snap back to their minSize.
|
|
519
522
|
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
|
|
520
523
|
const targetPanelId = movement < 0 ? idBefore : idAfter;
|
|
521
|
-
const targetPanelIndex = panelsArray.findIndex((panel)=>panel.id === targetPanelId);
|
|
524
|
+
const targetPanelIndex = panelsArray.findIndex((panel)=>panel.current.id === targetPanelId);
|
|
522
525
|
const targetPanel = panelsArray[targetPanelIndex];
|
|
523
|
-
if (targetPanel.collapsible) {
|
|
526
|
+
if (targetPanel.current.collapsible) {
|
|
524
527
|
const baseSize = baseSizes[targetPanelIndex];
|
|
525
|
-
if (baseSize === 0 || baseSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)) === targetPanel.minSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879))) movement = movement < 0 ? -targetPanel.minSize * groupSizeInPixels : targetPanel.minSize * groupSizeInPixels;
|
|
528
|
+
if (baseSize === 0 || baseSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)) === targetPanel.current.minSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879))) movement = movement < 0 ? -targetPanel.current.minSize * groupSizeInPixels : targetPanel.current.minSize * groupSizeInPixels;
|
|
526
529
|
}
|
|
527
530
|
return movement;
|
|
528
531
|
} else return $47eee9224cfec8e8$export$ec391ce65b083ed4(event, handleId, direction, dragOffset, dragHandleRect);
|
|
@@ -594,7 +597,7 @@ function $2e8572579e31d898$export$2e2bcd8739ae039(callback, durationMs = 10) {
|
|
|
594
597
|
// Pre-sorting by minSize allows remembering layouts even if panels are re-ordered/dragged.
|
|
595
598
|
function $f9cb001fbb908626$var$getSerializationKey(panels) {
|
|
596
599
|
return panels.map((panel)=>{
|
|
597
|
-
const { minSize: minSize , order: order } = panel;
|
|
600
|
+
const { minSize: minSize , order: order } = panel.current;
|
|
598
601
|
return order ? `${order}:${minSize}` : `${minSize}`;
|
|
599
602
|
}).sort((a, b)=>a.localeCompare(b)).join(",");
|
|
600
603
|
}
|
|
@@ -629,6 +632,14 @@ function $f9cb001fbb908626$export$af183b313c61be4f(autoSaveId, panels, sizes, st
|
|
|
629
632
|
}
|
|
630
633
|
|
|
631
634
|
|
|
635
|
+
function $ed0ab1c277bd13ad$export$1aa6024f7a345313() {
|
|
636
|
+
try {
|
|
637
|
+
return window, false;
|
|
638
|
+
} catch (error) {}
|
|
639
|
+
return true;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
|
|
632
643
|
const $cec4cafe75f3db78$var$debounceMap = {};
|
|
633
644
|
function $cec4cafe75f3db78$var$throwServerError() {
|
|
634
645
|
throw new Error('PanelGroup "storage" prop required for server rendering.');
|
|
@@ -737,15 +748,15 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
737
748
|
// 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.
|
|
738
749
|
// For now, these logic edge cases are left to the user to handle via props.
|
|
739
750
|
panelsArray.forEach((panel)=>{
|
|
740
|
-
totalMinSize += panel.minSize;
|
|
741
|
-
if (panel.defaultSize === null) panelsWithNullDefaultSize++;
|
|
742
|
-
else totalDefaultSize += panel.defaultSize;
|
|
751
|
+
totalMinSize += panel.current.minSize;
|
|
752
|
+
if (panel.current.defaultSize === null) panelsWithNullDefaultSize++;
|
|
753
|
+
else totalDefaultSize += panel.current.defaultSize;
|
|
743
754
|
});
|
|
744
755
|
if (totalDefaultSize > 100) throw new Error(`The sum of the defaultSize of all panels in a group cannot exceed 100.`);
|
|
745
756
|
else if (totalMinSize > 100) throw new Error(`The sum of the minSize of all panels in a group cannot exceed 100.`);
|
|
746
757
|
setSizes(panelsArray.map((panel)=>{
|
|
747
|
-
if (panel.defaultSize === null) return (100 - totalDefaultSize) / panelsWithNullDefaultSize;
|
|
748
|
-
return panel.defaultSize;
|
|
758
|
+
if (panel.current.defaultSize === null) return (100 - totalDefaultSize) / panelsWithNullDefaultSize;
|
|
759
|
+
return panel.current.defaultSize;
|
|
749
760
|
}));
|
|
750
761
|
}
|
|
751
762
|
}, [
|
|
@@ -768,18 +779,21 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
768
779
|
sizes,
|
|
769
780
|
storage
|
|
770
781
|
]);
|
|
771
|
-
const getPanelStyle = (0, $6e687094f9ca8395$export$35808ee640e87ca7)((id)=>{
|
|
782
|
+
const getPanelStyle = (0, $6e687094f9ca8395$export$35808ee640e87ca7)((id, defaultSize)=>{
|
|
772
783
|
const { panels: panels } = committedValuesRef.current;
|
|
773
784
|
// Before mounting, Panels will not yet have registered themselves.
|
|
774
785
|
// This includes server rendering.
|
|
775
786
|
// At this point the best we can do is render everything with the same size.
|
|
776
|
-
if (panels.size === 0)
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
787
|
+
if (panels.size === 0) {
|
|
788
|
+
if ((0, $ed0ab1c277bd13ad$export$1aa6024f7a345313)() && defaultSize == null) console.warn(`WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`);
|
|
789
|
+
return {
|
|
790
|
+
flexBasis: 0,
|
|
791
|
+
flexGrow: defaultSize != null ? defaultSize : undefined,
|
|
792
|
+
flexShrink: 1,
|
|
793
|
+
// Without this, Panel sizes may be unintentionally overridden by their content.
|
|
794
|
+
overflow: "hidden"
|
|
795
|
+
};
|
|
796
|
+
}
|
|
783
797
|
const flexGrow = (0, $cda3cc4b1114cf23$export$6f43503e166de6fb)(panels, id, sizes);
|
|
784
798
|
return {
|
|
785
799
|
flexBasis: 0,
|
|
@@ -796,11 +810,11 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
796
810
|
disablePointerEventsDuringResize,
|
|
797
811
|
sizes
|
|
798
812
|
]);
|
|
799
|
-
const registerPanel = (0, $6e687094f9ca8395$export$35808ee640e87ca7)((id,
|
|
813
|
+
const registerPanel = (0, $6e687094f9ca8395$export$35808ee640e87ca7)((id, panelRef)=>{
|
|
800
814
|
setPanels((prevPanels)=>{
|
|
801
815
|
if (prevPanels.has(id)) return prevPanels;
|
|
802
816
|
const nextPanels = new Map(prevPanels);
|
|
803
|
-
nextPanels.set(id,
|
|
817
|
+
nextPanels.set(id, panelRef);
|
|
804
818
|
return nextPanels;
|
|
805
819
|
});
|
|
806
820
|
}, []);
|
|
@@ -811,11 +825,13 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
811
825
|
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
812
826
|
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
|
|
813
827
|
if (idBefore == null || idAfter == null) return;
|
|
814
|
-
|
|
828
|
+
let movement = (0, $47eee9224cfec8e8$export$354b17c0684607ed)(event, groupId, handleId, panelsArray, direction, prevSizes, initialDragStateRef.current);
|
|
815
829
|
if (movement === 0) return;
|
|
816
830
|
const groupElement = (0, $cda3cc4b1114cf23$export$5e67632cf3550a9c)(groupId);
|
|
817
831
|
const rect = groupElement.getBoundingClientRect();
|
|
818
832
|
const isHorizontal = direction === "horizontal";
|
|
833
|
+
// Support RTL layouts
|
|
834
|
+
if (document.dir === "rtl" && isHorizontal) movement = -movement;
|
|
819
835
|
const size = isHorizontal ? rect.width : rect.height;
|
|
820
836
|
const delta = movement / size * 100;
|
|
821
837
|
const nextSizes = (0, $cda3cc4b1114cf23$export$f50bae335f53943c)(event, panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current, initialDragStateRef.current);
|
|
@@ -858,7 +874,7 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
858
874
|
const collapsePanel = (0, $6e687094f9ca8395$export$35808ee640e87ca7)((id)=>{
|
|
859
875
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
860
876
|
const panel = panels.get(id);
|
|
861
|
-
if (panel == null || !panel.collapsible) return;
|
|
877
|
+
if (panel == null || !panel.current.collapsible) return;
|
|
862
878
|
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
863
879
|
const index = panelsArray.indexOf(panel);
|
|
864
880
|
if (index < 0) return;
|
|
@@ -881,7 +897,7 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
881
897
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
882
898
|
const panel = panels.get(id);
|
|
883
899
|
if (panel == null) return;
|
|
884
|
-
const sizeBeforeCollapse = panelSizeBeforeCollapse.current.get(id) || panel.minSize;
|
|
900
|
+
const sizeBeforeCollapse = panelSizeBeforeCollapse.current.get(id) || panel.current.minSize;
|
|
885
901
|
if (!sizeBeforeCollapse) return;
|
|
886
902
|
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
887
903
|
const index = panelsArray.indexOf(panel);
|
|
@@ -909,8 +925,8 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
909
925
|
if (index < 0) return;
|
|
910
926
|
const currentSize = prevSizes[index];
|
|
911
927
|
if (currentSize === nextSize) return;
|
|
912
|
-
if (panel.collapsible && nextSize === 0) ;
|
|
913
|
-
else nextSize = Math.min(panel.maxSize, Math.max(panel.minSize, nextSize));
|
|
928
|
+
if (panel.current.collapsible && nextSize === 0) ;
|
|
929
|
+
else nextSize = Math.min(panel.current.maxSize, Math.max(panel.current.minSize, nextSize));
|
|
914
930
|
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$5a5b0c1d38c23c3b)(id, panelsArray);
|
|
915
931
|
if (idBefore == null || idAfter == null) return;
|
|
916
932
|
const isLastPanel = index === panelsArray.length - 1;
|