react-resizable-panels 0.0.30 → 0.0.32
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 +4 -2
- package/dist/react-resizable-panels.d.ts +2 -0
- package/dist/react-resizable-panels.d.ts.map +1 -1
- package/dist/react-resizable-panels.js +69 -25
- package/dist/react-resizable-panels.js.map +1 -1
- package/dist/react-resizable-panels.module.js +70 -26
- package/dist/react-resizable-panels.module.js.map +1 -1
- package/package.json +1 -1
- package/src/Panel.ts +37 -10
- package/src/PanelGroup.ts +33 -5
- package/src/hooks/useWindowSplitterBehavior.ts +4 -1
- package/src/utils/group.ts +21 -6
- package/src/utils/serialization.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.32
|
|
4
|
+
* [#75](https://github.com/bvaughn/react-resizable-panels/issues/75): Ensure `Panel` and `PanelGroup` callbacks are always called after mounting.
|
|
5
|
+
|
|
6
|
+
## 0.0.31
|
|
7
|
+
* [#71](https://github.com/bvaughn/react-resizable-panels/issues/71): Added `getSize` and `getCollapsed` to imperative API exposed by `Panel`.
|
|
8
|
+
* [#67](https://github.com/bvaughn/react-resizable-panels/issues/67), [#72](https://github.com/bvaughn/react-resizable-panels/issues/72): Removed nullish coalescing operator (`??`) because it caused problems with default create-react-app configuration.
|
|
9
|
+
* Fix edge case when expanding a panel via imperative API that was collapsed by user drag
|
|
10
|
+
|
|
3
11
|
## 0.0.30
|
|
4
12
|
* [#68](https://github.com/bvaughn/react-resizable-panels/pull/68): Reduce volume/frequency of local storage writes for `PanelGroup`s configured to _auto-save_.
|
|
5
13
|
* Added `onLayout` prop to `PanelGroup` to be called when group layout changes. Note that some form of debouncing is recommended before processing these values (e.g. saving to a database).
|
package/README.md
CHANGED
|
@@ -52,8 +52,10 @@ import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
|
|
|
52
52
|
`Panel` components also expose an imperative API for manual resizing:
|
|
53
53
|
| method | description
|
|
54
54
|
| :--------------------------- | :---
|
|
55
|
-
| `collapse`
|
|
56
|
-
| `expand`
|
|
55
|
+
| `collapse()` | If panel is `collapsible`, collapse it fully.
|
|
56
|
+
| `expand()` | If panel is currently _collapsed_, expand it to its most recent size.
|
|
57
|
+
| `getCollapsed(): boolean` | Returns `true` if the panel is currently _collapsed_ (`size === 0`).
|
|
58
|
+
| `getSize(): number` | Returns the most recently commited size of the panel as a percentage (`1 - 100`).
|
|
57
59
|
| `resize(percentage: number)` | Resize panel to the specified _percentage_ (`1 - 100`).
|
|
58
60
|
|
|
59
61
|
### `PanelResizeHandle`
|
|
@@ -33,6 +33,8 @@ export type PanelProps = {
|
|
|
33
33
|
export type ImperativePanelHandle = {
|
|
34
34
|
collapse: () => void;
|
|
35
35
|
expand: () => void;
|
|
36
|
+
getCollapsed(): boolean;
|
|
37
|
+
getSize(): number;
|
|
36
38
|
resize: (percentage: number) => void;
|
|
37
39
|
};
|
|
38
40
|
export const Panel: import("react").ForwardRefExoticComponent<PanelProps & import("react").RefAttributes<ImperativePanelHandle>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";AEEA,iBAAwB,YAAY,GAAG,UAAU,CAAC;AAElD,0BAAiC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;AAC3D,uBAA8B,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;AAC3D,qBAA4B,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAEnD,iBAAwB;IACtB,YAAY,EAAE,UAAU;QACtB,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;QACnC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;KAChC,CAAC,CAAC;IACH,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAA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AAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF,2BAA2B,EACzB,UAAU,EACV,QAAe,EACf,SAAS,EAAE,kBAAuB,EAClC,SAAS,EACT,EAAE,EAAE,WAAkB,EACtB,QAAe,EACf,KAAK,EAAE,cAAmB,EAC1B,OAAO,EAAE,IAAY,GACtB,EAAE,eAAe;;;;;;;;;;;;;IAyejB;ACvhBD,qCAAqC;IACnC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF,kCAAkC,EAChC,QAAe,EACf,SAAS,EAAE,kBAAuB,EAClC,QAAgB,EAChB,EAAE,EAAE,WAAkB,EACtB,KAAK,EAAE,cAAmB,EAC1B,OAAO,EAAE,IAAY,GACtB,EAAE,sBAAsB,0FA+GxB","sources":["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/utils/serialization.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/coordinates.ts","packages/react-resizable-panels/src/src/hooks/useWindowSplitterBehavior.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/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,"import { Panel } from \"./Panel\";\nimport { PanelGroup } from \"./PanelGroup\";\nimport { PanelResizeHandle } from \"./PanelResizeHandle\";\n\nimport type { ImperativePanelHandle, PanelProps } from \"./Panel\";\nimport type { PanelGroupProps } from \"./PanelGroup\";\nimport type { PanelResizeHandleProps } from \"./PanelResizeHandle\";\n\nexport {\n Panel,\n PanelGroup,\n PanelResizeHandle,\n\n // TypeScript types\n ImperativePanelHandle,\n PanelGroupProps,\n PanelProps,\n PanelResizeHandleProps,\n};\n"],"names":[],"version":3,"file":"react-resizable-panels.d.ts.map"}
|
|
@@ -37,16 +37,6 @@ function $4b51bd7b90b9da8b$var$PanelWithForwardedRef({ children: children = null
|
|
|
37
37
|
if (context === null) throw Error(`Panel components must be rendered within a PanelGroup container`);
|
|
38
38
|
const panelId = (0, $6d548a0d130941e3$export$2e2bcd8739ae039)(idFromProps);
|
|
39
39
|
const { collapsePanel: collapsePanel , expandPanel: expandPanel , getPanelStyle: getPanelStyle , registerPanel: registerPanel , resizePanel: resizePanel , unregisterPanel: unregisterPanel } = context;
|
|
40
|
-
(0, $b2QPe$react.useImperativeHandle)(forwardedRef, ()=>({
|
|
41
|
-
collapse: ()=>collapsePanel(panelId),
|
|
42
|
-
expand: ()=>expandPanel(panelId),
|
|
43
|
-
resize: (percentage)=>resizePanel(panelId, percentage)
|
|
44
|
-
}), [
|
|
45
|
-
collapsePanel,
|
|
46
|
-
expandPanel,
|
|
47
|
-
panelId,
|
|
48
|
-
resizePanel
|
|
49
|
-
]);
|
|
50
40
|
// Use a ref to guard against users passing inline props
|
|
51
41
|
const callbacksRef = (0, $b2QPe$react.useRef)({
|
|
52
42
|
onCollapse: onCollapse,
|
|
@@ -91,6 +81,28 @@ function $4b51bd7b90b9da8b$var$PanelWithForwardedRef({ children: children = null
|
|
|
91
81
|
unregisterPanel
|
|
92
82
|
]);
|
|
93
83
|
const style = getPanelStyle(panelId);
|
|
84
|
+
const committedValuesRef = (0, $b2QPe$react.useRef)({
|
|
85
|
+
size: $4b51bd7b90b9da8b$var$parseSizeFromStyle(style)
|
|
86
|
+
});
|
|
87
|
+
(0, $967abed3d1bd1fe9$export$2e2bcd8739ae039)(()=>{
|
|
88
|
+
committedValuesRef.current.size = $4b51bd7b90b9da8b$var$parseSizeFromStyle(style);
|
|
89
|
+
});
|
|
90
|
+
(0, $b2QPe$react.useImperativeHandle)(forwardedRef, ()=>({
|
|
91
|
+
collapse: ()=>collapsePanel(panelId),
|
|
92
|
+
expand: ()=>expandPanel(panelId),
|
|
93
|
+
getCollapsed () {
|
|
94
|
+
return committedValuesRef.current.size === 0;
|
|
95
|
+
},
|
|
96
|
+
getSize () {
|
|
97
|
+
return committedValuesRef.current.size;
|
|
98
|
+
},
|
|
99
|
+
resize: (percentage)=>resizePanel(panelId, percentage)
|
|
100
|
+
}), [
|
|
101
|
+
collapsePanel,
|
|
102
|
+
expandPanel,
|
|
103
|
+
panelId,
|
|
104
|
+
resizePanel
|
|
105
|
+
]);
|
|
94
106
|
return (0, $b2QPe$react.createElement)(Type, {
|
|
95
107
|
children: children,
|
|
96
108
|
className: classNameFromProps,
|
|
@@ -114,6 +126,12 @@ const $4b51bd7b90b9da8b$export$2ddb90ad54e5f587 = (0, $b2QPe$react.forwardRef)((
|
|
|
114
126
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
115
127
|
$4b51bd7b90b9da8b$var$PanelWithForwardedRef.displayName = "Panel";
|
|
116
128
|
$4b51bd7b90b9da8b$export$2ddb90ad54e5f587.displayName = "forwardRef(Panel)";
|
|
129
|
+
// HACK
|
|
130
|
+
function $4b51bd7b90b9da8b$var$parseSizeFromStyle(style) {
|
|
131
|
+
const { flexGrow: flexGrow } = style;
|
|
132
|
+
if (typeof flexGrow === "string") return parseFloat(flexGrow);
|
|
133
|
+
else return flexGrow;
|
|
134
|
+
}
|
|
117
135
|
|
|
118
136
|
|
|
119
137
|
|
|
@@ -142,7 +160,7 @@ function $e045b0dd313f33c7$export$9c80c6617f0386da(autoSaveId, panels) {
|
|
|
142
160
|
const state = $e045b0dd313f33c7$var$loadSerializedPanelGroupState(autoSaveId);
|
|
143
161
|
if (state) {
|
|
144
162
|
const key = $e045b0dd313f33c7$var$getSerializationKey(panels);
|
|
145
|
-
return state[key]
|
|
163
|
+
return state[key] || null;
|
|
146
164
|
}
|
|
147
165
|
return null;
|
|
148
166
|
}
|
|
@@ -162,7 +180,7 @@ const $3237bc4a138172cd$export$d6d3992f3becc879 = 10;
|
|
|
162
180
|
|
|
163
181
|
|
|
164
182
|
|
|
165
|
-
function $d520236daad9c5d5$export$f50bae335f53943c(panels, idBefore, idAfter, delta, prevSizes) {
|
|
183
|
+
function $d520236daad9c5d5$export$f50bae335f53943c(panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse) {
|
|
166
184
|
if (delta === 0) return prevSizes;
|
|
167
185
|
const panelsArray = $d520236daad9c5d5$export$a861c0ad45885494(panels);
|
|
168
186
|
const nextSizes = prevSizes.concat();
|
|
@@ -182,7 +200,10 @@ function $d520236daad9c5d5$export$f50bae335f53943c(panels, idBefore, idAfter, de
|
|
|
182
200
|
const prevSize = prevSizes[index];
|
|
183
201
|
const nextSize = $d520236daad9c5d5$var$safeResizePanel(panel, Math.abs(delta), prevSize);
|
|
184
202
|
if (prevSize === nextSize) return prevSizes;
|
|
185
|
-
else
|
|
203
|
+
else {
|
|
204
|
+
if (nextSize === 0 && prevSize > 0) panelSizeBeforeCollapse.set(pivotId, prevSize);
|
|
205
|
+
delta = delta < 0 ? prevSize - nextSize : nextSize - prevSize;
|
|
206
|
+
}
|
|
186
207
|
}
|
|
187
208
|
let pivotId1 = delta < 0 ? idBefore : idAfter;
|
|
188
209
|
let index1 = panelsArray.findIndex((panel)=>panel.id === pivotId1);
|
|
@@ -191,6 +212,7 @@ function $d520236daad9c5d5$export$f50bae335f53943c(panels, idBefore, idAfter, de
|
|
|
191
212
|
const prevSize1 = prevSizes[index1];
|
|
192
213
|
const nextSize1 = $d520236daad9c5d5$var$safeResizePanel(panel1, 0 - Math.abs(delta), prevSize1);
|
|
193
214
|
if (prevSize1 !== nextSize1) {
|
|
215
|
+
if (nextSize1 === 0 && prevSize1 > 0) panelSizeBeforeCollapse.set(panel1.id, prevSize1);
|
|
194
216
|
deltaApplied += prevSize1 - nextSize1;
|
|
195
217
|
nextSizes[index1] = nextSize1;
|
|
196
218
|
if (deltaApplied.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879)) >= delta.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879))) break;
|
|
@@ -268,7 +290,7 @@ function $d520236daad9c5d5$export$2e27d3a347680388(id) {
|
|
|
268
290
|
function $d520236daad9c5d5$export$96a40be80fb6c3c8(id) {
|
|
269
291
|
const handles = $d520236daad9c5d5$export$8d0cd3c32ddc045e();
|
|
270
292
|
const index = handles.findIndex((handle)=>handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
271
|
-
return index
|
|
293
|
+
return index || null;
|
|
272
294
|
}
|
|
273
295
|
function $d520236daad9c5d5$export$8d0cd3c32ddc045e() {
|
|
274
296
|
return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id]`));
|
|
@@ -280,8 +302,8 @@ function $d520236daad9c5d5$export$68d3a33c21dfbe27(groupId, handleId, panelsArra
|
|
|
280
302
|
const handle = $d520236daad9c5d5$export$2e27d3a347680388(handleId);
|
|
281
303
|
const handles = $d520236daad9c5d5$export$ae14931f0a0256a3(groupId);
|
|
282
304
|
const index = handles.indexOf(handle);
|
|
283
|
-
const idBefore = panelsArray[index]?.id
|
|
284
|
-
const idAfter = panelsArray[index + 1]?.id
|
|
305
|
+
const idBefore = panelsArray[index]?.id || null;
|
|
306
|
+
const idAfter = panelsArray[index + 1]?.id || null;
|
|
285
307
|
return [
|
|
286
308
|
idBefore,
|
|
287
309
|
idAfter
|
|
@@ -293,7 +315,11 @@ function $d520236daad9c5d5$export$a861c0ad45885494(panels) {
|
|
|
293
315
|
function $d520236daad9c5d5$var$safeResizePanel(panel, delta, prevSize) {
|
|
294
316
|
const nextSizeUnsafe = prevSize + delta;
|
|
295
317
|
if (panel.collapsible) {
|
|
296
|
-
if (
|
|
318
|
+
if (prevSize > 0) {
|
|
319
|
+
if (nextSizeUnsafe <= 0) return 0;
|
|
320
|
+
} else {
|
|
321
|
+
if (nextSizeUnsafe < panel.minSize) return 0;
|
|
322
|
+
}
|
|
297
323
|
}
|
|
298
324
|
const nextSize = Math.min(panel.maxSize, Math.max(panel.minSize, nextSizeUnsafe));
|
|
299
325
|
return nextSize;
|
|
@@ -374,7 +400,7 @@ function $f5af57c8e042a4ad$export$c4dfce035d43d1e0(event) {
|
|
|
374
400
|
|
|
375
401
|
|
|
376
402
|
|
|
377
|
-
function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committedValuesRef , groupId: groupId , panels: panels , setSizes: setSizes , sizes: sizes }) {
|
|
403
|
+
function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committedValuesRef , groupId: groupId , panels: panels , setSizes: setSizes , sizes: sizes , panelSizeBeforeCollapse: panelSizeBeforeCollapse }) {
|
|
378
404
|
(0, $b2QPe$react.useEffect)(()=>{
|
|
379
405
|
const { direction: direction , panels: panels } = committedValuesRef.current;
|
|
380
406
|
const groupElement = (0, $d520236daad9c5d5$export$5e67632cf3550a9c)(groupId);
|
|
@@ -417,7 +443,7 @@ function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
417
443
|
let delta = 0;
|
|
418
444
|
if (size.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879)) <= panelData.minSize.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
|
|
419
445
|
else delta = -(direction === "horizontal" ? width : height);
|
|
420
|
-
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, sizes);
|
|
446
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, sizes, panelSizeBeforeCollapse.current);
|
|
421
447
|
if (sizes !== nextSizes) setSizes(nextSizes);
|
|
422
448
|
}
|
|
423
449
|
}
|
|
@@ -547,6 +573,8 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
547
573
|
});
|
|
548
574
|
// 0-1 values representing the relative size of each panel.
|
|
549
575
|
const [sizes, setSizes] = (0, $b2QPe$react.useState)([]);
|
|
576
|
+
// Resize is calculated by the distance between the current pointer event and the resize handle being "dragged"
|
|
577
|
+
// This value accounts for the initial offset when the touch/click starts, so the handle doesn't appear to "jump"
|
|
550
578
|
const dragOffsetRef = (0, $b2QPe$react.useRef)(0);
|
|
551
579
|
// Used to support imperative collapse/expand API.
|
|
552
580
|
const panelSizeBeforeCollapse = (0, $b2QPe$react.useRef)(new Map());
|
|
@@ -566,14 +594,30 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
566
594
|
groupId: groupId,
|
|
567
595
|
panels: panels,
|
|
568
596
|
setSizes: setSizes,
|
|
569
|
-
sizes: sizes
|
|
597
|
+
sizes: sizes,
|
|
598
|
+
panelSizeBeforeCollapse: panelSizeBeforeCollapse
|
|
570
599
|
});
|
|
571
600
|
// Notify external code when sizes have changed.
|
|
572
601
|
(0, $b2QPe$react.useEffect)(()=>{
|
|
573
602
|
const { onLayout: onLayout } = callbacksRef.current;
|
|
574
603
|
if (onLayout) {
|
|
575
604
|
const { sizes: sizes } = committedValuesRef.current;
|
|
576
|
-
|
|
605
|
+
// Don't commit layout until all panels have registered and re-rendered with their actual sizes.
|
|
606
|
+
if (sizes.length > 0) onLayout(sizes);
|
|
607
|
+
}
|
|
608
|
+
}, [
|
|
609
|
+
sizes
|
|
610
|
+
]);
|
|
611
|
+
// Notify Panel listeners about their initial sizes and collapsed state after mount.
|
|
612
|
+
// Subsequent changes will be called by the resizeHandler.
|
|
613
|
+
const didNotifyCallbacksAfterMountRef = (0, $b2QPe$react.useRef)(false);
|
|
614
|
+
(0, $967abed3d1bd1fe9$export$2e2bcd8739ae039)(()=>{
|
|
615
|
+
if (didNotifyCallbacksAfterMountRef.current) return;
|
|
616
|
+
const { panels: panels , sizes: sizes } = committedValuesRef.current;
|
|
617
|
+
if (sizes.length > 0) {
|
|
618
|
+
didNotifyCallbacksAfterMountRef.current = true;
|
|
619
|
+
const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
|
|
620
|
+
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, [], sizes);
|
|
577
621
|
}
|
|
578
622
|
}, [
|
|
579
623
|
sizes
|
|
@@ -680,7 +724,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
680
724
|
const isHorizontal = direction === "horizontal";
|
|
681
725
|
const size = isHorizontal ? rect.width : rect.height;
|
|
682
726
|
const delta = movement / size * 100;
|
|
683
|
-
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
|
|
727
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current);
|
|
684
728
|
if (prevSizes === nextSizes) {
|
|
685
729
|
// If the pointer has moved too far to resize the panel any further,
|
|
686
730
|
// update the cursor style for a visual clue.
|
|
@@ -722,7 +766,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
722
766
|
if (idBefore == null || idAfter == null) return;
|
|
723
767
|
const isLastPanel = index === panelsArray.length - 1;
|
|
724
768
|
const delta = isLastPanel ? currentSize : 0 - currentSize;
|
|
725
|
-
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
|
|
769
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current);
|
|
726
770
|
if (prevSizes !== nextSizes) {
|
|
727
771
|
// If resize change handlers have been declared, this is the time to call them.
|
|
728
772
|
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
@@ -745,7 +789,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
745
789
|
if (idBefore == null || idAfter == null) return;
|
|
746
790
|
const isLastPanel = index === panelsArray.length - 1;
|
|
747
791
|
const delta = isLastPanel ? 0 - sizeBeforeCollapse : sizeBeforeCollapse;
|
|
748
|
-
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
|
|
792
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current);
|
|
749
793
|
if (prevSizes !== nextSizes) {
|
|
750
794
|
// If resize change handlers have been declared, this is the time to call them.
|
|
751
795
|
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
@@ -765,7 +809,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
765
809
|
if (idBefore == null || idAfter == null) return;
|
|
766
810
|
const isLastPanel = index === panelsArray.length - 1;
|
|
767
811
|
const delta = isLastPanel ? currentSize - nextSize : nextSize - currentSize;
|
|
768
|
-
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
|
|
812
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current);
|
|
769
813
|
if (prevSizes !== nextSizes) {
|
|
770
814
|
// If resize change handlers have been declared, this is the time to call them.
|
|
771
815
|
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|