react-resizable-panels 0.0.42 → 0.0.44
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 +7 -0
- package/README.md +5 -0
- package/dist/react-resizable-panels.d.ts +2 -1
- package/dist/react-resizable-panels.d.ts.map +1 -1
- package/dist/react-resizable-panels.js +193 -187
- package/dist/react-resizable-panels.js.map +1 -1
- package/dist/react-resizable-panels.module.js +193 -187
- package/dist/react-resizable-panels.module.js.map +1 -1
- package/package.json +1 -1
- package/src/Panel.ts +41 -30
- package/src/PanelGroup.ts +41 -23
- package/src/hooks/useWindowSplitterBehavior.ts +7 -7
- package/src/index.ts +4 -4
- package/src/types.ts +14 -10
- package/src/utils/coordinates.ts +5 -5
- package/src/utils/group.ts +20 -18
- package/src/utils/serialization.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.44
|
|
4
|
+
* [#142](https://github.com/bvaughn/react-resizable-panels/issues/142): Avoid re-registering `Panel` when props change
|
|
5
|
+
|
|
6
|
+
## 0.0.43
|
|
7
|
+
* Add imperative `getLayout` API to `PanelGroup`
|
|
8
|
+
* [#139](https://github.com/bvaughn/react-resizable-panels/pull/139): Fix edge case bug where simultaneous `localStorage` updates to multiple saved groups would drop some values
|
|
9
|
+
|
|
3
10
|
## 0.0.42
|
|
4
11
|
* Change cursor style from `col-resize`/`row-resize` to `ew-resize`/`ns-resize` to better match cursor style at edges of a panel.
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -43,6 +43,11 @@ import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
|
|
|
43
43
|
|
|
44
44
|
<sup>2</sup>: This behavior is disabled by default because it can interfere with scrollbar styles, but it can be useful in the edge case where a `Panel` contains an `<iframe>`
|
|
45
45
|
|
|
46
|
+
`PanelGroup` components also expose an imperative API for manual resizing:
|
|
47
|
+
| method | description
|
|
48
|
+
| :-------------------------------- | :---
|
|
49
|
+
| `setLayout(panelSizes: number[])` | Resize panel group to the specified _panelSizes_ (`[1 - 100, ...]`).
|
|
50
|
+
|
|
46
51
|
### `Panel`
|
|
47
52
|
| prop | type | description
|
|
48
53
|
| :------------ | :------------------------------ | :---
|
|
@@ -42,7 +42,8 @@ export type PanelGroupProps = {
|
|
|
42
42
|
style?: CSSProperties;
|
|
43
43
|
tagName?: ElementType;
|
|
44
44
|
};
|
|
45
|
-
type ImperativePanelGroupHandle = {
|
|
45
|
+
export type ImperativePanelGroupHandle = {
|
|
46
|
+
getLayout: () => number[];
|
|
46
47
|
setLayout: (panelSizes: number[]) => void;
|
|
47
48
|
};
|
|
48
49
|
export const PanelGroup: import("react").ForwardRefExoticComponent<PanelGroupProps & import("react").RefAttributes<ImperativePanelGroupHandle>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";AGEA,iBAAwB,YAAY,GAAG,UAAU,CAAC;AAElD,gCAAgC;IAC9B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACrC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C,CAAC;AAEF,0BAAiC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;AAC3D,uBAA8B,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;AAC3D,qBAA4B,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AACnD,mCAA0C,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;
|
|
1
|
+
{"mappings":";AGEA,iBAAwB,YAAY,GAAG,UAAU,CAAC;AAElD,gCAAgC;IAC9B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACrC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C,CAAC;AAEF,0BAAiC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;AAC3D,uBAA8B,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;AAC3D,qBAA4B,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AACnD,mCAA0C,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;AEWxE,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,YAAY,IAAI,OAAO,CAAC;IACxB,OAAO,IAAI,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC,CAAC;AA+IF,OAAO,MAAM,mHAGZ,CAAC;AU7FF,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,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF,yCAAyC;IACvC,SAAS,EAAE,MAAM,MAAM,EAAE,CAAC;IAC1B,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC3C,CAAC;AAskBF,OAAO,MAAM,kIAKZ,CAAC;ACpqBF,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,UAAU,CAAC,EAAE,2BAA2B,CAAC;IACzC,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,UAAU,EACV,KAAK,EAAE,cAAmB,EAC1B,OAAO,EAAE,IAAY,GACtB,EAAE,sBAAsB,0FAoJxB","sources":["packages/react-resizable-panels/src/src/vendor/react.ts","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/constants.ts","packages/react-resizable-panels/src/src/utils/group.ts","packages/react-resizable-panels/src/src/utils/assert.ts","packages/react-resizable-panels/src/src/hooks/useWindowSplitterBehavior.ts","packages/react-resizable-panels/src/src/utils/arrays.ts","packages/react-resizable-panels/src/src/utils/coordinates.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/utils/serialization.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,null,null,null,"import { Panel } from \"./Panel\";\nimport { PanelGroup } from \"./PanelGroup\";\nimport { PanelResizeHandle } from \"./PanelResizeHandle\";\n\nimport type { ImperativePanelHandle, PanelProps } from \"./Panel\";\nimport type { ImperativePanelGroupHandle, PanelGroupProps } from \"./PanelGroup\";\nimport type { PanelResizeHandleProps } from \"./PanelResizeHandle\";\nimport type { PanelGroupStorage } from \"./types\";\n\nexport {\n // TypeScript types\n ImperativePanelGroupHandle,\n ImperativePanelHandle,\n Panel,\n PanelGroup,\n PanelGroupProps,\n PanelGroupStorage,\n PanelProps,\n PanelResizeHandle,\n PanelResizeHandleProps,\n};\n"],"names":[],"version":3,"file":"react-resizable-panels.d.ts.map"}
|
|
@@ -19,7 +19,6 @@ const { createElement: $6e687094f9ca8395$export$c8a8987d4410bf2d , createContext
|
|
|
19
19
|
const $6e687094f9ca8395$export$f680877a34711e37 = $2IMI0$react["useId".toString()];
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
const $129b5b9a317dcc10$var$canUseEffectHooks = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
24
23
|
const $129b5b9a317dcc10$var$useIsomorphicLayoutEffect = $129b5b9a317dcc10$var$canUseEffectHooks ? (0, $6e687094f9ca8395$export$e5c5a5f917a5871c) : ()=>{};
|
|
25
24
|
var $129b5b9a317dcc10$export$2e2bcd8739ae039 = $129b5b9a317dcc10$var$useIsomorphicLayoutEffect;
|
|
@@ -37,6 +36,7 @@ function $b1693d8d8f570e9c$export$2e2bcd8739ae039(idFromParams = null) {
|
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
|
|
39
|
+
|
|
40
40
|
const $b9cf028330e7f243$export$7d8c6d083caec74a = (0, $6e687094f9ca8395$export$fd42f52fd3ae1109)(null);
|
|
41
41
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
42
42
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
@@ -68,37 +68,38 @@ function $45da0e827c614f1d$var$PanelWithForwardedRef({ children: children = null
|
|
|
68
68
|
defaultSize = minSize;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
const style = getPanelStyle(panelId);
|
|
72
|
+
const committedValuesRef = (0, $6e687094f9ca8395$export$b8f5890fc79d6aca)({
|
|
73
|
+
size: $45da0e827c614f1d$var$parseSizeFromStyle(style)
|
|
74
|
+
});
|
|
75
|
+
const panelDataRef = (0, $6e687094f9ca8395$export$b8f5890fc79d6aca)({
|
|
76
|
+
callbacksRef: callbacksRef,
|
|
77
|
+
collapsible: collapsible,
|
|
78
|
+
defaultSize: defaultSize,
|
|
79
|
+
id: panelId,
|
|
80
|
+
maxSize: maxSize,
|
|
81
|
+
minSize: minSize,
|
|
82
|
+
order: order
|
|
83
|
+
});
|
|
71
84
|
(0, $129b5b9a317dcc10$export$2e2bcd8739ae039)(()=>{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
committedValuesRef.current.size = $45da0e827c614f1d$var$parseSizeFromStyle(style);
|
|
86
|
+
panelDataRef.current.callbacksRef = callbacksRef;
|
|
87
|
+
panelDataRef.current.collapsible = collapsible;
|
|
88
|
+
panelDataRef.current.defaultSize = defaultSize;
|
|
89
|
+
panelDataRef.current.id = panelId;
|
|
90
|
+
panelDataRef.current.maxSize = maxSize;
|
|
91
|
+
panelDataRef.current.minSize = minSize;
|
|
92
|
+
panelDataRef.current.order = order;
|
|
93
|
+
});
|
|
94
|
+
(0, $129b5b9a317dcc10$export$2e2bcd8739ae039)(()=>{
|
|
95
|
+
registerPanel(panelId, panelDataRef);
|
|
82
96
|
return ()=>{
|
|
83
97
|
unregisterPanel(panelId);
|
|
84
98
|
};
|
|
85
99
|
}, [
|
|
86
|
-
collapsible,
|
|
87
|
-
defaultSize,
|
|
88
|
-
panelId,
|
|
89
|
-
maxSize,
|
|
90
|
-
minSize,
|
|
91
|
-
order,
|
|
92
100
|
registerPanel,
|
|
93
101
|
unregisterPanel
|
|
94
102
|
]);
|
|
95
|
-
const style = getPanelStyle(panelId);
|
|
96
|
-
const committedValuesRef = (0, $6e687094f9ca8395$export$b8f5890fc79d6aca)({
|
|
97
|
-
size: $45da0e827c614f1d$var$parseSizeFromStyle(style)
|
|
98
|
-
});
|
|
99
|
-
(0, $129b5b9a317dcc10$export$2e2bcd8739ae039)(()=>{
|
|
100
|
-
committedValuesRef.current.size = $45da0e827c614f1d$var$parseSizeFromStyle(style);
|
|
101
|
-
});
|
|
102
103
|
(0, $6e687094f9ca8395$export$d5a552a76deda3c2)(forwardedRef, ()=>({
|
|
103
104
|
collapse: ()=>collapsePanel(panelId),
|
|
104
105
|
expand: ()=>expandPanel(panelId),
|
|
@@ -148,45 +149,6 @@ function $45da0e827c614f1d$var$parseSizeFromStyle(style) {
|
|
|
148
149
|
|
|
149
150
|
|
|
150
151
|
|
|
151
|
-
// Note that Panel ids might be user-provided (stable) or useId generated (non-deterministic)
|
|
152
|
-
// so they should not be used as part of the serialization key.
|
|
153
|
-
// Using an attribute like minSize instead should work well enough.
|
|
154
|
-
// Pre-sorting by minSize allows remembering layouts even if panels are re-ordered/dragged.
|
|
155
|
-
function $f9cb001fbb908626$var$getSerializationKey(panels) {
|
|
156
|
-
return panels.map((panel)=>{
|
|
157
|
-
const { minSize: minSize , order: order } = panel;
|
|
158
|
-
return order ? `${order}:${minSize}` : `${minSize}`;
|
|
159
|
-
}).sort((a, b)=>a.localeCompare(b)).join(",");
|
|
160
|
-
}
|
|
161
|
-
function $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
162
|
-
try {
|
|
163
|
-
const serialized = storage.getItem(`PanelGroup:sizes:${autoSaveId}`);
|
|
164
|
-
if (serialized) {
|
|
165
|
-
const parsed = JSON.parse(serialized);
|
|
166
|
-
if (typeof parsed === "object" && parsed != null) return parsed;
|
|
167
|
-
}
|
|
168
|
-
} catch (error) {}
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
function $f9cb001fbb908626$export$9c80c6617f0386da(autoSaveId, panels, storage) {
|
|
172
|
-
const state = $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage);
|
|
173
|
-
if (state) {
|
|
174
|
-
const key = $f9cb001fbb908626$var$getSerializationKey(panels);
|
|
175
|
-
var _state_key;
|
|
176
|
-
return (_state_key = state[key]) !== null && _state_key !== void 0 ? _state_key : null;
|
|
177
|
-
}
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
function $f9cb001fbb908626$export$af183b313c61be4f(autoSaveId, panels, sizes, storage) {
|
|
181
|
-
const key = $f9cb001fbb908626$var$getSerializationKey(panels);
|
|
182
|
-
const state = $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage) || {};
|
|
183
|
-
state[key] = sizes;
|
|
184
|
-
try {
|
|
185
|
-
storage.setItem(`PanelGroup:sizes:${autoSaveId}`, JSON.stringify(state));
|
|
186
|
-
} catch (error) {
|
|
187
|
-
console.error(error);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
152
|
|
|
191
153
|
|
|
192
154
|
const $9abd79656a89cd3a$export$d6d3992f3becc879 = 10;
|
|
@@ -212,7 +174,7 @@ function $cda3cc4b1114cf23$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
212
174
|
// Max-bounds check the panel being expanded first.
|
|
213
175
|
{
|
|
214
176
|
const pivotId = delta < 0 ? idAfter : idBefore;
|
|
215
|
-
const index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
177
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
|
|
216
178
|
const panel = panelsArray[index];
|
|
217
179
|
const baseSize = baseSizes[index];
|
|
218
180
|
const nextSize = $cda3cc4b1114cf23$var$safeResizePanel(panel, Math.abs(delta), baseSize, event);
|
|
@@ -224,14 +186,14 @@ function $cda3cc4b1114cf23$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
224
186
|
}
|
|
225
187
|
}
|
|
226
188
|
let pivotId = delta < 0 ? idBefore : idAfter;
|
|
227
|
-
let index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
189
|
+
let index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
|
|
228
190
|
while(true){
|
|
229
191
|
const panel = panelsArray[index];
|
|
230
192
|
const baseSize = baseSizes[index];
|
|
231
193
|
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
232
194
|
const nextSize = $cda3cc4b1114cf23$var$safeResizePanel(panel, 0 - deltaRemaining, baseSize, event);
|
|
233
195
|
if (baseSize !== nextSize) {
|
|
234
|
-
if (nextSize === 0 && baseSize > 0) panelSizeBeforeCollapse.set(panel.id, baseSize);
|
|
196
|
+
if (nextSize === 0 && baseSize > 0) panelSizeBeforeCollapse.set(panel.current.id, baseSize);
|
|
235
197
|
deltaApplied += baseSize - nextSize;
|
|
236
198
|
nextSizes[index] = nextSize;
|
|
237
199
|
if (deltaApplied.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)).localeCompare(Math.abs(delta).toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)), undefined, {
|
|
@@ -249,7 +211,7 @@ function $cda3cc4b1114cf23$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
249
211
|
if (deltaApplied === 0) return baseSizes;
|
|
250
212
|
// Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
|
|
251
213
|
pivotId = delta < 0 ? idAfter : idBefore;
|
|
252
|
-
index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
214
|
+
index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
|
|
253
215
|
nextSizes[index] = baseSizes[index] + deltaApplied;
|
|
254
216
|
return nextSizes;
|
|
255
217
|
}
|
|
@@ -257,7 +219,7 @@ function $cda3cc4b1114cf23$export$b8e48269e4faa934(panelsArray, prevSizes, nextS
|
|
|
257
219
|
nextSizes.forEach((nextSize, index)=>{
|
|
258
220
|
const prevSize = prevSizes[index];
|
|
259
221
|
if (prevSize !== nextSize) {
|
|
260
|
-
const { callbacksRef: callbacksRef , collapsible: collapsible } = panelsArray[index];
|
|
222
|
+
const { callbacksRef: callbacksRef , collapsible: collapsible } = panelsArray[index].current;
|
|
261
223
|
const { onCollapse: onCollapse , onResize: onResize } = callbacksRef.current;
|
|
262
224
|
if (onResize) onResize(nextSize);
|
|
263
225
|
if (collapsible && onCollapse) {
|
|
@@ -274,14 +236,14 @@ function $cda3cc4b1114cf23$export$5a5b0c1d38c23c3b(id, panelsArray) {
|
|
|
274
236
|
null,
|
|
275
237
|
null
|
|
276
238
|
];
|
|
277
|
-
const index = panelsArray.findIndex((panel)=>panel.id === id);
|
|
239
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === id);
|
|
278
240
|
if (index < 0) return [
|
|
279
241
|
null,
|
|
280
242
|
null
|
|
281
243
|
];
|
|
282
244
|
const isLastPanel = index === panelsArray.length - 1;
|
|
283
|
-
const idBefore = isLastPanel ? panelsArray[index - 1].id : id;
|
|
284
|
-
const idAfter = isLastPanel ? id : panelsArray[index + 1].id;
|
|
245
|
+
const idBefore = isLastPanel ? panelsArray[index - 1].current.id : id;
|
|
246
|
+
const idAfter = isLastPanel ? id : panelsArray[index + 1].current.id;
|
|
285
247
|
return [
|
|
286
248
|
idBefore,
|
|
287
249
|
idAfter
|
|
@@ -290,7 +252,7 @@ function $cda3cc4b1114cf23$export$5a5b0c1d38c23c3b(id, panelsArray) {
|
|
|
290
252
|
function $cda3cc4b1114cf23$export$6f43503e166de6fb(panels, id, sizes) {
|
|
291
253
|
if (panels.size === 1) return "100";
|
|
292
254
|
const panelsArray = $cda3cc4b1114cf23$export$a861c0ad45885494(panels);
|
|
293
|
-
const index = panelsArray.findIndex((panel)=>panel.id === id);
|
|
255
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === id);
|
|
294
256
|
const size = sizes[index];
|
|
295
257
|
if (size == null) return "0";
|
|
296
258
|
return size.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879));
|
|
@@ -322,14 +284,14 @@ function $cda3cc4b1114cf23$export$ae14931f0a0256a3(groupId) {
|
|
|
322
284
|
return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
|
|
323
285
|
}
|
|
324
286
|
function $cda3cc4b1114cf23$export$68d3a33c21dfbe27(groupId, handleId, panelsArray) {
|
|
325
|
-
var _panelsArray_index, _panelsArray_;
|
|
287
|
+
var _panelsArray_index, _panelsArray_index_current, _panelsArray_, _panelsArray__current;
|
|
326
288
|
const handle = $cda3cc4b1114cf23$export$2e27d3a347680388(handleId);
|
|
327
289
|
const handles = $cda3cc4b1114cf23$export$ae14931f0a0256a3(groupId);
|
|
328
290
|
const index = handle ? handles.indexOf(handle) : -1;
|
|
329
|
-
var
|
|
330
|
-
const idBefore = (
|
|
331
|
-
var
|
|
332
|
-
const idAfter = (
|
|
291
|
+
var _panelsArray_index_current_id;
|
|
292
|
+
const idBefore = (_panelsArray_index_current_id = (_panelsArray_index = panelsArray[index]) === null || _panelsArray_index === void 0 ? void 0 : (_panelsArray_index_current = _panelsArray_index.current) === null || _panelsArray_index_current === void 0 ? void 0 : _panelsArray_index_current.id) !== null && _panelsArray_index_current_id !== void 0 ? _panelsArray_index_current_id : null;
|
|
293
|
+
var _panelsArray__current_id;
|
|
294
|
+
const idAfter = (_panelsArray__current_id = (_panelsArray_ = panelsArray[index + 1]) === null || _panelsArray_ === void 0 ? void 0 : (_panelsArray__current = _panelsArray_.current) === null || _panelsArray__current === void 0 ? void 0 : _panelsArray__current.id) !== null && _panelsArray__current_id !== void 0 ? _panelsArray__current_id : null;
|
|
333
295
|
return [
|
|
334
296
|
idBefore,
|
|
335
297
|
idAfter
|
|
@@ -337,8 +299,8 @@ function $cda3cc4b1114cf23$export$68d3a33c21dfbe27(groupId, handleId, panelsArra
|
|
|
337
299
|
}
|
|
338
300
|
function $cda3cc4b1114cf23$export$a861c0ad45885494(panels) {
|
|
339
301
|
return Array.from(panels.values()).sort((panelA, panelB)=>{
|
|
340
|
-
const orderA = panelA.order;
|
|
341
|
-
const orderB = panelB.order;
|
|
302
|
+
const orderA = panelA.current.order;
|
|
303
|
+
const orderB = panelB.current.order;
|
|
342
304
|
if (orderA == null && orderB == null) return 0;
|
|
343
305
|
else if (orderA == null) return -1;
|
|
344
306
|
else if (orderB == null) return 1;
|
|
@@ -347,7 +309,7 @@ function $cda3cc4b1114cf23$export$a861c0ad45885494(panels) {
|
|
|
347
309
|
}
|
|
348
310
|
function $cda3cc4b1114cf23$var$safeResizePanel(panel, delta, prevSize, event) {
|
|
349
311
|
const nextSizeUnsafe = prevSize + delta;
|
|
350
|
-
if (panel.collapsible) {
|
|
312
|
+
if (panel.current.collapsible) {
|
|
351
313
|
if (prevSize > 0) {
|
|
352
314
|
if (nextSizeUnsafe <= 0) return 0;
|
|
353
315
|
} else {
|
|
@@ -357,93 +319,15 @@ function $cda3cc4b1114cf23$var$safeResizePanel(panel, delta, prevSize, event) {
|
|
|
357
319
|
// Keyboard events should expand a collapsed panel to the min size,
|
|
358
320
|
// but mouse events should wait until the panel has reached its min size
|
|
359
321
|
// to avoid a visual flickering when dragging between collapsed and min size.
|
|
360
|
-
if (nextSizeUnsafe < panel.minSize) return 0;
|
|
322
|
+
if (nextSizeUnsafe < panel.current.minSize) return 0;
|
|
361
323
|
}
|
|
362
324
|
}
|
|
363
325
|
}
|
|
364
|
-
const nextSize = Math.min(panel.maxSize, Math.max(panel.minSize, nextSizeUnsafe));
|
|
326
|
+
const nextSize = Math.min(panel.current.maxSize, Math.max(panel.current.minSize, nextSizeUnsafe));
|
|
365
327
|
return nextSize;
|
|
366
328
|
}
|
|
367
329
|
|
|
368
330
|
|
|
369
|
-
function $47eee9224cfec8e8$export$ec391ce65b083ed4(event, handleId, direction, initialOffset = 0, initialHandleElementRect = null) {
|
|
370
|
-
const isHorizontal = direction === "horizontal";
|
|
371
|
-
let pointerOffset = 0;
|
|
372
|
-
if ($47eee9224cfec8e8$export$764db16956f554f8(event)) pointerOffset = isHorizontal ? event.clientX : event.clientY;
|
|
373
|
-
else if ($47eee9224cfec8e8$export$c4dfce035d43d1e0(event)) {
|
|
374
|
-
const firstTouch = event.touches[0];
|
|
375
|
-
pointerOffset = isHorizontal ? firstTouch.screenX : firstTouch.screenY;
|
|
376
|
-
} else return 0;
|
|
377
|
-
const handleElement = (0, $cda3cc4b1114cf23$export$2e27d3a347680388)(handleId);
|
|
378
|
-
const rect = initialHandleElementRect || handleElement.getBoundingClientRect();
|
|
379
|
-
const elementOffset = isHorizontal ? rect.left : rect.top;
|
|
380
|
-
return pointerOffset - elementOffset - initialOffset;
|
|
381
|
-
}
|
|
382
|
-
function $47eee9224cfec8e8$export$354b17c0684607ed(event, groupId, handleId, panelsArray, direction, prevSizes, initialDragState) {
|
|
383
|
-
const { dragOffset: dragOffset = 0 , dragHandleRect: dragHandleRect , sizes: initialSizes } = initialDragState || {};
|
|
384
|
-
// If we're resizing by mouse or touch, use the initial sizes as a base.
|
|
385
|
-
// This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
|
|
386
|
-
const baseSizes = initialSizes || prevSizes;
|
|
387
|
-
if ($47eee9224cfec8e8$export$e7bf60a870f429b0(event)) {
|
|
388
|
-
const isHorizontal = direction === "horizontal";
|
|
389
|
-
const groupElement = (0, $cda3cc4b1114cf23$export$5e67632cf3550a9c)(groupId);
|
|
390
|
-
const rect = groupElement.getBoundingClientRect();
|
|
391
|
-
const groupSizeInPixels = isHorizontal ? rect.width : rect.height;
|
|
392
|
-
const denominator = event.shiftKey ? 10 : 100;
|
|
393
|
-
const delta = groupSizeInPixels / denominator;
|
|
394
|
-
let movement = 0;
|
|
395
|
-
switch(event.key){
|
|
396
|
-
case "ArrowDown":
|
|
397
|
-
movement = isHorizontal ? 0 : delta;
|
|
398
|
-
break;
|
|
399
|
-
case "ArrowLeft":
|
|
400
|
-
movement = isHorizontal ? -delta : 0;
|
|
401
|
-
break;
|
|
402
|
-
case "ArrowRight":
|
|
403
|
-
movement = isHorizontal ? delta : 0;
|
|
404
|
-
break;
|
|
405
|
-
case "ArrowUp":
|
|
406
|
-
movement = isHorizontal ? 0 : -delta;
|
|
407
|
-
break;
|
|
408
|
-
case "End":
|
|
409
|
-
movement = groupSizeInPixels;
|
|
410
|
-
break;
|
|
411
|
-
case "Home":
|
|
412
|
-
movement = -groupSizeInPixels;
|
|
413
|
-
break;
|
|
414
|
-
}
|
|
415
|
-
// If the Panel being resized is collapsible,
|
|
416
|
-
// we need to special case resizing around the minSize boundary.
|
|
417
|
-
// If contracting, Panels should shrink to their minSize and then snap to fully collapsed.
|
|
418
|
-
// If expanding from collapsed, they should snap back to their minSize.
|
|
419
|
-
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
|
|
420
|
-
const targetPanelId = movement < 0 ? idBefore : idAfter;
|
|
421
|
-
const targetPanelIndex = panelsArray.findIndex((panel)=>panel.id === targetPanelId);
|
|
422
|
-
const targetPanel = panelsArray[targetPanelIndex];
|
|
423
|
-
if (targetPanel.collapsible) {
|
|
424
|
-
const baseSize = baseSizes[targetPanelIndex];
|
|
425
|
-
if (baseSize === 0 || baseSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)) === targetPanel.minSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879))) movement = movement < 0 ? -targetPanel.minSize * groupSizeInPixels : targetPanel.minSize * groupSizeInPixels;
|
|
426
|
-
}
|
|
427
|
-
return movement;
|
|
428
|
-
} else return $47eee9224cfec8e8$export$ec391ce65b083ed4(event, handleId, direction, dragOffset, dragHandleRect);
|
|
429
|
-
}
|
|
430
|
-
function $47eee9224cfec8e8$export$e7bf60a870f429b0(event) {
|
|
431
|
-
return event.type === "keydown";
|
|
432
|
-
}
|
|
433
|
-
function $47eee9224cfec8e8$export$764db16956f554f8(event) {
|
|
434
|
-
return event.type.startsWith("mouse");
|
|
435
|
-
}
|
|
436
|
-
function $47eee9224cfec8e8$export$c4dfce035d43d1e0(event) {
|
|
437
|
-
return event.type.startsWith("touch");
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
331
|
function $3b727a2145ecd6f8$export$a7a9523472993e97(expectedCondition, message = "Assertion failed!") {
|
|
448
332
|
if (!expectedCondition) {
|
|
449
333
|
console.error(message);
|
|
@@ -469,12 +353,12 @@ function $a695670cc57a5969$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
469
353
|
let totalMaxSize = 0;
|
|
470
354
|
// A panel's effective min/max sizes also need to account for other panel's sizes.
|
|
471
355
|
panelsArray.forEach((panelData)=>{
|
|
472
|
-
if (panelData.id === idBefore) {
|
|
473
|
-
maxSize = panelData.maxSize;
|
|
474
|
-
minSize = panelData.minSize;
|
|
356
|
+
if (panelData.current.id === idBefore) {
|
|
357
|
+
maxSize = panelData.current.maxSize;
|
|
358
|
+
minSize = panelData.current.minSize;
|
|
475
359
|
} else {
|
|
476
|
-
totalMinSize += panelData.minSize;
|
|
477
|
-
totalMaxSize += panelData.maxSize;
|
|
360
|
+
totalMinSize += panelData.current.minSize;
|
|
361
|
+
totalMaxSize += panelData.current.maxSize;
|
|
478
362
|
}
|
|
479
363
|
});
|
|
480
364
|
const ariaValueMax = Math.min(maxSize, 100 - totalMinSize);
|
|
@@ -489,13 +373,13 @@ function $a695670cc57a5969$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
489
373
|
case "Enter":
|
|
490
374
|
{
|
|
491
375
|
event.preventDefault();
|
|
492
|
-
const index = panelsArray.findIndex((panel)=>panel.id === idBefore);
|
|
376
|
+
const index = panelsArray.findIndex((panel)=>panel.current.id === idBefore);
|
|
493
377
|
if (index >= 0) {
|
|
494
378
|
const panelData = panelsArray[index];
|
|
495
379
|
const size = sizes[index];
|
|
496
380
|
if (size != null) {
|
|
497
381
|
let delta = 0;
|
|
498
|
-
if (size.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)) <= panelData.minSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
|
|
382
|
+
if (size.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)) <= panelData.current.minSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
|
|
499
383
|
else delta = -(direction === "horizontal" ? width : height);
|
|
500
384
|
const nextSizes = (0, $cda3cc4b1114cf23$export$f50bae335f53943c)(event, panels, idBefore, idAfter, delta, sizes, panelSizeBeforeCollapse.current, null);
|
|
501
385
|
if (sizes !== nextSizes) setSizes(nextSizes);
|
|
@@ -570,6 +454,91 @@ function $a695670cc57a5969$export$33b0bea6ac3ffb03({ disabled: disabled , handle
|
|
|
570
454
|
}
|
|
571
455
|
|
|
572
456
|
|
|
457
|
+
|
|
458
|
+
function $d31ef7445a11a6c5$export$b141efd0b0fb9174(arrayA, arrayB) {
|
|
459
|
+
if (arrayA.length !== arrayB.length) return false;
|
|
460
|
+
for(let index = 0; index < arrayA.length; index++){
|
|
461
|
+
if (arrayA[index] !== arrayB[index]) return false;
|
|
462
|
+
}
|
|
463
|
+
return true;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
function $47eee9224cfec8e8$export$ec391ce65b083ed4(event, handleId, direction, initialOffset = 0, initialHandleElementRect = null) {
|
|
471
|
+
const isHorizontal = direction === "horizontal";
|
|
472
|
+
let pointerOffset = 0;
|
|
473
|
+
if ($47eee9224cfec8e8$export$764db16956f554f8(event)) pointerOffset = isHorizontal ? event.clientX : event.clientY;
|
|
474
|
+
else if ($47eee9224cfec8e8$export$c4dfce035d43d1e0(event)) {
|
|
475
|
+
const firstTouch = event.touches[0];
|
|
476
|
+
pointerOffset = isHorizontal ? firstTouch.screenX : firstTouch.screenY;
|
|
477
|
+
} else return 0;
|
|
478
|
+
const handleElement = (0, $cda3cc4b1114cf23$export$2e27d3a347680388)(handleId);
|
|
479
|
+
const rect = initialHandleElementRect || handleElement.getBoundingClientRect();
|
|
480
|
+
const elementOffset = isHorizontal ? rect.left : rect.top;
|
|
481
|
+
return pointerOffset - elementOffset - initialOffset;
|
|
482
|
+
}
|
|
483
|
+
function $47eee9224cfec8e8$export$354b17c0684607ed(event, groupId, handleId, panelsArray, direction, prevSizes, initialDragState) {
|
|
484
|
+
const { dragOffset: dragOffset = 0 , dragHandleRect: dragHandleRect , sizes: initialSizes } = initialDragState || {};
|
|
485
|
+
// If we're resizing by mouse or touch, use the initial sizes as a base.
|
|
486
|
+
// This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
|
|
487
|
+
const baseSizes = initialSizes || prevSizes;
|
|
488
|
+
if ($47eee9224cfec8e8$export$e7bf60a870f429b0(event)) {
|
|
489
|
+
const isHorizontal = direction === "horizontal";
|
|
490
|
+
const groupElement = (0, $cda3cc4b1114cf23$export$5e67632cf3550a9c)(groupId);
|
|
491
|
+
const rect = groupElement.getBoundingClientRect();
|
|
492
|
+
const groupSizeInPixels = isHorizontal ? rect.width : rect.height;
|
|
493
|
+
const denominator = event.shiftKey ? 10 : 100;
|
|
494
|
+
const delta = groupSizeInPixels / denominator;
|
|
495
|
+
let movement = 0;
|
|
496
|
+
switch(event.key){
|
|
497
|
+
case "ArrowDown":
|
|
498
|
+
movement = isHorizontal ? 0 : delta;
|
|
499
|
+
break;
|
|
500
|
+
case "ArrowLeft":
|
|
501
|
+
movement = isHorizontal ? -delta : 0;
|
|
502
|
+
break;
|
|
503
|
+
case "ArrowRight":
|
|
504
|
+
movement = isHorizontal ? delta : 0;
|
|
505
|
+
break;
|
|
506
|
+
case "ArrowUp":
|
|
507
|
+
movement = isHorizontal ? 0 : -delta;
|
|
508
|
+
break;
|
|
509
|
+
case "End":
|
|
510
|
+
movement = groupSizeInPixels;
|
|
511
|
+
break;
|
|
512
|
+
case "Home":
|
|
513
|
+
movement = -groupSizeInPixels;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
// If the Panel being resized is collapsible,
|
|
517
|
+
// we need to special case resizing around the minSize boundary.
|
|
518
|
+
// If contracting, Panels should shrink to their minSize and then snap to fully collapsed.
|
|
519
|
+
// If expanding from collapsed, they should snap back to their minSize.
|
|
520
|
+
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
|
|
521
|
+
const targetPanelId = movement < 0 ? idBefore : idAfter;
|
|
522
|
+
const targetPanelIndex = panelsArray.findIndex((panel)=>panel.current.id === targetPanelId);
|
|
523
|
+
const targetPanel = panelsArray[targetPanelIndex];
|
|
524
|
+
if (targetPanel.current.collapsible) {
|
|
525
|
+
const baseSize = baseSizes[targetPanelIndex];
|
|
526
|
+
if (baseSize === 0 || baseSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)) === targetPanel.current.minSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879))) movement = movement < 0 ? -targetPanel.current.minSize * groupSizeInPixels : targetPanel.current.minSize * groupSizeInPixels;
|
|
527
|
+
}
|
|
528
|
+
return movement;
|
|
529
|
+
} else return $47eee9224cfec8e8$export$ec391ce65b083ed4(event, handleId, direction, dragOffset, dragHandleRect);
|
|
530
|
+
}
|
|
531
|
+
function $47eee9224cfec8e8$export$e7bf60a870f429b0(event) {
|
|
532
|
+
return event.type === "keydown";
|
|
533
|
+
}
|
|
534
|
+
function $47eee9224cfec8e8$export$764db16956f554f8(event) {
|
|
535
|
+
return event.type.startsWith("mouse");
|
|
536
|
+
}
|
|
537
|
+
function $47eee9224cfec8e8$export$c4dfce035d43d1e0(event) {
|
|
538
|
+
return event.type.startsWith("touch");
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
|
|
573
542
|
let $08745f7373322b05$var$currentState = null;
|
|
574
543
|
let $08745f7373322b05$var$element = null;
|
|
575
544
|
function $08745f7373322b05$export$fa35f3322c52262f(state) {
|
|
@@ -619,18 +588,49 @@ function $2e8572579e31d898$export$2e2bcd8739ae039(callback, durationMs = 10) {
|
|
|
619
588
|
}
|
|
620
589
|
|
|
621
590
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
591
|
+
|
|
592
|
+
// Note that Panel ids might be user-provided (stable) or useId generated (non-deterministic)
|
|
593
|
+
// so they should not be used as part of the serialization key.
|
|
594
|
+
// Using an attribute like minSize instead should work well enough.
|
|
595
|
+
// Pre-sorting by minSize allows remembering layouts even if panels are re-ordered/dragged.
|
|
596
|
+
function $f9cb001fbb908626$var$getSerializationKey(panels) {
|
|
597
|
+
return panels.map((panel)=>{
|
|
598
|
+
const { minSize: minSize , order: order } = panel.current;
|
|
599
|
+
return order ? `${order}:${minSize}` : `${minSize}`;
|
|
600
|
+
}).sort((a, b)=>a.localeCompare(b)).join(",");
|
|
601
|
+
}
|
|
602
|
+
function $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
603
|
+
try {
|
|
604
|
+
const serialized = storage.getItem(`PanelGroup:sizes:${autoSaveId}`);
|
|
605
|
+
if (serialized) {
|
|
606
|
+
const parsed = JSON.parse(serialized);
|
|
607
|
+
if (typeof parsed === "object" && parsed != null) return parsed;
|
|
608
|
+
}
|
|
609
|
+
} catch (error) {}
|
|
610
|
+
return null;
|
|
611
|
+
}
|
|
612
|
+
function $f9cb001fbb908626$export$9c80c6617f0386da(autoSaveId, panels, storage) {
|
|
613
|
+
const state = $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage);
|
|
614
|
+
if (state) {
|
|
615
|
+
const key = $f9cb001fbb908626$var$getSerializationKey(panels);
|
|
616
|
+
var _state_key;
|
|
617
|
+
return (_state_key = state[key]) !== null && _state_key !== void 0 ? _state_key : null;
|
|
618
|
+
}
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
function $f9cb001fbb908626$export$af183b313c61be4f(autoSaveId, panels, sizes, storage) {
|
|
622
|
+
const key = $f9cb001fbb908626$var$getSerializationKey(panels);
|
|
623
|
+
const state = $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage) || {};
|
|
624
|
+
state[key] = sizes;
|
|
625
|
+
try {
|
|
626
|
+
storage.setItem(`PanelGroup:sizes:${autoSaveId}`, JSON.stringify(state));
|
|
627
|
+
} catch (error) {
|
|
628
|
+
console.error(error);
|
|
626
629
|
}
|
|
627
|
-
return true;
|
|
628
630
|
}
|
|
629
631
|
|
|
630
632
|
|
|
631
|
-
|
|
632
|
-
// Limit the frequency of localStorage updates.
|
|
633
|
-
const $cec4cafe75f3db78$var$savePanelGroupLayoutDebounced = (0, $2e8572579e31d898$export$2e2bcd8739ae039)((0, $f9cb001fbb908626$export$af183b313c61be4f), 100);
|
|
633
|
+
const $cec4cafe75f3db78$var$debounceMap = {};
|
|
634
634
|
function $cec4cafe75f3db78$var$throwServerError() {
|
|
635
635
|
throw new Error('PanelGroup "storage" prop required for server rendering.');
|
|
636
636
|
}
|
|
@@ -665,6 +665,10 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
665
665
|
sizes: sizes
|
|
666
666
|
});
|
|
667
667
|
(0, $6e687094f9ca8395$export$d5a552a76deda3c2)(forwardedRef, ()=>({
|
|
668
|
+
getLayout: ()=>{
|
|
669
|
+
const { sizes: sizes } = committedValuesRef.current;
|
|
670
|
+
return sizes;
|
|
671
|
+
},
|
|
668
672
|
setLayout: (sizes)=>{
|
|
669
673
|
const total = sizes.reduce((accumulated, current)=>accumulated + current, 0);
|
|
670
674
|
(0, $3b727a2145ecd6f8$export$a7a9523472993e97)(total === 100, "Panel sizes must add up to 100%");
|
|
@@ -734,15 +738,15 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
734
738
|
// 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.
|
|
735
739
|
// For now, these logic edge cases are left to the user to handle via props.
|
|
736
740
|
panelsArray.forEach((panel)=>{
|
|
737
|
-
totalMinSize += panel.minSize;
|
|
738
|
-
if (panel.defaultSize === null) panelsWithNullDefaultSize++;
|
|
739
|
-
else totalDefaultSize += panel.defaultSize;
|
|
741
|
+
totalMinSize += panel.current.minSize;
|
|
742
|
+
if (panel.current.defaultSize === null) panelsWithNullDefaultSize++;
|
|
743
|
+
else totalDefaultSize += panel.current.defaultSize;
|
|
740
744
|
});
|
|
741
745
|
if (totalDefaultSize > 100) throw new Error(`The sum of the defaultSize of all panels in a group cannot exceed 100.`);
|
|
742
746
|
else if (totalMinSize > 100) throw new Error(`The sum of the minSize of all panels in a group cannot exceed 100.`);
|
|
743
747
|
setSizes(panelsArray.map((panel)=>{
|
|
744
|
-
if (panel.defaultSize === null) return (100 - totalDefaultSize) / panelsWithNullDefaultSize;
|
|
745
|
-
return panel.defaultSize;
|
|
748
|
+
if (panel.current.defaultSize === null) return (100 - totalDefaultSize) / panelsWithNullDefaultSize;
|
|
749
|
+
return panel.current.defaultSize;
|
|
746
750
|
}));
|
|
747
751
|
}
|
|
748
752
|
}, [
|
|
@@ -755,7 +759,9 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
755
759
|
if (autoSaveId) {
|
|
756
760
|
if (sizes.length === 0 || sizes.length !== panels.size) return;
|
|
757
761
|
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
758
|
-
|
|
762
|
+
// Limit the frequency of localStorage updates.
|
|
763
|
+
if (!$cec4cafe75f3db78$var$debounceMap[autoSaveId]) $cec4cafe75f3db78$var$debounceMap[autoSaveId] = (0, $2e8572579e31d898$export$2e2bcd8739ae039)((0, $f9cb001fbb908626$export$af183b313c61be4f), 100);
|
|
764
|
+
$cec4cafe75f3db78$var$debounceMap[autoSaveId](autoSaveId, panelsArray, sizes, storage);
|
|
759
765
|
}
|
|
760
766
|
}, [
|
|
761
767
|
autoSaveId,
|
|
@@ -791,11 +797,11 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
791
797
|
disablePointerEventsDuringResize,
|
|
792
798
|
sizes
|
|
793
799
|
]);
|
|
794
|
-
const registerPanel = (0, $6e687094f9ca8395$export$35808ee640e87ca7)((id,
|
|
800
|
+
const registerPanel = (0, $6e687094f9ca8395$export$35808ee640e87ca7)((id, panelRef)=>{
|
|
795
801
|
setPanels((prevPanels)=>{
|
|
796
802
|
if (prevPanels.has(id)) return prevPanels;
|
|
797
803
|
const nextPanels = new Map(prevPanels);
|
|
798
|
-
nextPanels.set(id,
|
|
804
|
+
nextPanels.set(id, panelRef);
|
|
799
805
|
return nextPanels;
|
|
800
806
|
});
|
|
801
807
|
}, []);
|
|
@@ -853,7 +859,7 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
853
859
|
const collapsePanel = (0, $6e687094f9ca8395$export$35808ee640e87ca7)((id)=>{
|
|
854
860
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
855
861
|
const panel = panels.get(id);
|
|
856
|
-
if (panel == null || !panel.collapsible) return;
|
|
862
|
+
if (panel == null || !panel.current.collapsible) return;
|
|
857
863
|
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
858
864
|
const index = panelsArray.indexOf(panel);
|
|
859
865
|
if (index < 0) return;
|
|
@@ -876,7 +882,7 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
876
882
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
877
883
|
const panel = panels.get(id);
|
|
878
884
|
if (panel == null) return;
|
|
879
|
-
const sizeBeforeCollapse = panelSizeBeforeCollapse.current.get(id) || panel.minSize;
|
|
885
|
+
const sizeBeforeCollapse = panelSizeBeforeCollapse.current.get(id) || panel.current.minSize;
|
|
880
886
|
if (!sizeBeforeCollapse) return;
|
|
881
887
|
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
882
888
|
const index = panelsArray.indexOf(panel);
|
|
@@ -904,8 +910,8 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
904
910
|
if (index < 0) return;
|
|
905
911
|
const currentSize = prevSizes[index];
|
|
906
912
|
if (currentSize === nextSize) return;
|
|
907
|
-
if (panel.collapsible && nextSize === 0) ;
|
|
908
|
-
else nextSize = Math.min(panel.maxSize, Math.max(panel.minSize, nextSize));
|
|
913
|
+
if (panel.current.collapsible && nextSize === 0) ;
|
|
914
|
+
else nextSize = Math.min(panel.current.maxSize, Math.max(panel.current.minSize, nextSize));
|
|
909
915
|
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$5a5b0c1d38c23c3b)(id, panelsArray);
|
|
910
916
|
if (idBefore == null || idAfter == null) return;
|
|
911
917
|
const isLastPanel = index === panelsArray.length - 1;
|