react-resizable-panels 0.0.28 → 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 +6 -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 +139 -24
- package/dist/react-resizable-panels.js.map +1 -1
- package/dist/react-resizable-panels.module.js +138 -23
- package/dist/react-resizable-panels.module.js.map +1 -1
- package/package.json +1 -1
- package/src/Panel.ts +42 -7
- package/src/PanelContexts.ts +3 -0
- package/src/PanelGroup.ts +157 -20
- package/src/PanelResizeHandle.ts +1 -1
- package/src/hooks/useIsomorphicEffect.ts +9 -2
- package/src/index.ts +18 -4
- package/src/utils/group.ts +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
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
|
+
|
|
2
8
|
## 0.0.28
|
|
3
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.
|
|
4
10
|
|
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":";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;
|
|
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,12 +4,13 @@ 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
10
|
|
|
11
11
|
|
|
12
|
-
const $967abed3d1bd1fe9$var$
|
|
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) : ()=>{};
|
|
13
14
|
var $967abed3d1bd1fe9$export$2e2bcd8739ae039 = $967abed3d1bd1fe9$var$useIsomorphicLayoutEffect;
|
|
14
15
|
|
|
15
16
|
|
|
@@ -31,9 +32,21 @@ const $3251d17c1c3bce6c$export$7d8c6d083caec74a = (0, $b2QPe$react.createContext
|
|
|
31
32
|
$3251d17c1c3bce6c$export$7d8c6d083caec74a.displayName = "PanelGroupContext";
|
|
32
33
|
|
|
33
34
|
|
|
34
|
-
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" }) {
|
|
35
36
|
const context = (0, $b2QPe$react.useContext)((0, $3251d17c1c3bce6c$export$7d8c6d083caec74a));
|
|
36
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
|
+
]);
|
|
37
50
|
// Use a ref to guard against users passing inline props
|
|
38
51
|
const callbacksRef = (0, $b2QPe$react.useRef)({
|
|
39
52
|
onCollapse: onCollapse,
|
|
@@ -53,8 +66,6 @@ function $4b51bd7b90b9da8b$export$2e2bcd8739ae039({ children: children = null ,
|
|
|
53
66
|
defaultSize = minSize;
|
|
54
67
|
}
|
|
55
68
|
}
|
|
56
|
-
const panelId = (0, $6d548a0d130941e3$export$2e2bcd8739ae039)(idFromProps);
|
|
57
|
-
const { getPanelStyle: getPanelStyle , registerPanel: registerPanel , unregisterPanel: unregisterPanel } = context;
|
|
58
69
|
(0, $967abed3d1bd1fe9$export$2e2bcd8739ae039)(()=>{
|
|
59
70
|
const panel = {
|
|
60
71
|
callbacksRef: callbacksRef,
|
|
@@ -94,10 +105,15 @@ function $4b51bd7b90b9da8b$export$2e2bcd8739ae039({ children: children = null ,
|
|
|
94
105
|
}
|
|
95
106
|
});
|
|
96
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
|
+
}));
|
|
97
112
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
98
113
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
99
114
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
100
|
-
$4b51bd7b90b9da8b$
|
|
115
|
+
$4b51bd7b90b9da8b$var$PanelWithForwardedRef.displayName = "Panel";
|
|
116
|
+
$4b51bd7b90b9da8b$export$2ddb90ad54e5f587.displayName = "forwardRef(Panel)";
|
|
101
117
|
|
|
102
118
|
|
|
103
119
|
|
|
@@ -194,6 +210,38 @@ function $d520236daad9c5d5$export$f50bae335f53943c(panels, idBefore, idAfter, de
|
|
|
194
210
|
nextSizes[index1] = prevSizes[index1] + deltaApplied;
|
|
195
211
|
return nextSizes;
|
|
196
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
|
+
}
|
|
197
245
|
function $d520236daad9c5d5$export$6f43503e166de6fb(panels, id, sizes) {
|
|
198
246
|
if (panels.size === 1) return "100";
|
|
199
247
|
const panelsArray = $d520236daad9c5d5$export$a861c0ad45885494(panels);
|
|
@@ -472,13 +520,15 @@ function $102aa6bc0f99b2b3$export$d395b5dfd066a659(state) {
|
|
|
472
520
|
}
|
|
473
521
|
|
|
474
522
|
|
|
475
|
-
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" }) {
|
|
476
524
|
const groupId = (0, $6d548a0d130941e3$export$2e2bcd8739ae039)(idFromProps);
|
|
477
525
|
const [activeHandleId, setActiveHandleId] = (0, $b2QPe$react.useState)(null);
|
|
478
526
|
const [panels, setPanels] = (0, $b2QPe$react.useState)(new Map());
|
|
479
527
|
// 0-1 values representing the relative size of each panel.
|
|
480
528
|
const [sizes, setSizes] = (0, $b2QPe$react.useState)([]);
|
|
481
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());
|
|
482
532
|
// Store committed values to avoid unnecessarily re-running memoization/effects functions.
|
|
483
533
|
const committedValuesRef = (0, $b2QPe$react.useRef)({
|
|
484
534
|
direction: direction,
|
|
@@ -567,9 +617,13 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
|
|
|
567
617
|
flexGrow: flexGrow,
|
|
568
618
|
flexShrink: 1,
|
|
569
619
|
// Without this, Panel sizes may be unintentionally overridden by their content.
|
|
570
|
-
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
|
|
571
624
|
};
|
|
572
625
|
}, [
|
|
626
|
+
activeHandleId,
|
|
573
627
|
direction,
|
|
574
628
|
sizes
|
|
575
629
|
]);
|
|
@@ -606,17 +660,7 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
|
|
|
606
660
|
// Reset the cursor style to the the normal resize cursor.
|
|
607
661
|
(0, $102aa6bc0f99b2b3$export$d395b5dfd066a659)(isHorizontal ? "horizontal" : "vertical");
|
|
608
662
|
// If resize change handlers have been declared, this is the time to call them.
|
|
609
|
-
|
|
610
|
-
const prevSize = prevSizes[index];
|
|
611
|
-
if (prevSize !== nextSize) {
|
|
612
|
-
const { onCollapse: onCollapse , onResize: onResize } = panelsArray[index].callbacksRef.current;
|
|
613
|
-
if (onResize) onResize(nextSize);
|
|
614
|
-
if (onCollapse) {
|
|
615
|
-
if (prevSize === 0 && nextSize !== 0) onCollapse(false);
|
|
616
|
-
else if (prevSize !== 0 && nextSize === 0) onCollapse(true);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
});
|
|
663
|
+
(0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
620
664
|
setSizes(nextSizes);
|
|
621
665
|
}
|
|
622
666
|
};
|
|
@@ -632,13 +676,81 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
|
|
|
632
676
|
return nextPanels;
|
|
633
677
|
});
|
|
634
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
|
+
}, []);
|
|
635
744
|
const context = (0, $b2QPe$react.useMemo)(()=>({
|
|
636
745
|
activeHandleId: activeHandleId,
|
|
746
|
+
collapsePanel: collapsePanel,
|
|
637
747
|
direction: direction,
|
|
748
|
+
expandPanel: expandPanel,
|
|
638
749
|
getPanelStyle: getPanelStyle,
|
|
639
750
|
groupId: groupId,
|
|
640
751
|
registerPanel: registerPanel,
|
|
641
752
|
registerResizeHandle: registerResizeHandle,
|
|
753
|
+
resizePanel: resizePanel,
|
|
642
754
|
startDragging: (id, event)=>{
|
|
643
755
|
setActiveHandleId(id);
|
|
644
756
|
dragOffsetRef.current = (0, $f5af57c8e042a4ad$export$ec391ce65b083ed4)(event, id, direction);
|
|
@@ -650,11 +762,14 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
|
|
|
650
762
|
unregisterPanel: unregisterPanel
|
|
651
763
|
}), [
|
|
652
764
|
activeHandleId,
|
|
765
|
+
collapsePanel,
|
|
653
766
|
direction,
|
|
767
|
+
expandPanel,
|
|
654
768
|
getPanelStyle,
|
|
655
769
|
groupId,
|
|
656
770
|
registerPanel,
|
|
657
771
|
registerResizeHandle,
|
|
772
|
+
resizePanel,
|
|
658
773
|
unregisterPanel
|
|
659
774
|
]);
|
|
660
775
|
const style = {
|
|
@@ -681,7 +796,7 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
|
|
|
681
796
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
682
797
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
683
798
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
684
|
-
$19bf0050f73d236b$export$
|
|
799
|
+
$19bf0050f73d236b$export$1d05749f6f573bb.displayName = "PanelGroup";
|
|
685
800
|
|
|
686
801
|
|
|
687
802
|
|
|
@@ -689,7 +804,7 @@ $19bf0050f73d236b$export$2e2bcd8739ae039.displayName = "PanelGroup";
|
|
|
689
804
|
|
|
690
805
|
|
|
691
806
|
|
|
692
|
-
function $01377e07790cf46f$export$
|
|
807
|
+
function $01377e07790cf46f$export$8829ecf6b6b15484({ children: children = null , className: classNameFromProps = "" , disabled: disabled = false , id: idFromProps = null , style: styleFromProps = {} , tagName: Type = "div" }) {
|
|
693
808
|
const divElementRef = (0, $b2QPe$react.useRef)(null);
|
|
694
809
|
const panelGroupContext = (0, $b2QPe$react.useContext)((0, $3251d17c1c3bce6c$export$7d8c6d083caec74a));
|
|
695
810
|
if (panelGroupContext === null) throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
|
|
@@ -779,7 +894,7 @@ function $01377e07790cf46f$export$2e2bcd8739ae039({ children: children = null ,
|
|
|
779
894
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
780
895
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
781
896
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
782
|
-
$01377e07790cf46f$export$
|
|
897
|
+
$01377e07790cf46f$export$8829ecf6b6b15484.displayName = "PanelResizeHandle";
|
|
783
898
|
|
|
784
899
|
|
|
785
900
|
|