react-resizable-panels 0.0.29 → 0.0.31
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 +9 -0
- package/README.md +19 -17
- package/dist/react-resizable-panels.d.ts +5 -1
- package/dist/react-resizable-panels.d.ts.map +1 -1
- package/dist/react-resizable-panels.js +79 -25
- package/dist/react-resizable-panels.js.map +1 -1
- package/dist/react-resizable-panels.module.js +80 -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 +35 -6
- package/src/hooks/useWindowSplitterBehavior.ts +4 -1
- package/src/types.ts +1 -0
- package/src/utils/debounce.ts +16 -0
- package/src/utils/group.ts +13 -4
- package/src/utils/serialization.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.31
|
|
4
|
+
* [#71](https://github.com/bvaughn/react-resizable-panels/issues/71): Added `getSize` and `getCollapsed` to imperative API exposed by `Panel`.
|
|
5
|
+
* [#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.
|
|
6
|
+
* Fix edge case when expanding a panel via imperative API that was collapsed by user drag
|
|
7
|
+
|
|
8
|
+
## 0.0.30
|
|
9
|
+
* [#68](https://github.com/bvaughn/react-resizable-panels/pull/68): Reduce volume/frequency of local storage writes for `PanelGroup`s configured to _auto-save_.
|
|
10
|
+
* 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).
|
|
11
|
+
|
|
3
12
|
## 0.0.29
|
|
4
13
|
* [#58](https://github.com/bvaughn/react-resizable-panels/pull/58): Add imperative `collapse`, `expand`, and `resize` methods to `Panel`.
|
|
5
14
|
* [#64](https://github.com/bvaughn/react-resizable-panels/pull/64): Disable `pointer-events` inside of `Panel`s during resize. This avoid edge cases like nested iframes.
|
package/README.md
CHANGED
|
@@ -26,42 +26,44 @@ import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
|
|
|
26
26
|
| :----------- | :-------------------------- | :---
|
|
27
27
|
| `autoSaveId` | `?string` | Unique id used to auto-save group arrangement via `localStorage`
|
|
28
28
|
| `children` | `ReactNode` | Arbitrary React element(s)
|
|
29
|
-
| `className` | `?string` |
|
|
29
|
+
| `className` | `?string` | Class name to attach to root element
|
|
30
30
|
| `direction` | `"horizontal" \| "vertical"` | Group orientation
|
|
31
|
-
| `id` | `?string` |
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
31
|
+
| `id` | `?string` | Group id; falls back to `useId` when not provided
|
|
32
|
+
| `onLayout` | `?(sizes: number[]) => void` | Called when group layout changes
|
|
33
|
+
| `style` | `?CSSProperties` | CSS style to attach to root element
|
|
34
|
+
| `tagName` | `?string = "div"` | HTML element tag name for root element
|
|
34
35
|
|
|
35
36
|
### `Panel`
|
|
36
37
|
| prop | type | description
|
|
37
38
|
| :------------ | :------------------------------ | :---
|
|
38
39
|
| `children` | `ReactNode` | Arbitrary React element(s)
|
|
39
|
-
| `className` | `?string` |
|
|
40
|
+
| `className` | `?string` | Class name to attach to root element
|
|
40
41
|
| `collapsible` | `?boolean=false` | Panel should collapse when resized beyond its `minSize`
|
|
41
42
|
| `defaultSize` | `?number` | Initial size of panel (numeric value between 1-100)
|
|
42
|
-
| `id` | `?string` |
|
|
43
|
+
| `id` | `?string` | Panel id (unique within group); falls back to `useId` when not provided
|
|
43
44
|
| `maxSize` | `?number = 100` | Maximum allowable size of panel (numeric value between 1-100); defaults to `100`
|
|
44
45
|
| `minSize` | `?number = 10` | Minimum allowable size of panel (numeric value between 1-100); defaults to `10`
|
|
45
|
-
| `onCollapse` | `?(collapsed: boolean) => void` |
|
|
46
|
-
| `onResize` | `?(size: number) => void` |
|
|
46
|
+
| `onCollapse` | `?(collapsed: boolean) => void` | Called when panel is collapsed; `collapsed` boolean parameter reflecting the new state
|
|
47
|
+
| `onResize` | `?(size: number) => void` | Called when panel is resized; `size` parameter is a numeric value between 1-100
|
|
47
48
|
| `order` | `?number` | Order of panel within group; required for groups with conditionally rendered panels
|
|
48
|
-
| `style` | `?CSSProperties` |
|
|
49
|
-
| `tagName` | `?string = "div"` |
|
|
49
|
+
| `style` | `?CSSProperties` | CSS style to attach to root element
|
|
50
|
+
| `tagName` | `?string = "div"` | HTML element tag name for root element
|
|
50
51
|
|
|
51
52
|
`Panel` components also expose an imperative API for manual resizing:
|
|
52
53
|
| method | description
|
|
53
54
|
| :--------------------------- | :---
|
|
54
|
-
| `collapse`
|
|
55
|
-
| `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`).
|
|
56
59
|
| `resize(percentage: number)` | Resize panel to the specified _percentage_ (`1 - 100`).
|
|
57
60
|
|
|
58
|
-
|
|
59
61
|
### `PanelResizeHandle`
|
|
60
62
|
| prop | type | description
|
|
61
63
|
| :------------ | :---------------- | :---
|
|
62
64
|
| `children` | `?ReactNode` | Custom drag UI; can be any arbitrary React element(s)
|
|
63
|
-
| `className` | `?string` |
|
|
65
|
+
| `className` | `?string` | Class name to attach to root element
|
|
64
66
|
| `disabled` | `?boolean` | Disable drag handle
|
|
65
|
-
| `id` | `?string` |
|
|
66
|
-
| `style` | `?CSSProperties` |
|
|
67
|
-
| `tagName` | `?string = "div"` |
|
|
67
|
+
| `id` | `?string` | Resize handle id (unique within group); falls back to `useId` when not provided
|
|
68
|
+
| `style` | `?CSSProperties` | CSS style to attach to root element
|
|
69
|
+
| `tagName` | `?string = "div"` | HTML element tag name for root element
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RefObject, CSSProperties, ElementType, ReactNode } from "react";
|
|
2
2
|
type Direction = "horizontal" | "vertical";
|
|
3
|
+
type PanelGroupOnLayout = (sizes: number[]) => void;
|
|
3
4
|
type PanelOnCollapse = (collapsed: boolean) => void;
|
|
4
5
|
type PanelOnResize = (size: number) => void;
|
|
5
6
|
type PanelData = {
|
|
@@ -32,6 +33,8 @@ export type PanelProps = {
|
|
|
32
33
|
export type ImperativePanelHandle = {
|
|
33
34
|
collapse: () => void;
|
|
34
35
|
expand: () => void;
|
|
36
|
+
getCollapsed(): boolean;
|
|
37
|
+
getSize(): number;
|
|
35
38
|
resize: (percentage: number) => void;
|
|
36
39
|
};
|
|
37
40
|
export const Panel: import("react").ForwardRefExoticComponent<PanelProps & import("react").RefAttributes<ImperativePanelHandle>>;
|
|
@@ -41,10 +44,11 @@ export type PanelGroupProps = {
|
|
|
41
44
|
className?: string;
|
|
42
45
|
direction: Direction;
|
|
43
46
|
id?: string | null;
|
|
47
|
+
onLayout?: PanelGroupOnLayout;
|
|
44
48
|
style?: CSSProperties;
|
|
45
49
|
tagName?: ElementType;
|
|
46
50
|
};
|
|
47
|
-
export function PanelGroup({ autoSaveId, children, className: classNameFromProps, direction, id: idFromProps, style: styleFromProps, tagName: Type, }: PanelGroupProps): import("react").FunctionComponentElement<import("react").ProviderProps<{
|
|
51
|
+
export function PanelGroup({ autoSaveId, children, className: classNameFromProps, direction, id: idFromProps, onLayout, style: styleFromProps, tagName: Type, }: PanelGroupProps): import("react").FunctionComponentElement<import("react").ProviderProps<{
|
|
48
52
|
activeHandleId: string;
|
|
49
53
|
collapsePanel: (id: string) => void;
|
|
50
54
|
direction: "horizontal" | "vertical";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";AEEA,iBAAwB,YAAY,GAAG,UAAU,CAAC;AAElD,uBAA8B,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;AAC3D,qBAA4B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,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
|
|
@@ -374,7 +396,7 @@ function $f5af57c8e042a4ad$export$c4dfce035d43d1e0(event) {
|
|
|
374
396
|
|
|
375
397
|
|
|
376
398
|
|
|
377
|
-
function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committedValuesRef , groupId: groupId , panels: panels , setSizes: setSizes , sizes: sizes }) {
|
|
399
|
+
function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committedValuesRef , groupId: groupId , panels: panels , setSizes: setSizes , sizes: sizes , panelSizeBeforeCollapse: panelSizeBeforeCollapse }) {
|
|
378
400
|
(0, $b2QPe$react.useEffect)(()=>{
|
|
379
401
|
const { direction: direction , panels: panels } = committedValuesRef.current;
|
|
380
402
|
const groupElement = (0, $d520236daad9c5d5$export$5e67632cf3550a9c)(groupId);
|
|
@@ -417,7 +439,7 @@ function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
417
439
|
let delta = 0;
|
|
418
440
|
if (size.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879)) <= panelData.minSize.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
|
|
419
441
|
else delta = -(direction === "horizontal" ? width : height);
|
|
420
|
-
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, sizes);
|
|
442
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, sizes, panelSizeBeforeCollapse.current);
|
|
421
443
|
if (sizes !== nextSizes) setSizes(nextSizes);
|
|
422
444
|
}
|
|
423
445
|
}
|
|
@@ -520,10 +542,31 @@ function $102aa6bc0f99b2b3$export$d395b5dfd066a659(state) {
|
|
|
520
542
|
}
|
|
521
543
|
|
|
522
544
|
|
|
523
|
-
function $
|
|
545
|
+
function $0f7a23424493ebd6$export$2e2bcd8739ae039(callback, durationMs = 10) {
|
|
546
|
+
let timeoutId = null;
|
|
547
|
+
let callable = (...args)=>{
|
|
548
|
+
clearTimeout(timeoutId);
|
|
549
|
+
timeoutId = setTimeout(()=>{
|
|
550
|
+
callback(...args);
|
|
551
|
+
}, durationMs);
|
|
552
|
+
};
|
|
553
|
+
return callable;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
// Limit the frequency of localStorage updates.
|
|
558
|
+
const $19bf0050f73d236b$var$savePanelGroupLayoutDebounced = (0, $0f7a23424493ebd6$export$2e2bcd8739ae039)((0, $e045b0dd313f33c7$export$af183b313c61be4f), 100);
|
|
559
|
+
function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , children: children = null , className: classNameFromProps = "" , direction: direction , id: idFromProps = null , onLayout: onLayout = null , style: styleFromProps = {} , tagName: Type = "div" }) {
|
|
524
560
|
const groupId = (0, $6d548a0d130941e3$export$2e2bcd8739ae039)(idFromProps);
|
|
525
561
|
const [activeHandleId, setActiveHandleId] = (0, $b2QPe$react.useState)(null);
|
|
526
562
|
const [panels, setPanels] = (0, $b2QPe$react.useState)(new Map());
|
|
563
|
+
// Use a ref to guard against users passing inline props
|
|
564
|
+
const callbacksRef = (0, $b2QPe$react.useRef)({
|
|
565
|
+
onLayout: onLayout
|
|
566
|
+
});
|
|
567
|
+
(0, $b2QPe$react.useEffect)(()=>{
|
|
568
|
+
callbacksRef.current.onLayout = onLayout;
|
|
569
|
+
});
|
|
527
570
|
// 0-1 values representing the relative size of each panel.
|
|
528
571
|
const [sizes, setSizes] = (0, $b2QPe$react.useState)([]);
|
|
529
572
|
const dragOffsetRef = (0, $b2QPe$react.useRef)(0);
|
|
@@ -545,8 +588,19 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
545
588
|
groupId: groupId,
|
|
546
589
|
panels: panels,
|
|
547
590
|
setSizes: setSizes,
|
|
548
|
-
sizes: sizes
|
|
591
|
+
sizes: sizes,
|
|
592
|
+
panelSizeBeforeCollapse: panelSizeBeforeCollapse
|
|
549
593
|
});
|
|
594
|
+
// Notify external code when sizes have changed.
|
|
595
|
+
(0, $b2QPe$react.useEffect)(()=>{
|
|
596
|
+
const { onLayout: onLayout } = callbacksRef.current;
|
|
597
|
+
if (onLayout) {
|
|
598
|
+
const { sizes: sizes } = committedValuesRef.current;
|
|
599
|
+
onLayout(sizes);
|
|
600
|
+
}
|
|
601
|
+
}, [
|
|
602
|
+
sizes
|
|
603
|
+
]);
|
|
550
604
|
// Once all panels have registered themselves,
|
|
551
605
|
// Compute the initial sizes based on default weights.
|
|
552
606
|
// This assumes that panels register during initial mount (no conditional rendering)!
|
|
@@ -592,7 +646,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
592
646
|
if (autoSaveId) {
|
|
593
647
|
if (sizes.length === 0 || sizes.length !== panels.size) return;
|
|
594
648
|
const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
|
|
595
|
-
|
|
649
|
+
$19bf0050f73d236b$var$savePanelGroupLayoutDebounced(autoSaveId, panelsArray, sizes);
|
|
596
650
|
}
|
|
597
651
|
}, [
|
|
598
652
|
autoSaveId,
|
|
@@ -649,7 +703,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
649
703
|
const isHorizontal = direction === "horizontal";
|
|
650
704
|
const size = isHorizontal ? rect.width : rect.height;
|
|
651
705
|
const delta = movement / size * 100;
|
|
652
|
-
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
|
|
706
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current);
|
|
653
707
|
if (prevSizes === nextSizes) {
|
|
654
708
|
// If the pointer has moved too far to resize the panel any further,
|
|
655
709
|
// update the cursor style for a visual clue.
|
|
@@ -691,7 +745,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
691
745
|
if (idBefore == null || idAfter == null) return;
|
|
692
746
|
const isLastPanel = index === panelsArray.length - 1;
|
|
693
747
|
const delta = isLastPanel ? currentSize : 0 - currentSize;
|
|
694
|
-
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
|
|
748
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current);
|
|
695
749
|
if (prevSizes !== nextSizes) {
|
|
696
750
|
// If resize change handlers have been declared, this is the time to call them.
|
|
697
751
|
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
@@ -714,7 +768,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
714
768
|
if (idBefore == null || idAfter == null) return;
|
|
715
769
|
const isLastPanel = index === panelsArray.length - 1;
|
|
716
770
|
const delta = isLastPanel ? 0 - sizeBeforeCollapse : sizeBeforeCollapse;
|
|
717
|
-
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
|
|
771
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current);
|
|
718
772
|
if (prevSizes !== nextSizes) {
|
|
719
773
|
// If resize change handlers have been declared, this is the time to call them.
|
|
720
774
|
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
@@ -734,7 +788,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
734
788
|
if (idBefore == null || idAfter == null) return;
|
|
735
789
|
const isLastPanel = index === panelsArray.length - 1;
|
|
736
790
|
const delta = isLastPanel ? currentSize - nextSize : nextSize - currentSize;
|
|
737
|
-
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
|
|
791
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current);
|
|
738
792
|
if (prevSizes !== nextSizes) {
|
|
739
793
|
// If resize change handlers have been declared, this is the time to call them.
|
|
740
794
|
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|