react-resizable-panels 0.0.22 → 0.0.24

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,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.24
4
+ * [#49](https://github.com/bvaughn/react-resizable-panels/issues/49): Change cursor based on min/max boundaries.
5
+
6
+ ## 0.0.23
7
+ * [#40](https://github.com/bvaughn/react-resizable-panels/issues/40): Add optional `maxSize` prop to `Panel`.
8
+ * [#41](https://github.com/bvaughn/react-resizable-panels/issues/41): Add optional `onResize` prop to `Panel`. This prop can be used (along with `defaultSize`) to persistence layouts somewhere externally.
9
+ * [#42](https://github.com/bvaughn/react-resizable-panels/issues/42): Don't cancel resize operations when exiting the window. Only cancel when a `"mouseup"` (or `"touchend"`) event is fired.
10
+
3
11
  ## 0.0.22
4
12
  * Replaced the `"ew-resize"` and `"ns-resize"` cursor style with `"col-resize"` and `"row-resize"`.
5
13
 
package/README.md CHANGED
@@ -33,16 +33,18 @@ import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
33
33
  | `tagName` | `?string = "div"` | Optional HTML element tag name for root element
34
34
 
35
35
  ### `Panel`
36
- | prop | type | description
37
- | :------------ | :---------------- | :---
38
- | `children` | `ReactNode` | Arbitrary React element(s)
39
- | `className` | `?string` | Optional class name to attach to root element
40
- | `defaultSize` | `?number` | Initial size of panel (numeric value between 1-100)
41
- | `id` | `?string` | Optional panel id (unique within group); falls back to `useId` when not provided
42
- | `minSize` | `?number` | Minimum allowable size of panel (numeric value between 1-100)
43
- | `order` | `?number` | Order of panel within group; required for groups with conditionally rendered panels
44
- | `style` | `?CSSProperties` | Optional CSS style to attach to root element
45
- | `tagName` | `?string = "div"` | Optional HTML element tag name for root element
36
+ | prop | type | description
37
+ | :------------ | :------------------------ | :---
38
+ | `children` | `ReactNode` | Arbitrary React element(s)
39
+ | `className` | `?string` | Optional class name to attach to root element
40
+ | `defaultSize` | `?number` | Initial size of panel (numeric value between 1-100)
41
+ | `id` | `?string` | Optional panel id (unique within group); falls back to `useId` when not provided
42
+ | `maxSize` | `?number` | Maximum allowable size of panel (numeric value between 1-100)
43
+ | `minSize` | `?number` | Minimum allowable size of panel (numeric value between 1-100)
44
+ | `onResize` | `?(size: number) => void` | Optional function to be called when panel is resized; `size` parameter is a numeric value between 1-100
45
+ | `order` | `?number` | Order of panel within group; required for groups with conditionally rendered panels
46
+ | `style` | `?CSSProperties` | Optional CSS style to attach to root element
47
+ | `tagName` | `?string = "div"` | Optional HTML element tag name for root element
46
48
 
47
49
  ### `PanelResizeHandle`
48
50
  | prop | type | description
@@ -1,16 +1,29 @@
1
- import { CSSProperties, ElementType, ReactNode } from "react";
1
+ import { RefObject, CSSProperties, ElementType, ReactNode } from "react";
2
2
  type Direction = "horizontal" | "vertical";
3
- export function Panel({ children, className: classNameFromProps, defaultSize, id: idFromProps, minSize, order, style: styleFromProps, tagName: Type, }: {
3
+ type PanelOnResize = (size: number) => void;
4
+ type PanelData = {
5
+ defaultSize: number;
6
+ id: string;
7
+ maxSize: number;
8
+ minSize: number;
9
+ onResizeRef: RefObject<PanelOnResize | null>;
10
+ order: number | null;
11
+ };
12
+ type ResizeEvent = KeyboardEvent | MouseEvent | TouchEvent;
13
+ type PanelProps = {
4
14
  children?: ReactNode;
5
15
  className?: string;
6
16
  defaultSize?: number | null;
7
17
  id?: string | null;
18
+ maxSize?: number;
8
19
  minSize?: number;
20
+ onResize?: PanelOnResize | null;
9
21
  order?: number | null;
10
22
  style?: CSSProperties;
11
23
  tagName?: ElementType;
12
- }): JSX.Element;
13
- export function PanelGroup({ autoSaveId, children, className: classNameFromProps, direction, id: idFromProps, style: styleFromProps, tagName: Type, }: {
24
+ };
25
+ export function Panel({ children, className: classNameFromProps, defaultSize, id: idFromProps, maxSize, minSize, onResize, order, style: styleFromProps, tagName: Type, }: PanelProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
26
+ type PanelGroupProps = {
14
27
  autoSaveId?: string;
15
28
  children?: ReactNode;
16
29
  className?: string;
@@ -18,14 +31,26 @@ export function PanelGroup({ autoSaveId, children, className: classNameFromProps
18
31
  id?: string | null;
19
32
  style?: CSSProperties;
20
33
  tagName?: ElementType;
21
- }): JSX.Element;
22
- export function PanelResizeHandle({ children, className: classNameFromProps, disabled, id: idFromProps, style: styleFromProps, tagName: Type, }: {
34
+ };
35
+ export function PanelGroup({ autoSaveId, children, className: classNameFromProps, direction, id: idFromProps, style: styleFromProps, tagName: Type, }: PanelGroupProps): import("react").FunctionComponentElement<import("react").ProviderProps<{
36
+ activeHandleId: string;
37
+ direction: "horizontal" | "vertical";
38
+ getPanelStyle: (id: string) => CSSProperties;
39
+ groupId: string;
40
+ registerPanel: (id: string, panel: PanelData) => void;
41
+ registerResizeHandle: (id: string) => import("types").ResizeHandler;
42
+ startDragging: (id: string, event: ResizeEvent) => void;
43
+ stopDragging: () => void;
44
+ unregisterPanel: (id: string) => void;
45
+ }>>;
46
+ type PanelResizeHandleProps = {
23
47
  children?: ReactNode;
24
48
  className?: string;
25
49
  disabled?: boolean;
26
50
  id?: string | null;
27
51
  style?: CSSProperties;
28
52
  tagName?: ElementType;
29
- }): JSX.Element;
53
+ };
54
+ export function PanelResizeHandle({ children, className: classNameFromProps, disabled, id: idFromProps, style: styleFromProps, tagName: Type, }: PanelResizeHandleProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
30
55
 
31
56
  //# sourceMappingURL=react-resizable-panels.d.ts.map
@@ -1 +1 @@
1
- {"mappings":";ACAA,iBAAwB,YAAY,GAAG,UAAU,CAAC;AEclD,sBAA8B,EAC5B,QAAe,EACf,SAAS,EAAE,kBAAuB,EAClC,WAAkB,EAClB,EAAE,EAAE,WAAkB,EACtB,OAAY,EACZ,KAAY,EACZ,KAAK,EAAE,cAAmB,EAC1B,OAAO,EAAE,IAAY,GACtB,EAAE;IACD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,eA4DA;AMtDD,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;IACD,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,eA2PA;AC/RD,kCAA0C,EACxC,QAAe,EACf,SAAS,EAAE,kBAAuB,EAClC,QAAgB,EAChB,EAAE,EAAE,WAAkB,EACtB,KAAK,EAAE,cAAmB,EAC1B,OAAO,EAAE,IAAY,GACtB,EAAE;IACD,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,eAuHA","sources":["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.tsx","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/PanelGroup.tsx","packages/react-resizable-panels/src/src/PanelResizeHandle.tsx","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,"import Panel from \"./Panel\";\nimport PanelGroup from \"./PanelGroup\";\nimport PanelResizeHandle from \"./PanelResizeHandle\";\n\nexport { Panel, PanelGroup, PanelResizeHandle };\n"],"names":[],"version":3,"file":"react-resizable-panels.d.ts.map"}
1
+ {"mappings":";ACEA,iBAAwB,YAAY,GAAG,UAAU,CAAC;AAElD,qBAA4B,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAEnD,iBAAwB;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,UAAU,aAAa,GAAG,IAAI,CAAC,CAAC;IAC7C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,mBAA0B,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC;AEDlE,kBAAyB;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,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,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,sBAA8B,EAC5B,QAAe,EACf,SAAS,EAAE,kBAAuB,EAClC,WAAkB,EAClB,EAAE,EAAE,WAAkB,EACtB,OAAa,EACb,OAAY,EACZ,QAAe,EACf,KAAY,EACZ,KAAK,EAAE,cAAmB,EAC1B,OAAO,EAAE,IAAY,GACtB,EAAE,UAAU,0FAwEZ;AMvED,uBAA8B;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,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;;;;;;;;;;IAuRjB;AC7TD,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,0FAoHxB","sources":["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/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,"import Panel from \"./Panel\";\nimport PanelGroup from \"./PanelGroup\";\nimport PanelResizeHandle from \"./PanelResizeHandle\";\n\nexport { Panel, PanelGroup, PanelResizeHandle };\n"],"names":[],"version":3,"file":"react-resizable-panels.d.ts.map"}
@@ -1,14 +1,12 @@
1
- var $b2QPe$reactjsxruntime = require("react/jsx-runtime");
2
1
  var $b2QPe$react = require("react");
3
2
 
4
3
  function $parcel$export(e, n, v, s) {
5
4
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
5
  }
7
6
 
8
- $parcel$export(module.exports, "Panel", () => $6d390b7f2e6b107f$export$2e2bcd8739ae039);
9
- $parcel$export(module.exports, "PanelGroup", () => $d428eaeef644efb2$export$2e2bcd8739ae039);
10
- $parcel$export(module.exports, "PanelResizeHandle", () => $d578a49f00f1bdeb$export$2e2bcd8739ae039);
11
-
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);
12
10
 
13
11
 
14
12
  let $6d548a0d130941e3$var$counter = 0;
@@ -28,24 +26,29 @@ const $3251d17c1c3bce6c$export$7d8c6d083caec74a = (0, $b2QPe$react.createContext
28
26
  $3251d17c1c3bce6c$export$7d8c6d083caec74a.displayName = "PanelGroupContext";
29
27
 
30
28
 
31
- function $6d390b7f2e6b107f$export$2e2bcd8739ae039({ children: children = null , className: classNameFromProps = "" , defaultSize: defaultSize = null , id: idFromProps = null , minSize: minSize = 10 , order: order = null , style: styleFromProps = {} , tagName: Type = "div" }) {
29
+ function $4b51bd7b90b9da8b$export$2e2bcd8739ae039({ children: children = null , className: classNameFromProps = "" , defaultSize: defaultSize = null , id: idFromProps = null , maxSize: maxSize = 100 , minSize: minSize = 10 , onResize: onResize = null , order: order = null , style: styleFromProps = {} , tagName: Type = "div" }) {
32
30
  const context = (0, $b2QPe$react.useContext)((0, $3251d17c1c3bce6c$export$7d8c6d083caec74a));
33
31
  if (context === null) throw Error(`Panel components must be rendered within a PanelGroup container`);
34
- const panelId = (0, $6d548a0d130941e3$export$2e2bcd8739ae039)(idFromProps);
32
+ const onResizeRef = (0, $b2QPe$react.useRef)(onResize);
33
+ // Basic props validation
35
34
  if (minSize < 0 || minSize > 100) throw Error(`Panel minSize must be between 0 and 100, but was ${minSize}`);
36
- if (defaultSize !== null) {
35
+ else if (maxSize < 0 || maxSize > 100) throw Error(`Panel maxSize must be between 0 and 100, but was ${maxSize}`);
36
+ else if (defaultSize !== null) {
37
37
  if (defaultSize < 0 || defaultSize > 100) throw Error(`Panel defaultSize must be between 0 and 100, but was ${defaultSize}`);
38
38
  else if (minSize > defaultSize) {
39
39
  console.error(`Panel minSize ${minSize} cannot be greater than defaultSize ${defaultSize}`);
40
40
  defaultSize = minSize;
41
41
  }
42
42
  }
43
+ const panelId = (0, $6d548a0d130941e3$export$2e2bcd8739ae039)(idFromProps);
43
44
  const { getPanelStyle: getPanelStyle , registerPanel: registerPanel , unregisterPanel: unregisterPanel } = context;
44
45
  (0, $b2QPe$react.useLayoutEffect)(()=>{
45
46
  const panel = {
46
47
  defaultSize: defaultSize,
47
48
  id: panelId,
49
+ maxSize: maxSize,
48
50
  minSize: minSize,
51
+ onResizeRef: onResizeRef,
49
52
  order: order
50
53
  };
51
54
  registerPanel(panelId, panel);
@@ -55,28 +58,28 @@ function $6d390b7f2e6b107f$export$2e2bcd8739ae039({ children: children = null ,
55
58
  }, [
56
59
  defaultSize,
57
60
  panelId,
61
+ maxSize,
58
62
  minSize,
59
63
  order,
60
64
  registerPanel,
61
65
  unregisterPanel
62
66
  ]);
63
67
  const style = getPanelStyle(panelId);
64
- return /*#__PURE__*/ (0, $b2QPe$reactjsxruntime.jsx)(Type, {
68
+ return (0, $b2QPe$react.createElement)(Type, {
69
+ children: children,
65
70
  className: classNameFromProps,
66
71
  "data-panel-id": panelId,
67
72
  id: `data-panel-id-${panelId}`,
68
73
  style: {
69
74
  ...style,
70
75
  ...styleFromProps
71
- },
72
- children: children
76
+ }
73
77
  });
74
78
  }
75
79
  // Workaround for Parcel scope hoisting (which renames objects/functions).
76
80
  // Casting to :any is required to avoid corrupting the generated TypeScript types.
77
81
  // See github.com/parcel-bundler/parcel/issues/8724
78
- $6d390b7f2e6b107f$export$2e2bcd8739ae039.displayName = "Panel";
79
-
82
+ $4b51bd7b90b9da8b$export$2e2bcd8739ae039.displayName = "Panel";
80
83
 
81
84
 
82
85
 
@@ -136,30 +139,40 @@ function $d520236daad9c5d5$export$f50bae335f53943c(panels, idBefore, idAfter, de
136
139
  //
137
140
  // A positive delta means the panel immediately before the resizer should "expand".
138
141
  // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resizer.
139
- let pivotId = delta < 0 ? idBefore : idAfter;
140
- let index = panelsArray.findIndex((panel)=>panel.id === pivotId);
141
- while(true){
142
+ // Max-bounds check the panel being expanded first.
143
+ {
144
+ const pivotId = delta < 0 ? idAfter : idBefore;
145
+ const index = panelsArray.findIndex((panel)=>panel.id === pivotId);
142
146
  const panel = panelsArray[index];
143
147
  const prevSize = prevSizes[index];
144
- const nextSize = Math.max(prevSize - Math.abs(delta), panel.minSize);
145
- if (prevSize !== nextSize) {
146
- deltaApplied += prevSize - nextSize;
147
- nextSizes[index] = nextSize;
148
+ const nextSize = $d520236daad9c5d5$var$safeResizePanel(panel, Math.abs(delta), prevSize);
149
+ if (prevSize === nextSize) return prevSizes;
150
+ else delta = delta < 0 ? prevSize - nextSize : nextSize - prevSize;
151
+ }
152
+ let pivotId1 = delta < 0 ? idBefore : idAfter;
153
+ let index1 = panelsArray.findIndex((panel)=>panel.id === pivotId1);
154
+ while(true){
155
+ const panel1 = panelsArray[index1];
156
+ const prevSize1 = prevSizes[index1];
157
+ const nextSize1 = $d520236daad9c5d5$var$safeResizePanel(panel1, 0 - Math.abs(delta), prevSize1);
158
+ if (prevSize1 !== nextSize1) {
159
+ deltaApplied += prevSize1 - nextSize1;
160
+ nextSizes[index1] = nextSize1;
148
161
  if (deltaApplied.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879)) >= delta.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879))) break;
149
162
  }
150
163
  if (delta < 0) {
151
- if (--index < 0) break;
164
+ if (--index1 < 0) break;
152
165
  } else {
153
- if (++index >= panelsArray.length) break;
166
+ if (++index1 >= panelsArray.length) break;
154
167
  }
155
168
  }
156
169
  // If we were unable to resize any of the panels panels, return the previous state.
157
170
  // This will essentially bailout and ignore the "mousemove" event.
158
171
  if (deltaApplied === 0) return prevSizes;
159
172
  // Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
160
- pivotId = delta < 0 ? idAfter : idBefore;
161
- index = panelsArray.findIndex((panel)=>panel.id === pivotId);
162
- nextSizes[index] = prevSizes[index] + deltaApplied;
173
+ pivotId1 = delta < 0 ? idAfter : idBefore;
174
+ index1 = panelsArray.findIndex((panel)=>panel.id === pivotId1);
175
+ nextSizes[index1] = prevSizes[index1] + deltaApplied;
163
176
  return nextSizes;
164
177
  }
165
178
  function $d520236daad9c5d5$export$6f43503e166de6fb(panels, id, sizes) {
@@ -210,6 +223,11 @@ function $d520236daad9c5d5$export$68d3a33c21dfbe27(groupId, handleId, panelsArra
210
223
  function $d520236daad9c5d5$export$a861c0ad45885494(panels) {
211
224
  return Array.from(panels.values()).sort((a, b)=>a.order - b.order);
212
225
  }
226
+ function $d520236daad9c5d5$var$safeResizePanel(panel, delta, prevSize) {
227
+ const nextSizeUnsafe = prevSize + delta;
228
+ const nextSize = Math.min(panel.maxSize, Math.max(panel.minSize, nextSizeUnsafe));
229
+ return nextSize;
230
+ }
213
231
 
214
232
 
215
233
  function $f5af57c8e042a4ad$export$ec391ce65b083ed4(event, handleId, direction, initialOffset = 0) {
@@ -243,11 +261,9 @@ function $f5af57c8e042a4ad$export$354b17c0684607ed(event, groupId, handleId, dir
243
261
  case "ArrowUp":
244
262
  return isHorizontal ? 0 : -delta;
245
263
  case "End":
246
- if (isHorizontal) return size;
247
- else return size;
264
+ return size;
248
265
  case "Home":
249
- if (isHorizontal) return -size;
250
- else return -size;
266
+ return -size;
251
267
  }
252
268
  } else return $f5af57c8e042a4ad$export$ec391ce65b083ed4(event, handleId, direction, initialOffset);
253
269
  }
@@ -277,11 +293,22 @@ function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committ
277
293
  const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
278
294
  const [idBefore, idAfter] = (0, $d520236daad9c5d5$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
279
295
  if (idBefore == null || idAfter == null) return ()=>{};
280
- const ariaValueMax = panelsArray.reduce((difference, panel)=>{
281
- if (panel.id !== idBefore) return difference - panel.minSize;
282
- return difference;
283
- }, 100);
284
- const ariaValueMin = panelsArray.find((panel)=>panel.id == idBefore)?.minSize ?? 0;
296
+ let minSize = 0;
297
+ let maxSize = 100;
298
+ let totalMinSize = 0;
299
+ let totalMaxSize = 0;
300
+ // A panel's effective min/max sizes also need to account for other panel's sizes.
301
+ panelsArray.forEach((panelData)=>{
302
+ if (panelData.id === idBefore) {
303
+ maxSize = panelData.maxSize;
304
+ minSize = panelData.minSize;
305
+ } else {
306
+ totalMinSize += panelData.minSize;
307
+ totalMaxSize += panelData.maxSize;
308
+ }
309
+ });
310
+ const ariaValueMax = Math.min(maxSize, 100 - totalMinSize);
311
+ const ariaValueMin = Math.max(minSize, (panelsArray.length - 1) * 100 - totalMaxSize);
285
312
  const flexGrow = (0, $d520236daad9c5d5$export$6f43503e166de6fb)(panels, idBefore, sizes);
286
313
  handle.setAttribute("aria-valuemax", "" + Math.round(ariaValueMax));
287
314
  handle.setAttribute("aria-valuemin", "" + Math.round(ariaValueMin));
@@ -365,7 +392,7 @@ function $63be9a96d8675f03$export$33b0bea6ac3ffb03({ disabled: disabled , handle
365
392
 
366
393
 
367
394
 
368
- function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , children: children = null , className: classNameFromProps = "" , direction: direction , id: idFromProps = null , style: styleFromProps = {} , tagName: Type = "div" }) {
395
+ function $19bf0050f73d236b$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , children: children = null , className: classNameFromProps = "" , direction: direction , id: idFromProps = null , style: styleFromProps = {} , tagName: Type = "div" }) {
369
396
  const groupId = (0, $6d548a0d130941e3$export$2e2bcd8739ae039)(idFromProps);
370
397
  const [activeHandleId, setActiveHandleId] = (0, $b2QPe$react.useState)(null);
371
398
  const [panels, setPanels] = (0, $b2QPe$react.useState)(new Map());
@@ -395,7 +422,8 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
395
422
  // This assumes that panels register during initial mount (no conditional rendering)!
396
423
  (0, $b2QPe$react.useLayoutEffect)(()=>{
397
424
  const sizes = committedValuesRef.current.sizes;
398
- if (sizes.length === panels.size) return;
425
+ if (sizes.length === panels.size) // Only compute (or restore) default sizes once per panel configuration.
426
+ return;
399
427
  // If this panel has been configured to persist sizing information,
400
428
  // default size should be restored from local storage if possible.
401
429
  let defaultSizes = undefined;
@@ -409,6 +437,10 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
409
437
  let panelsWithNullDefaultSize = 0;
410
438
  let totalDefaultSize = 0;
411
439
  let totalMinSize = 0;
440
+ // TODO
441
+ // Implicit default size calculations below do not account for inferred min/max size values.
442
+ // e.g. if Panel A has a maxSize of 40 then Panels A and B can't both have an implicit default size of 50.
443
+ // For now, these logic edge cases are left to the user to handle via props.
412
444
  panelsArray1.forEach((panel)=>{
413
445
  totalMinSize += panel.minSize;
414
446
  if (panel.defaultSize === null) panelsWithNullDefaultSize++;
@@ -474,7 +506,25 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
474
506
  const size = isHorizontal ? rect.width : rect.height;
475
507
  const delta = movement / size * 100;
476
508
  const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
477
- if (prevSizes !== nextSizes) setSizes(nextSizes);
509
+ if (prevSizes === nextSizes) {
510
+ // If the pointer has moved too far to resize the panel any further,
511
+ // update the cursor style for a visual clue.
512
+ // This mimics VS Code behavior.
513
+ if (isHorizontal) document.body.style.cursor = movement < 0 ? "e-resize" : "w-resize";
514
+ else document.body.style.cursor = movement < 0 ? "s-resize" : "n-resize";
515
+ } else {
516
+ // Reset the cursor style to the the normal resize cursor.
517
+ document.body.style.cursor = direction === "horizontal" ? "col-resize" : "row-resize";
518
+ // If resize change handlers have been declared, this is the time to call them.
519
+ nextSizes.forEach((nextSize, index)=>{
520
+ const prevSize = prevSizes[index];
521
+ if (prevSize !== nextSize) {
522
+ const onResize = panelsArray[index].onResizeRef.current;
523
+ if (onResize) onResize(nextSize);
524
+ }
525
+ });
526
+ setSizes(nextSizes);
527
+ }
478
528
  };
479
529
  return resizeHandler;
480
530
  }, [
@@ -519,32 +569,31 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
519
569
  overflow: "hidden",
520
570
  width: "100%"
521
571
  };
522
- return /*#__PURE__*/ (0, $b2QPe$reactjsxruntime.jsx)((0, $3251d17c1c3bce6c$export$7d8c6d083caec74a).Provider, {
523
- value: context,
524
- children: /*#__PURE__*/ (0, $b2QPe$reactjsxruntime.jsx)(Type, {
572
+ return (0, $b2QPe$react.createElement)((0, $3251d17c1c3bce6c$export$7d8c6d083caec74a).Provider, {
573
+ children: (0, $b2QPe$react.createElement)(Type, {
574
+ children: children,
525
575
  className: classNameFromProps,
526
576
  "data-panel-group-direction": direction,
527
577
  "data-panel-group-id": groupId,
528
578
  style: {
529
579
  ...style,
530
580
  ...styleFromProps
531
- },
532
- children: children
533
- })
581
+ }
582
+ }),
583
+ value: context
534
584
  });
535
585
  }
536
586
  // Workaround for Parcel scope hoisting (which renames objects/functions).
537
587
  // Casting to :any is required to avoid corrupting the generated TypeScript types.
538
588
  // See github.com/parcel-bundler/parcel/issues/8724
539
- $d428eaeef644efb2$export$2e2bcd8739ae039.displayName = "PanelGroup";
540
-
589
+ $19bf0050f73d236b$export$2e2bcd8739ae039.displayName = "PanelGroup";
541
590
 
542
591
 
543
592
 
544
593
 
545
594
 
546
595
 
547
- function $d578a49f00f1bdeb$export$2e2bcd8739ae039({ children: children = null , className: classNameFromProps = "" , disabled: disabled = false , id: idFromProps = null , style: styleFromProps = {} , tagName: Type = "div" }) {
596
+ function $01377e07790cf46f$export$2e2bcd8739ae039({ children: children = null , className: classNameFromProps = "" , disabled: disabled = false , id: idFromProps = null , style: styleFromProps = {} , tagName: Type = "div" }) {
548
597
  const divElementRef = (0, $b2QPe$react.useRef)(null);
549
598
  const panelGroupContext = (0, $b2QPe$react.useContext)((0, $3251d17c1c3bce6c$export$7d8c6d083caec74a));
550
599
  if (panelGroupContext === null) throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
@@ -580,17 +629,17 @@ function $d578a49f00f1bdeb$export$2e2bcd8739ae039({ children: children = null ,
580
629
  resizeHandler(event);
581
630
  };
582
631
  document.body.addEventListener("contextmenu", stopDraggingAndBlur);
583
- document.body.addEventListener("mouseleave", stopDraggingAndBlur);
584
632
  document.body.addEventListener("mousemove", onMove);
585
633
  document.body.addEventListener("touchmove", onMove);
586
- document.body.addEventListener("mouseup", stopDraggingAndBlur);
634
+ window.addEventListener("mouseup", stopDraggingAndBlur);
635
+ window.addEventListener("touchend", stopDraggingAndBlur);
587
636
  return ()=>{
588
637
  document.body.style.cursor = "";
589
638
  document.body.removeEventListener("contextmenu", stopDraggingAndBlur);
590
- document.body.removeEventListener("mouseleave", stopDraggingAndBlur);
591
639
  document.body.removeEventListener("mousemove", onMove);
592
640
  document.body.removeEventListener("touchmove", onMove);
593
- document.body.removeEventListener("mouseup", stopDraggingAndBlur);
641
+ window.removeEventListener("mouseup", stopDraggingAndBlur);
642
+ window.removeEventListener("touchend", stopDraggingAndBlur);
594
643
  };
595
644
  }, [
596
645
  direction,
@@ -609,7 +658,8 @@ function $d578a49f00f1bdeb$export$2e2bcd8739ae039({ children: children = null ,
609
658
  touchAction: "none",
610
659
  userSelect: "none"
611
660
  };
612
- return /*#__PURE__*/ (0, $b2QPe$reactjsxruntime.jsx)(Type, {
661
+ return (0, $b2QPe$react.createElement)(Type, {
662
+ children: children,
613
663
  className: classNameFromProps,
614
664
  "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
615
665
  "data-panel-group-direction": direction,
@@ -629,14 +679,13 @@ function $d578a49f00f1bdeb$export$2e2bcd8739ae039({ children: children = null ,
629
679
  ...style,
630
680
  ...styleFromProps
631
681
  },
632
- tabIndex: 0,
633
- children: children
682
+ tabIndex: 0
634
683
  });
635
684
  }
636
685
  // Workaround for Parcel scope hoisting (which renames objects/functions).
637
686
  // Casting to :any is required to avoid corrupting the generated TypeScript types.
638
687
  // See github.com/parcel-bundler/parcel/issues/8724
639
- $d578a49f00f1bdeb$export$2e2bcd8739ae039.displayName = "PanelResizeHandle";
688
+ $01377e07790cf46f$export$2e2bcd8739ae039.displayName = "PanelResizeHandle";
640
689
 
641
690
 
642
691