react-resizable-panels 0.0.28 → 0.0.30

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 CHANGED
@@ -1,4 +1,14 @@
1
1
  # Changelog
2
+
3
+ ## 0.0.30
4
+ * [#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
+ * 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).
6
+
7
+ ## 0.0.29
8
+ * [#58](https://github.com/bvaughn/react-resizable-panels/pull/58): Add imperative `collapse`, `expand`, and `resize` methods to `Panel`.
9
+ * [#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.
10
+ * [#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.
11
+
2
12
  ## 0.0.28
3
13
  * [#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
14
 
package/README.md CHANGED
@@ -26,34 +26,42 @@ 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` | Optional class name to attach to root element
29
+ | `className` | `?string` | Class name to attach to root element
30
30
  | `direction` | `"horizontal" \| "vertical"` | Group orientation
31
- | `id` | `?string` | Optional group id; falls back to `useId` when not provided
32
- | `style` | `?CSSProperties` | Optional CSS style to attach to root element
33
- | `tagName` | `?string = "div"` | Optional HTML element tag name for root element
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` | Optional class name to attach to root element
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` | Optional panel id (unique within group); falls back to `useId` when not provided
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` | Optional function to be called when panel is collapsed; `collapsed` boolean parameter reflecting the new state
46
- | `onResize` | `?(size: number) => void` | Optional function to be called when panel is resized; `size` parameter is a numeric value between 1-100
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` | Optional CSS style to attach to root element
49
- | `tagName` | `?string = "div"` | Optional HTML element tag name for root element
49
+ | `style` | `?CSSProperties` | CSS style to attach to root element
50
+ | `tagName` | `?string = "div"` | HTML element tag name for root element
51
+
52
+ `Panel` components also expose an imperative API for manual resizing:
53
+ | method | description
54
+ | :--------------------------- | :---
55
+ | `collapse` | If panel is `collapsible`, collapse it fully.
56
+ | `expand` | If panel is currently _collapsed_, expand it to its most recent size.
57
+ | `resize(percentage: number)` | Resize panel to the specified _percentage_ (`1 - 100`).
50
58
 
51
59
  ### `PanelResizeHandle`
52
60
  | prop | type | description
53
61
  | :------------ | :---------------- | :---
54
62
  | `children` | `?ReactNode` | Custom drag UI; can be any arbitrary React element(s)
55
- | `className` | `?string` | Optional class name to attach to root element
63
+ | `className` | `?string` | Class name to attach to root element
56
64
  | `disabled` | `?boolean` | Disable drag handle
57
- | `id` | `?string` | Optional resize handle id (unique within group); falls back to `useId` when not provided
58
- | `style` | `?CSSProperties` | Optional CSS style to attach to root element
59
- | `tagName` | `?string = "div"` | Optional HTML element tag name for root element
65
+ | `id` | `?string` | Resize handle id (unique within group); falls back to `useId` when not provided
66
+ | `style` | `?CSSProperties` | CSS style to attach to root element
67
+ | `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 = {
@@ -15,7 +16,7 @@ type PanelData = {
15
16
  order: number | null;
16
17
  };
17
18
  type ResizeEvent = KeyboardEvent | MouseEvent | TouchEvent;
18
- type PanelProps = {
19
+ export type PanelProps = {
19
20
  children?: ReactNode;
20
21
  className?: string;
21
22
  collapsible?: boolean;
@@ -29,28 +30,37 @@ type PanelProps = {
29
30
  style?: CSSProperties;
30
31
  tagName?: ElementType;
31
32
  };
32
- export function Panel({ children, className: classNameFromProps, collapsible, defaultSize, id: idFromProps, maxSize, minSize, onCollapse, onResize, order, style: styleFromProps, tagName: Type, }: PanelProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
33
- type PanelGroupProps = {
33
+ export type ImperativePanelHandle = {
34
+ collapse: () => void;
35
+ expand: () => void;
36
+ resize: (percentage: number) => void;
37
+ };
38
+ export const Panel: import("react").ForwardRefExoticComponent<PanelProps & import("react").RefAttributes<ImperativePanelHandle>>;
39
+ export type PanelGroupProps = {
34
40
  autoSaveId?: string;
35
41
  children?: ReactNode;
36
42
  className?: string;
37
43
  direction: Direction;
38
44
  id?: string | null;
45
+ onLayout?: PanelGroupOnLayout;
39
46
  style?: CSSProperties;
40
47
  tagName?: ElementType;
41
48
  };
42
- export function PanelGroup({ autoSaveId, children, className: classNameFromProps, direction, id: idFromProps, style: styleFromProps, tagName: Type, }: PanelGroupProps): import("react").FunctionComponentElement<import("react").ProviderProps<{
49
+ export function PanelGroup({ autoSaveId, children, className: classNameFromProps, direction, id: idFromProps, onLayout, style: styleFromProps, tagName: Type, }: PanelGroupProps): import("react").FunctionComponentElement<import("react").ProviderProps<{
43
50
  activeHandleId: string;
51
+ collapsePanel: (id: string) => void;
44
52
  direction: "horizontal" | "vertical";
53
+ expandPanel: (id: string) => void;
45
54
  getPanelStyle: (id: string) => CSSProperties;
46
55
  groupId: string;
47
56
  registerPanel: (id: string, panel: PanelData) => void;
48
57
  registerResizeHandle: (id: string) => import("types").ResizeHandler;
58
+ resizePanel: (id: string, percentage: number) => void;
49
59
  startDragging: (id: string, event: ResizeEvent) => void;
50
60
  stopDragging: () => void;
51
61
  unregisterPanel: (id: string) => void;
52
62
  }>>;
53
- type PanelResizeHandleProps = {
63
+ export type PanelResizeHandleProps = {
54
64
  children?: ReactNode;
55
65
  className?: string;
56
66
  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,E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C;AAEF,2BAAmC,EACjC,UAAU,EACV,QAAe,EACf,SAAS,EAAE,kBAAuB,EAClC,SAAS,EACT,EAAE,EAAE,WAAkB,EACtB,KAAK,EAAE,cAAmB,EAC1B,OAAO,EAAE,IAAY,GACtB,EAAE,eAAe;;;;;;;;;;IAoTjB;AC1VD,8BAAqC;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,kCAA0C,EACxC,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\nexport { Panel, Panel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AAQ,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;AQpHF,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,QAAQ,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;;;;;;;;;;;;;IA6cjB;AC3fD,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"}
@@ -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$2e2bcd8739ae039);
8
- $parcel$export(module.exports, "PanelGroup", () => $19bf0050f73d236b$export$2e2bcd8739ae039);
9
- $parcel$export(module.exports, "PanelResizeHandle", () => $01377e07790cf46f$export$2e2bcd8739ae039);
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$useIsomorphicLayoutEffect = typeof window !== "undefined" ? (0, $b2QPe$react.useLayoutEffect) : (0, $b2QPe$react.useEffect);
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$export$2e2bcd8739ae039({ children: children = null , className: classNameFromProps = "" , collapsible: collapsible = false , defaultSize: defaultSize = null , id: idFromProps = null , maxSize: maxSize = 100 , minSize: minSize = 10 , onCollapse: onCollapse = null , onResize: onResize = null , order: order = null , style: styleFromProps = {} , tagName: Type = "div" }) {
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$export$2e2bcd8739ae039.displayName = "Panel";
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,36 @@ function $102aa6bc0f99b2b3$export$d395b5dfd066a659(state) {
472
520
  }
473
521
 
474
522
 
475
- function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , children: children = null , className: classNameFromProps = "" , direction: direction , id: idFromProps = null , style: styleFromProps = {} , tagName: Type = "div" }) {
523
+ function $0f7a23424493ebd6$export$2e2bcd8739ae039(callback, durationMs = 10) {
524
+ let timeoutId = null;
525
+ let callable = (...args)=>{
526
+ clearTimeout(timeoutId);
527
+ timeoutId = setTimeout(()=>{
528
+ callback(...args);
529
+ }, durationMs);
530
+ };
531
+ return callable;
532
+ }
533
+
534
+
535
+ // Limit the frequency of localStorage updates.
536
+ const $19bf0050f73d236b$var$savePanelGroupLayoutDebounced = (0, $0f7a23424493ebd6$export$2e2bcd8739ae039)((0, $e045b0dd313f33c7$export$af183b313c61be4f), 100);
537
+ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , children: children = null , className: classNameFromProps = "" , direction: direction , id: idFromProps = null , onLayout: onLayout = null , style: styleFromProps = {} , tagName: Type = "div" }) {
476
538
  const groupId = (0, $6d548a0d130941e3$export$2e2bcd8739ae039)(idFromProps);
477
539
  const [activeHandleId, setActiveHandleId] = (0, $b2QPe$react.useState)(null);
478
540
  const [panels, setPanels] = (0, $b2QPe$react.useState)(new Map());
541
+ // Use a ref to guard against users passing inline props
542
+ const callbacksRef = (0, $b2QPe$react.useRef)({
543
+ onLayout: onLayout
544
+ });
545
+ (0, $b2QPe$react.useEffect)(()=>{
546
+ callbacksRef.current.onLayout = onLayout;
547
+ });
479
548
  // 0-1 values representing the relative size of each panel.
480
549
  const [sizes, setSizes] = (0, $b2QPe$react.useState)([]);
481
550
  const dragOffsetRef = (0, $b2QPe$react.useRef)(0);
551
+ // Used to support imperative collapse/expand API.
552
+ const panelSizeBeforeCollapse = (0, $b2QPe$react.useRef)(new Map());
482
553
  // Store committed values to avoid unnecessarily re-running memoization/effects functions.
483
554
  const committedValuesRef = (0, $b2QPe$react.useRef)({
484
555
  direction: direction,
@@ -497,6 +568,16 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
497
568
  setSizes: setSizes,
498
569
  sizes: sizes
499
570
  });
571
+ // Notify external code when sizes have changed.
572
+ (0, $b2QPe$react.useEffect)(()=>{
573
+ const { onLayout: onLayout } = callbacksRef.current;
574
+ if (onLayout) {
575
+ const { sizes: sizes } = committedValuesRef.current;
576
+ onLayout(sizes);
577
+ }
578
+ }, [
579
+ sizes
580
+ ]);
500
581
  // Once all panels have registered themselves,
501
582
  // Compute the initial sizes based on default weights.
502
583
  // This assumes that panels register during initial mount (no conditional rendering)!
@@ -542,7 +623,7 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
542
623
  if (autoSaveId) {
543
624
  if (sizes.length === 0 || sizes.length !== panels.size) return;
544
625
  const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
545
- (0, $e045b0dd313f33c7$export$af183b313c61be4f)(autoSaveId, panelsArray, sizes);
626
+ $19bf0050f73d236b$var$savePanelGroupLayoutDebounced(autoSaveId, panelsArray, sizes);
546
627
  }
547
628
  }, [
548
629
  autoSaveId,
@@ -567,9 +648,13 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
567
648
  flexGrow: flexGrow,
568
649
  flexShrink: 1,
569
650
  // Without this, Panel sizes may be unintentionally overridden by their content.
570
- overflow: "hidden"
651
+ overflow: "hidden",
652
+ // Disable pointer events inside of a panel during resize.
653
+ // This avoid edge cases like nested iframes.
654
+ pointerEvents: activeHandleId !== null ? "none" : undefined
571
655
  };
572
656
  }, [
657
+ activeHandleId,
573
658
  direction,
574
659
  sizes
575
660
  ]);
@@ -606,17 +691,7 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
606
691
  // Reset the cursor style to the the normal resize cursor.
607
692
  (0, $102aa6bc0f99b2b3$export$d395b5dfd066a659)(isHorizontal ? "horizontal" : "vertical");
608
693
  // If resize change handlers have been declared, this is the time to call them.
609
- nextSizes.forEach((nextSize, index)=>{
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
- });
694
+ (0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
620
695
  setSizes(nextSizes);
621
696
  }
622
697
  };
@@ -632,13 +707,81 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
632
707
  return nextPanels;
633
708
  });
634
709
  }, []);
710
+ const collapsePanel = (0, $b2QPe$react.useCallback)((id)=>{
711
+ const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
712
+ const panel = panels.get(id);
713
+ if (panel == null || !panel.collapsible) return;
714
+ const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
715
+ const index = panelsArray.indexOf(panel);
716
+ if (index < 0) return;
717
+ const currentSize = prevSizes[index];
718
+ if (currentSize === 0) // Panel is already collapsed.
719
+ return;
720
+ panelSizeBeforeCollapse.current.set(id, currentSize);
721
+ const [idBefore, idAfter] = (0, $d520236daad9c5d5$export$5a5b0c1d38c23c3b)(id, panelsArray);
722
+ if (idBefore == null || idAfter == null) return;
723
+ const isLastPanel = index === panelsArray.length - 1;
724
+ const delta = isLastPanel ? currentSize : 0 - currentSize;
725
+ const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
726
+ if (prevSizes !== nextSizes) {
727
+ // If resize change handlers have been declared, this is the time to call them.
728
+ (0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
729
+ setSizes(nextSizes);
730
+ }
731
+ }, []);
732
+ const expandPanel = (0, $b2QPe$react.useCallback)((id)=>{
733
+ const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
734
+ const panel = panels.get(id);
735
+ if (panel == null) return;
736
+ const sizeBeforeCollapse = panelSizeBeforeCollapse.current.get(id) || panel.minSize;
737
+ if (!sizeBeforeCollapse) return;
738
+ const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
739
+ const index = panelsArray.indexOf(panel);
740
+ if (index < 0) return;
741
+ const currentSize = prevSizes[index];
742
+ if (currentSize !== 0) // Panel is already expanded.
743
+ return;
744
+ const [idBefore, idAfter] = (0, $d520236daad9c5d5$export$5a5b0c1d38c23c3b)(id, panelsArray);
745
+ if (idBefore == null || idAfter == null) return;
746
+ const isLastPanel = index === panelsArray.length - 1;
747
+ const delta = isLastPanel ? 0 - sizeBeforeCollapse : sizeBeforeCollapse;
748
+ const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
749
+ if (prevSizes !== nextSizes) {
750
+ // If resize change handlers have been declared, this is the time to call them.
751
+ (0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
752
+ setSizes(nextSizes);
753
+ }
754
+ }, []);
755
+ const resizePanel = (0, $b2QPe$react.useCallback)((id, nextSize)=>{
756
+ const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
757
+ const panel = panels.get(id);
758
+ if (panel == null) return;
759
+ const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
760
+ const index = panelsArray.indexOf(panel);
761
+ if (index < 0) return;
762
+ const currentSize = prevSizes[index];
763
+ if (currentSize === nextSize) return;
764
+ const [idBefore, idAfter] = (0, $d520236daad9c5d5$export$5a5b0c1d38c23c3b)(id, panelsArray);
765
+ if (idBefore == null || idAfter == null) return;
766
+ const isLastPanel = index === panelsArray.length - 1;
767
+ const delta = isLastPanel ? currentSize - nextSize : nextSize - currentSize;
768
+ const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
769
+ if (prevSizes !== nextSizes) {
770
+ // If resize change handlers have been declared, this is the time to call them.
771
+ (0, $d520236daad9c5d5$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
772
+ setSizes(nextSizes);
773
+ }
774
+ }, []);
635
775
  const context = (0, $b2QPe$react.useMemo)(()=>({
636
776
  activeHandleId: activeHandleId,
777
+ collapsePanel: collapsePanel,
637
778
  direction: direction,
779
+ expandPanel: expandPanel,
638
780
  getPanelStyle: getPanelStyle,
639
781
  groupId: groupId,
640
782
  registerPanel: registerPanel,
641
783
  registerResizeHandle: registerResizeHandle,
784
+ resizePanel: resizePanel,
642
785
  startDragging: (id, event)=>{
643
786
  setActiveHandleId(id);
644
787
  dragOffsetRef.current = (0, $f5af57c8e042a4ad$export$ec391ce65b083ed4)(event, id, direction);
@@ -650,11 +793,14 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
650
793
  unregisterPanel: unregisterPanel
651
794
  }), [
652
795
  activeHandleId,
796
+ collapsePanel,
653
797
  direction,
798
+ expandPanel,
654
799
  getPanelStyle,
655
800
  groupId,
656
801
  registerPanel,
657
802
  registerResizeHandle,
803
+ resizePanel,
658
804
  unregisterPanel
659
805
  ]);
660
806
  const style = {
@@ -681,7 +827,7 @@ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
681
827
  // Workaround for Parcel scope hoisting (which renames objects/functions).
682
828
  // Casting to :any is required to avoid corrupting the generated TypeScript types.
683
829
  // See github.com/parcel-bundler/parcel/issues/8724
684
- $19bf0050f73d236b$export$2e2bcd8739ae039.displayName = "PanelGroup";
830
+ $19bf0050f73d236b$export$1d05749f6f573bb.displayName = "PanelGroup";
685
831
 
686
832
 
687
833
 
@@ -689,7 +835,7 @@ $19bf0050f73d236b$export$2e2bcd8739ae039.displayName = "PanelGroup";
689
835
 
690
836
 
691
837
 
692
- function $01377e07790cf46f$export$2e2bcd8739ae039({ children: children = null , className: classNameFromProps = "" , disabled: disabled = false , id: idFromProps = null , style: styleFromProps = {} , tagName: Type = "div" }) {
838
+ function $01377e07790cf46f$export$8829ecf6b6b15484({ children: children = null , className: classNameFromProps = "" , disabled: disabled = false , id: idFromProps = null , style: styleFromProps = {} , tagName: Type = "div" }) {
693
839
  const divElementRef = (0, $b2QPe$react.useRef)(null);
694
840
  const panelGroupContext = (0, $b2QPe$react.useContext)((0, $3251d17c1c3bce6c$export$7d8c6d083caec74a));
695
841
  if (panelGroupContext === null) throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
@@ -779,7 +925,7 @@ function $01377e07790cf46f$export$2e2bcd8739ae039({ children: children = null ,
779
925
  // Workaround for Parcel scope hoisting (which renames objects/functions).
780
926
  // Casting to :any is required to avoid corrupting the generated TypeScript types.
781
927
  // See github.com/parcel-bundler/parcel/issues/8724
782
- $01377e07790cf46f$export$2e2bcd8739ae039.displayName = "PanelResizeHandle";
928
+ $01377e07790cf46f$export$8829ecf6b6b15484.displayName = "PanelResizeHandle";
783
929
 
784
930
 
785
931