react-resizable-panels 0.0.27 → 0.0.29
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 +8 -0
- package/dist/react-resizable-panels.d.ts +12 -4
- package/dist/react-resizable-panels.d.ts.map +1 -1
- package/dist/react-resizable-panels.js +158 -27
- package/dist/react-resizable-panels.js.map +1 -1
- package/dist/react-resizable-panels.module.js +157 -26
- package/dist/react-resizable-panels.module.js.map +1 -1
- package/package.json +1 -1
- package/src/Panel.ts +44 -9
- package/src/PanelContexts.ts +3 -0
- package/src/PanelGroup.ts +175 -24
- package/src/PanelResizeHandle.ts +1 -1
- package/src/hooks/useIsomorphicEffect.ts +13 -0
- package/src/index.ts +18 -4
- package/src/utils/group.ts +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.29
|
|
4
|
+
* [#58](https://github.com/bvaughn/react-resizable-panels/pull/58): Add imperative `collapse`, `expand`, and `resize` methods to `Panel`.
|
|
5
|
+
* [#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.
|
|
6
|
+
* [#57](https://github.com/bvaughn/react-resizable-panels/pull/57): Improve server rendering check to include `window.document`. This more closely matches React's own check and avoids false positives for environments that alias `window` to some global object.
|
|
7
|
+
|
|
8
|
+
## 0.0.28
|
|
9
|
+
* [#53](https://github.com/bvaughn/react-resizable-panels/issues/53): Avoid `useLayoutEffect` warning when server rendering. Render panels with default style of `flex: 1 1 auto` during initial render.
|
|
10
|
+
|
|
3
11
|
## 0.0.27
|
|
4
12
|
* [#4](https://github.com/bvaughn/react-resizable-panels/issues/4): Add `collapsible` and `onCollapse` props to `Panel` to support auto-collapsing panels that resize beyond their `minSize` value (similar to VS Code's panel UX).
|
|
5
13
|
|
package/README.md
CHANGED
|
@@ -48,6 +48,14 @@ import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
|
|
|
48
48
|
| `style` | `?CSSProperties` | Optional CSS style to attach to root element
|
|
49
49
|
| `tagName` | `?string = "div"` | Optional HTML element tag name for root element
|
|
50
50
|
|
|
51
|
+
`Panel` components also expose an imperative API for manual resizing:
|
|
52
|
+
| method | description
|
|
53
|
+
| :--------------------------- | :---
|
|
54
|
+
| `collapse` | If panel is `collapsible`, collapse it fully.
|
|
55
|
+
| `expand` | If panel is currently _collapsed_, expand it to its most recent size.
|
|
56
|
+
| `resize(percentage: number)` | Resize panel to the specified _percentage_ (`1 - 100`).
|
|
57
|
+
|
|
58
|
+
|
|
51
59
|
### `PanelResizeHandle`
|
|
52
60
|
| prop | type | description
|
|
53
61
|
| :------------ | :---------------- | :---
|
|
@@ -15,7 +15,7 @@ type PanelData = {
|
|
|
15
15
|
order: number | null;
|
|
16
16
|
};
|
|
17
17
|
type ResizeEvent = KeyboardEvent | MouseEvent | TouchEvent;
|
|
18
|
-
type PanelProps = {
|
|
18
|
+
export type PanelProps = {
|
|
19
19
|
children?: ReactNode;
|
|
20
20
|
className?: string;
|
|
21
21
|
collapsible?: boolean;
|
|
@@ -29,8 +29,13 @@ type PanelProps = {
|
|
|
29
29
|
style?: CSSProperties;
|
|
30
30
|
tagName?: ElementType;
|
|
31
31
|
};
|
|
32
|
-
export
|
|
33
|
-
|
|
32
|
+
export type ImperativePanelHandle = {
|
|
33
|
+
collapse: () => void;
|
|
34
|
+
expand: () => void;
|
|
35
|
+
resize: (percentage: number) => void;
|
|
36
|
+
};
|
|
37
|
+
export const Panel: import("react").ForwardRefExoticComponent<PanelProps & import("react").RefAttributes<ImperativePanelHandle>>;
|
|
38
|
+
export type PanelGroupProps = {
|
|
34
39
|
autoSaveId?: string;
|
|
35
40
|
children?: ReactNode;
|
|
36
41
|
className?: string;
|
|
@@ -41,16 +46,19 @@ type PanelGroupProps = {
|
|
|
41
46
|
};
|
|
42
47
|
export function PanelGroup({ autoSaveId, children, className: classNameFromProps, direction, id: idFromProps, style: styleFromProps, tagName: Type, }: PanelGroupProps): import("react").FunctionComponentElement<import("react").ProviderProps<{
|
|
43
48
|
activeHandleId: string;
|
|
49
|
+
collapsePanel: (id: string) => void;
|
|
44
50
|
direction: "horizontal" | "vertical";
|
|
51
|
+
expandPanel: (id: string) => void;
|
|
45
52
|
getPanelStyle: (id: string) => CSSProperties;
|
|
46
53
|
groupId: string;
|
|
47
54
|
registerPanel: (id: string, panel: PanelData) => void;
|
|
48
55
|
registerResizeHandle: (id: string) => import("types").ResizeHandler;
|
|
56
|
+
resizePanel: (id: string, percentage: number) => void;
|
|
49
57
|
startDragging: (id: string, event: ResizeEvent) => void;
|
|
50
58
|
stopDragging: () => void;
|
|
51
59
|
unregisterPanel: (id: string) => void;
|
|
52
60
|
}>>;
|
|
53
|
-
type PanelResizeHandleProps = {
|
|
61
|
+
export type PanelResizeHandleProps = {
|
|
54
62
|
children?: ReactNode;
|
|
55
63
|
className?: string;
|
|
56
64
|
disabled?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";
|
|
1
|
+
{"mappings":";AEEA,iBAAwB,YAAY,GAAG,UAAU,CAAC;AAElD,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,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,mBAA0B,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC;AEFlE,yBAAyB;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF,oCAAoC;IAClC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC,CAAC;AA0HF,OAAO,MAAM,mHAGZ,CAAC;AOxHF,8BAA8B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,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,KAAK,EAAE,cAAmB,EAC1B,OAAO,EAAE,IAAY,GACtB,EAAE,eAAe;;;;;;;;;;;;;IA2bjB;ACneD,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/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,"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"}
|
|
@@ -4,9 +4,15 @@ function $parcel$export(e, n, v, s) {
|
|
|
4
4
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
$parcel$export(module.exports, "Panel", () => $4b51bd7b90b9da8b$export$
|
|
8
|
-
$parcel$export(module.exports, "PanelGroup", () => $19bf0050f73d236b$export$
|
|
9
|
-
$parcel$export(module.exports, "PanelResizeHandle", () => $01377e07790cf46f$export$
|
|
7
|
+
$parcel$export(module.exports, "Panel", () => $4b51bd7b90b9da8b$export$2ddb90ad54e5f587);
|
|
8
|
+
$parcel$export(module.exports, "PanelGroup", () => $19bf0050f73d236b$export$1d05749f6f573bb);
|
|
9
|
+
$parcel$export(module.exports, "PanelResizeHandle", () => $01377e07790cf46f$export$8829ecf6b6b15484);
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const $967abed3d1bd1fe9$var$canUseEffectHooks = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
13
|
+
const $967abed3d1bd1fe9$var$useIsomorphicLayoutEffect = $967abed3d1bd1fe9$var$canUseEffectHooks ? (0, $b2QPe$react.useLayoutEffect) : ()=>{};
|
|
14
|
+
var $967abed3d1bd1fe9$export$2e2bcd8739ae039 = $967abed3d1bd1fe9$var$useIsomorphicLayoutEffect;
|
|
15
|
+
|
|
10
16
|
|
|
11
17
|
|
|
12
18
|
let $6d548a0d130941e3$var$counter = 0;
|
|
@@ -26,9 +32,21 @@ const $3251d17c1c3bce6c$export$7d8c6d083caec74a = (0, $b2QPe$react.createContext
|
|
|
26
32
|
$3251d17c1c3bce6c$export$7d8c6d083caec74a.displayName = "PanelGroupContext";
|
|
27
33
|
|
|
28
34
|
|
|
29
|
-
function $4b51bd7b90b9da8b$
|
|
35
|
+
function $4b51bd7b90b9da8b$var$PanelWithForwardedRef({ children: children = null , className: classNameFromProps = "" , collapsible: collapsible = false , defaultSize: defaultSize = null , forwardedRef: forwardedRef , id: idFromProps = null , maxSize: maxSize = 100 , minSize: minSize = 10 , onCollapse: onCollapse = null , onResize: onResize = null , order: order = null , style: styleFromProps = {} , tagName: Type = "div" }) {
|
|
30
36
|
const context = (0, $b2QPe$react.useContext)((0, $3251d17c1c3bce6c$export$7d8c6d083caec74a));
|
|
31
37
|
if (context === null) throw Error(`Panel components must be rendered within a PanelGroup container`);
|
|
38
|
+
const panelId = (0, $6d548a0d130941e3$export$2e2bcd8739ae039)(idFromProps);
|
|
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
|
+
]);
|
|
32
50
|
// Use a ref to guard against users passing inline props
|
|
33
51
|
const callbacksRef = (0, $b2QPe$react.useRef)({
|
|
34
52
|
onCollapse: onCollapse,
|
|
@@ -48,9 +66,7 @@ function $4b51bd7b90b9da8b$export$2e2bcd8739ae039({ children: children = null ,
|
|
|
48
66
|
defaultSize = minSize;
|
|
49
67
|
}
|
|
50
68
|
}
|
|
51
|
-
|
|
52
|
-
const { getPanelStyle: getPanelStyle , registerPanel: registerPanel , unregisterPanel: unregisterPanel } = context;
|
|
53
|
-
(0, $b2QPe$react.useLayoutEffect)(()=>{
|
|
69
|
+
(0, $967abed3d1bd1fe9$export$2e2bcd8739ae039)(()=>{
|
|
54
70
|
const panel = {
|
|
55
71
|
callbacksRef: callbacksRef,
|
|
56
72
|
collapsible: collapsible,
|
|
@@ -89,10 +105,15 @@ function $4b51bd7b90b9da8b$export$2e2bcd8739ae039({ children: children = null ,
|
|
|
89
105
|
}
|
|
90
106
|
});
|
|
91
107
|
}
|
|
108
|
+
const $4b51bd7b90b9da8b$export$2ddb90ad54e5f587 = (0, $b2QPe$react.forwardRef)((props, ref)=>(0, $b2QPe$react.createElement)($4b51bd7b90b9da8b$var$PanelWithForwardedRef, {
|
|
109
|
+
...props,
|
|
110
|
+
forwardedRef: ref
|
|
111
|
+
}));
|
|
92
112
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
93
113
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
94
114
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
95
|
-
$4b51bd7b90b9da8b$
|
|
115
|
+
$4b51bd7b90b9da8b$var$PanelWithForwardedRef.displayName = "Panel";
|
|
116
|
+
$4b51bd7b90b9da8b$export$2ddb90ad54e5f587.displayName = "forwardRef(Panel)";
|
|
96
117
|
|
|
97
118
|
|
|
98
119
|
|
|
@@ -189,6 +210,38 @@ function $d520236daad9c5d5$export$f50bae335f53943c(panels, idBefore, idAfter, de
|
|
|
189
210
|
nextSizes[index1] = prevSizes[index1] + deltaApplied;
|
|
190
211
|
return nextSizes;
|
|
191
212
|
}
|
|
213
|
+
function $d520236daad9c5d5$export$b8e48269e4faa934(panelsArray, prevSizes, nextSizes) {
|
|
214
|
+
nextSizes.forEach((nextSize, index)=>{
|
|
215
|
+
const prevSize = prevSizes[index];
|
|
216
|
+
if (prevSize !== nextSize) {
|
|
217
|
+
const { callbacksRef: callbacksRef } = panelsArray[index];
|
|
218
|
+
const { onCollapse: onCollapse , onResize: onResize } = callbacksRef.current;
|
|
219
|
+
if (onResize) onResize(nextSize);
|
|
220
|
+
if (onCollapse) {
|
|
221
|
+
if (prevSize === 0 && nextSize !== 0) onCollapse(false);
|
|
222
|
+
else if (prevSize !== 0 && nextSize === 0) onCollapse(true);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function $d520236daad9c5d5$export$5a5b0c1d38c23c3b(id, panelsArray) {
|
|
228
|
+
if (panelsArray.length < 2) return [
|
|
229
|
+
null,
|
|
230
|
+
null
|
|
231
|
+
];
|
|
232
|
+
const index = panelsArray.findIndex((panel)=>panel.id === id);
|
|
233
|
+
if (index < 0) return [
|
|
234
|
+
null,
|
|
235
|
+
null
|
|
236
|
+
];
|
|
237
|
+
const isLastPanel = index === panelsArray.length - 1;
|
|
238
|
+
const idBefore = isLastPanel ? panelsArray[index - 1].id : id;
|
|
239
|
+
const idAfter = isLastPanel ? id : panelsArray[index + 1].id;
|
|
240
|
+
return [
|
|
241
|
+
idBefore,
|
|
242
|
+
idAfter
|
|
243
|
+
];
|
|
244
|
+
}
|
|
192
245
|
function $d520236daad9c5d5$export$6f43503e166de6fb(panels, id, sizes) {
|
|
193
246
|
if (panels.size === 1) return "100";
|
|
194
247
|
const panelsArray = $d520236daad9c5d5$export$a861c0ad45885494(panels);
|
|
@@ -319,6 +372,8 @@ function $f5af57c8e042a4ad$export$c4dfce035d43d1e0(event) {
|
|
|
319
372
|
|
|
320
373
|
|
|
321
374
|
|
|
375
|
+
|
|
376
|
+
|
|
322
377
|
function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committedValuesRef , groupId: groupId , panels: panels , setSizes: setSizes , sizes: sizes }) {
|
|
323
378
|
(0, $b2QPe$react.useEffect)(()=>{
|
|
324
379
|
const { direction: direction , panels: panels } = committedValuesRef.current;
|
|
@@ -428,7 +483,6 @@ function $63be9a96d8675f03$export$33b0bea6ac3ffb03({ disabled: disabled , handle
|
|
|
428
483
|
}
|
|
429
484
|
|
|
430
485
|
|
|
431
|
-
|
|
432
486
|
let $102aa6bc0f99b2b3$var$currentState = null;
|
|
433
487
|
let $102aa6bc0f99b2b3$var$element = null;
|
|
434
488
|
function $102aa6bc0f99b2b3$export$fa35f3322c52262f(state) {
|
|
@@ -466,20 +520,22 @@ function $102aa6bc0f99b2b3$export$d395b5dfd066a659(state) {
|
|
|
466
520
|
}
|
|
467
521
|
|
|
468
522
|
|
|
469
|
-
function $19bf0050f73d236b$export$
|
|
523
|
+
function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , children: children = null , className: classNameFromProps = "" , direction: direction , id: idFromProps = null , style: styleFromProps = {} , tagName: Type = "div" }) {
|
|
470
524
|
const groupId = (0, $6d548a0d130941e3$export$2e2bcd8739ae039)(idFromProps);
|
|
471
525
|
const [activeHandleId, setActiveHandleId] = (0, $b2QPe$react.useState)(null);
|
|
472
526
|
const [panels, setPanels] = (0, $b2QPe$react.useState)(new Map());
|
|
473
527
|
// 0-1 values representing the relative size of each panel.
|
|
474
528
|
const [sizes, setSizes] = (0, $b2QPe$react.useState)([]);
|
|
475
529
|
const dragOffsetRef = (0, $b2QPe$react.useRef)(0);
|
|
530
|
+
// Used to support imperative collapse/expand API.
|
|
531
|
+
const panelSizeBeforeCollapse = (0, $b2QPe$react.useRef)(new Map());
|
|
476
532
|
// Store committed values to avoid unnecessarily re-running memoization/effects functions.
|
|
477
533
|
const committedValuesRef = (0, $b2QPe$react.useRef)({
|
|
478
534
|
direction: direction,
|
|
479
535
|
panels: panels,
|
|
480
536
|
sizes: sizes
|
|
481
537
|
});
|
|
482
|
-
(0, $
|
|
538
|
+
(0, $967abed3d1bd1fe9$export$2e2bcd8739ae039)(()=>{
|
|
483
539
|
committedValuesRef.current.direction = direction;
|
|
484
540
|
committedValuesRef.current.panels = panels;
|
|
485
541
|
committedValuesRef.current.sizes = sizes;
|
|
@@ -494,7 +550,7 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
|
|
|
494
550
|
// Once all panels have registered themselves,
|
|
495
551
|
// Compute the initial sizes based on default weights.
|
|
496
552
|
// This assumes that panels register during initial mount (no conditional rendering)!
|
|
497
|
-
(0, $
|
|
553
|
+
(0, $967abed3d1bd1fe9$export$2e2bcd8739ae039)(()=>{
|
|
498
554
|
const sizes = committedValuesRef.current.sizes;
|
|
499
555
|
if (sizes.length === panels.size) // Only compute (or restore) default sizes once per panel configuration.
|
|
500
556
|
return;
|
|
@@ -545,15 +601,29 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
|
|
|
545
601
|
]);
|
|
546
602
|
const getPanelStyle = (0, $b2QPe$react.useCallback)((id)=>{
|
|
547
603
|
const { panels: panels } = committedValuesRef.current;
|
|
604
|
+
// Before mounting, Panels will not yet have registered themselves.
|
|
605
|
+
// This includes server rendering.
|
|
606
|
+
// At this point the best we can do is render everything with the same size.
|
|
607
|
+
if (panels.size === 0) return {
|
|
608
|
+
flexBasis: "auto",
|
|
609
|
+
flexGrow: 1,
|
|
610
|
+
flexShrink: 1,
|
|
611
|
+
// Without this, Panel sizes may be unintentionally overridden by their content.
|
|
612
|
+
overflow: "hidden"
|
|
613
|
+
};
|
|
548
614
|
const flexGrow = (0, $d520236daad9c5d5$export$6f43503e166de6fb)(panels, id, sizes);
|
|
549
615
|
return {
|
|
550
616
|
flexBasis: 0,
|
|
551
617
|
flexGrow: flexGrow,
|
|
552
618
|
flexShrink: 1,
|
|
553
619
|
// Without this, Panel sizes may be unintentionally overridden by their content.
|
|
554
|
-
overflow: "hidden"
|
|
620
|
+
overflow: "hidden",
|
|
621
|
+
// Disable pointer events inside of a panel during resize.
|
|
622
|
+
// This avoid edge cases like nested iframes.
|
|
623
|
+
pointerEvents: activeHandleId !== null ? "none" : undefined
|
|
555
624
|
};
|
|
556
625
|
}, [
|
|
626
|
+
activeHandleId,
|
|
557
627
|
direction,
|
|
558
628
|
sizes
|
|
559
629
|
]);
|
|
@@ -590,17 +660,7 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
|
|
|
590
660
|
// Reset the cursor style to the the normal resize cursor.
|
|
591
661
|
(0, $102aa6bc0f99b2b3$export$d395b5dfd066a659)(isHorizontal ? "horizontal" : "vertical");
|
|
592
662
|
// If resize change handlers have been declared, this is the time to call them.
|
|
593
|
-
|
|
594
|
-
const prevSize = prevSizes[index];
|
|
595
|
-
if (prevSize !== nextSize) {
|
|
596
|
-
const { onCollapse: onCollapse , onResize: onResize } = panelsArray[index].callbacksRef.current;
|
|
597
|
-
if (onResize) onResize(nextSize);
|
|
598
|
-
if (onCollapse) {
|
|
599
|
-
if (prevSize === 0 && nextSize !== 0) onCollapse(false);
|
|
600
|
-
else if (prevSize !== 0 && nextSize === 0) onCollapse(true);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
});
|
|
663
|
+
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
604
664
|
setSizes(nextSizes);
|
|
605
665
|
}
|
|
606
666
|
};
|
|
@@ -616,13 +676,81 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
|
|
|
616
676
|
return nextPanels;
|
|
617
677
|
});
|
|
618
678
|
}, []);
|
|
679
|
+
const collapsePanel = (0, $b2QPe$react.useCallback)((id)=>{
|
|
680
|
+
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
681
|
+
const panel = panels.get(id);
|
|
682
|
+
if (panel == null || !panel.collapsible) return;
|
|
683
|
+
const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
|
|
684
|
+
const index = panelsArray.indexOf(panel);
|
|
685
|
+
if (index < 0) return;
|
|
686
|
+
const currentSize = prevSizes[index];
|
|
687
|
+
if (currentSize === 0) // Panel is already collapsed.
|
|
688
|
+
return;
|
|
689
|
+
panelSizeBeforeCollapse.current.set(id, currentSize);
|
|
690
|
+
const [idBefore, idAfter] = (0, $d520236daad9c5d5$export$5a5b0c1d38c23c3b)(id, panelsArray);
|
|
691
|
+
if (idBefore == null || idAfter == null) return;
|
|
692
|
+
const isLastPanel = index === panelsArray.length - 1;
|
|
693
|
+
const delta = isLastPanel ? currentSize : 0 - currentSize;
|
|
694
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
|
|
695
|
+
if (prevSizes !== nextSizes) {
|
|
696
|
+
// If resize change handlers have been declared, this is the time to call them.
|
|
697
|
+
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
698
|
+
setSizes(nextSizes);
|
|
699
|
+
}
|
|
700
|
+
}, []);
|
|
701
|
+
const expandPanel = (0, $b2QPe$react.useCallback)((id)=>{
|
|
702
|
+
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
703
|
+
const panel = panels.get(id);
|
|
704
|
+
if (panel == null) return;
|
|
705
|
+
const sizeBeforeCollapse = panelSizeBeforeCollapse.current.get(id) || panel.minSize;
|
|
706
|
+
if (!sizeBeforeCollapse) return;
|
|
707
|
+
const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
|
|
708
|
+
const index = panelsArray.indexOf(panel);
|
|
709
|
+
if (index < 0) return;
|
|
710
|
+
const currentSize = prevSizes[index];
|
|
711
|
+
if (currentSize !== 0) // Panel is already expanded.
|
|
712
|
+
return;
|
|
713
|
+
const [idBefore, idAfter] = (0, $d520236daad9c5d5$export$5a5b0c1d38c23c3b)(id, panelsArray);
|
|
714
|
+
if (idBefore == null || idAfter == null) return;
|
|
715
|
+
const isLastPanel = index === panelsArray.length - 1;
|
|
716
|
+
const delta = isLastPanel ? 0 - sizeBeforeCollapse : sizeBeforeCollapse;
|
|
717
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
|
|
718
|
+
if (prevSizes !== nextSizes) {
|
|
719
|
+
// If resize change handlers have been declared, this is the time to call them.
|
|
720
|
+
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
721
|
+
setSizes(nextSizes);
|
|
722
|
+
}
|
|
723
|
+
}, []);
|
|
724
|
+
const resizePanel = (0, $b2QPe$react.useCallback)((id, nextSize)=>{
|
|
725
|
+
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
726
|
+
const panel = panels.get(id);
|
|
727
|
+
if (panel == null) return;
|
|
728
|
+
const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
|
|
729
|
+
const index = panelsArray.indexOf(panel);
|
|
730
|
+
if (index < 0) return;
|
|
731
|
+
const currentSize = prevSizes[index];
|
|
732
|
+
if (currentSize === nextSize) return;
|
|
733
|
+
const [idBefore, idAfter] = (0, $d520236daad9c5d5$export$5a5b0c1d38c23c3b)(id, panelsArray);
|
|
734
|
+
if (idBefore == null || idAfter == null) return;
|
|
735
|
+
const isLastPanel = index === panelsArray.length - 1;
|
|
736
|
+
const delta = isLastPanel ? currentSize - nextSize : nextSize - currentSize;
|
|
737
|
+
const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
|
|
738
|
+
if (prevSizes !== nextSizes) {
|
|
739
|
+
// If resize change handlers have been declared, this is the time to call them.
|
|
740
|
+
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
741
|
+
setSizes(nextSizes);
|
|
742
|
+
}
|
|
743
|
+
}, []);
|
|
619
744
|
const context = (0, $b2QPe$react.useMemo)(()=>({
|
|
620
745
|
activeHandleId: activeHandleId,
|
|
746
|
+
collapsePanel: collapsePanel,
|
|
621
747
|
direction: direction,
|
|
748
|
+
expandPanel: expandPanel,
|
|
622
749
|
getPanelStyle: getPanelStyle,
|
|
623
750
|
groupId: groupId,
|
|
624
751
|
registerPanel: registerPanel,
|
|
625
752
|
registerResizeHandle: registerResizeHandle,
|
|
753
|
+
resizePanel: resizePanel,
|
|
626
754
|
startDragging: (id, event)=>{
|
|
627
755
|
setActiveHandleId(id);
|
|
628
756
|
dragOffsetRef.current = (0, $f5af57c8e042a4ad$export$ec391ce65b083ed4)(event, id, direction);
|
|
@@ -634,11 +762,14 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
|
|
|
634
762
|
unregisterPanel: unregisterPanel
|
|
635
763
|
}), [
|
|
636
764
|
activeHandleId,
|
|
765
|
+
collapsePanel,
|
|
637
766
|
direction,
|
|
767
|
+
expandPanel,
|
|
638
768
|
getPanelStyle,
|
|
639
769
|
groupId,
|
|
640
770
|
registerPanel,
|
|
641
771
|
registerResizeHandle,
|
|
772
|
+
resizePanel,
|
|
642
773
|
unregisterPanel
|
|
643
774
|
]);
|
|
644
775
|
const style = {
|
|
@@ -665,7 +796,7 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
|
|
|
665
796
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
666
797
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
667
798
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
668
|
-
$19bf0050f73d236b$export$
|
|
799
|
+
$19bf0050f73d236b$export$1d05749f6f573bb.displayName = "PanelGroup";
|
|
669
800
|
|
|
670
801
|
|
|
671
802
|
|
|
@@ -673,7 +804,7 @@ $19bf0050f73d236b$export$2e2bcd8739ae039.displayName = "PanelGroup";
|
|
|
673
804
|
|
|
674
805
|
|
|
675
806
|
|
|
676
|
-
function $01377e07790cf46f$export$
|
|
807
|
+
function $01377e07790cf46f$export$8829ecf6b6b15484({ children: children = null , className: classNameFromProps = "" , disabled: disabled = false , id: idFromProps = null , style: styleFromProps = {} , tagName: Type = "div" }) {
|
|
677
808
|
const divElementRef = (0, $b2QPe$react.useRef)(null);
|
|
678
809
|
const panelGroupContext = (0, $b2QPe$react.useContext)((0, $3251d17c1c3bce6c$export$7d8c6d083caec74a));
|
|
679
810
|
if (panelGroupContext === null) throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
|
|
@@ -763,7 +894,7 @@ function $01377e07790cf46f$export$2e2bcd8739ae039({ children: children = null ,
|
|
|
763
894
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
764
895
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
765
896
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
766
|
-
$01377e07790cf46f$export$
|
|
897
|
+
$01377e07790cf46f$export$8829ecf6b6b15484.displayName = "PanelResizeHandle";
|
|
767
898
|
|
|
768
899
|
|
|
769
900
|
|