react-resizable-panels 0.0.41 → 0.0.43
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 +133 -128
- package/dist/react-resizable-panels.js.map +1 -1
- package/dist/react-resizable-panels.module.js +133 -128
- package/dist/react-resizable-panels.module.js.map +1 -1
- package/package.json +1 -1
- package/src/PanelGroup.ts +27 -12
- package/src/index.ts +4 -4
- package/src/utils/cursor.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.43
|
|
4
|
+
* Add imperative `getLayout` API to `PanelGroup`
|
|
5
|
+
* [#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
|
|
6
|
+
|
|
7
|
+
## 0.0.42
|
|
8
|
+
* Change cursor style from `col-resize`/`row-resize` to `ew-resize`/`ns-resize` to better match cursor style at edges of a panel.
|
|
9
|
+
|
|
3
10
|
## 0.0.41
|
|
4
11
|
* Add imperative `setLayout` API for `PanelGroup`.
|
|
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;AEMxE,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,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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"}
|
|
@@ -148,45 +148,6 @@ function $45da0e827c614f1d$var$parseSizeFromStyle(style) {
|
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
|
|
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
151
|
|
|
191
152
|
|
|
192
153
|
const $9abd79656a89cd3a$export$d6d3992f3becc879 = 10;
|
|
@@ -366,84 +327,6 @@ function $cda3cc4b1114cf23$var$safeResizePanel(panel, delta, prevSize, event) {
|
|
|
366
327
|
}
|
|
367
328
|
|
|
368
329
|
|
|
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
330
|
function $3b727a2145ecd6f8$export$a7a9523472993e97(expectedCondition, message = "Assertion failed!") {
|
|
448
331
|
if (!expectedCondition) {
|
|
449
332
|
console.error(message);
|
|
@@ -570,18 +453,103 @@ function $a695670cc57a5969$export$33b0bea6ac3ffb03({ disabled: disabled , handle
|
|
|
570
453
|
}
|
|
571
454
|
|
|
572
455
|
|
|
456
|
+
|
|
457
|
+
function $d31ef7445a11a6c5$export$b141efd0b0fb9174(arrayA, arrayB) {
|
|
458
|
+
if (arrayA.length !== arrayB.length) return false;
|
|
459
|
+
for(let index = 0; index < arrayA.length; index++){
|
|
460
|
+
if (arrayA[index] !== arrayB[index]) return false;
|
|
461
|
+
}
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
function $47eee9224cfec8e8$export$ec391ce65b083ed4(event, handleId, direction, initialOffset = 0, initialHandleElementRect = null) {
|
|
470
|
+
const isHorizontal = direction === "horizontal";
|
|
471
|
+
let pointerOffset = 0;
|
|
472
|
+
if ($47eee9224cfec8e8$export$764db16956f554f8(event)) pointerOffset = isHorizontal ? event.clientX : event.clientY;
|
|
473
|
+
else if ($47eee9224cfec8e8$export$c4dfce035d43d1e0(event)) {
|
|
474
|
+
const firstTouch = event.touches[0];
|
|
475
|
+
pointerOffset = isHorizontal ? firstTouch.screenX : firstTouch.screenY;
|
|
476
|
+
} else return 0;
|
|
477
|
+
const handleElement = (0, $cda3cc4b1114cf23$export$2e27d3a347680388)(handleId);
|
|
478
|
+
const rect = initialHandleElementRect || handleElement.getBoundingClientRect();
|
|
479
|
+
const elementOffset = isHorizontal ? rect.left : rect.top;
|
|
480
|
+
return pointerOffset - elementOffset - initialOffset;
|
|
481
|
+
}
|
|
482
|
+
function $47eee9224cfec8e8$export$354b17c0684607ed(event, groupId, handleId, panelsArray, direction, prevSizes, initialDragState) {
|
|
483
|
+
const { dragOffset: dragOffset = 0 , dragHandleRect: dragHandleRect , sizes: initialSizes } = initialDragState || {};
|
|
484
|
+
// If we're resizing by mouse or touch, use the initial sizes as a base.
|
|
485
|
+
// This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
|
|
486
|
+
const baseSizes = initialSizes || prevSizes;
|
|
487
|
+
if ($47eee9224cfec8e8$export$e7bf60a870f429b0(event)) {
|
|
488
|
+
const isHorizontal = direction === "horizontal";
|
|
489
|
+
const groupElement = (0, $cda3cc4b1114cf23$export$5e67632cf3550a9c)(groupId);
|
|
490
|
+
const rect = groupElement.getBoundingClientRect();
|
|
491
|
+
const groupSizeInPixels = isHorizontal ? rect.width : rect.height;
|
|
492
|
+
const denominator = event.shiftKey ? 10 : 100;
|
|
493
|
+
const delta = groupSizeInPixels / denominator;
|
|
494
|
+
let movement = 0;
|
|
495
|
+
switch(event.key){
|
|
496
|
+
case "ArrowDown":
|
|
497
|
+
movement = isHorizontal ? 0 : delta;
|
|
498
|
+
break;
|
|
499
|
+
case "ArrowLeft":
|
|
500
|
+
movement = isHorizontal ? -delta : 0;
|
|
501
|
+
break;
|
|
502
|
+
case "ArrowRight":
|
|
503
|
+
movement = isHorizontal ? delta : 0;
|
|
504
|
+
break;
|
|
505
|
+
case "ArrowUp":
|
|
506
|
+
movement = isHorizontal ? 0 : -delta;
|
|
507
|
+
break;
|
|
508
|
+
case "End":
|
|
509
|
+
movement = groupSizeInPixels;
|
|
510
|
+
break;
|
|
511
|
+
case "Home":
|
|
512
|
+
movement = -groupSizeInPixels;
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
// If the Panel being resized is collapsible,
|
|
516
|
+
// we need to special case resizing around the minSize boundary.
|
|
517
|
+
// If contracting, Panels should shrink to their minSize and then snap to fully collapsed.
|
|
518
|
+
// If expanding from collapsed, they should snap back to their minSize.
|
|
519
|
+
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
|
|
520
|
+
const targetPanelId = movement < 0 ? idBefore : idAfter;
|
|
521
|
+
const targetPanelIndex = panelsArray.findIndex((panel)=>panel.id === targetPanelId);
|
|
522
|
+
const targetPanel = panelsArray[targetPanelIndex];
|
|
523
|
+
if (targetPanel.collapsible) {
|
|
524
|
+
const baseSize = baseSizes[targetPanelIndex];
|
|
525
|
+
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;
|
|
526
|
+
}
|
|
527
|
+
return movement;
|
|
528
|
+
} else return $47eee9224cfec8e8$export$ec391ce65b083ed4(event, handleId, direction, dragOffset, dragHandleRect);
|
|
529
|
+
}
|
|
530
|
+
function $47eee9224cfec8e8$export$e7bf60a870f429b0(event) {
|
|
531
|
+
return event.type === "keydown";
|
|
532
|
+
}
|
|
533
|
+
function $47eee9224cfec8e8$export$764db16956f554f8(event) {
|
|
534
|
+
return event.type.startsWith("mouse");
|
|
535
|
+
}
|
|
536
|
+
function $47eee9224cfec8e8$export$c4dfce035d43d1e0(event) {
|
|
537
|
+
return event.type.startsWith("touch");
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
|
|
573
541
|
let $08745f7373322b05$var$currentState = null;
|
|
574
542
|
let $08745f7373322b05$var$element = null;
|
|
575
543
|
function $08745f7373322b05$export$fa35f3322c52262f(state) {
|
|
576
544
|
switch(state){
|
|
577
545
|
case "horizontal":
|
|
578
|
-
return "
|
|
546
|
+
return "ew-resize";
|
|
579
547
|
case "horizontal-max":
|
|
580
548
|
return "w-resize";
|
|
581
549
|
case "horizontal-min":
|
|
582
550
|
return "e-resize";
|
|
583
551
|
case "vertical":
|
|
584
|
-
return "
|
|
552
|
+
return "ns-resize";
|
|
585
553
|
case "vertical-max":
|
|
586
554
|
return "n-resize";
|
|
587
555
|
case "vertical-min":
|
|
@@ -619,18 +587,49 @@ function $2e8572579e31d898$export$2e2bcd8739ae039(callback, durationMs = 10) {
|
|
|
619
587
|
}
|
|
620
588
|
|
|
621
589
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
590
|
+
|
|
591
|
+
// Note that Panel ids might be user-provided (stable) or useId generated (non-deterministic)
|
|
592
|
+
// so they should not be used as part of the serialization key.
|
|
593
|
+
// Using an attribute like minSize instead should work well enough.
|
|
594
|
+
// Pre-sorting by minSize allows remembering layouts even if panels are re-ordered/dragged.
|
|
595
|
+
function $f9cb001fbb908626$var$getSerializationKey(panels) {
|
|
596
|
+
return panels.map((panel)=>{
|
|
597
|
+
const { minSize: minSize , order: order } = panel;
|
|
598
|
+
return order ? `${order}:${minSize}` : `${minSize}`;
|
|
599
|
+
}).sort((a, b)=>a.localeCompare(b)).join(",");
|
|
600
|
+
}
|
|
601
|
+
function $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
602
|
+
try {
|
|
603
|
+
const serialized = storage.getItem(`PanelGroup:sizes:${autoSaveId}`);
|
|
604
|
+
if (serialized) {
|
|
605
|
+
const parsed = JSON.parse(serialized);
|
|
606
|
+
if (typeof parsed === "object" && parsed != null) return parsed;
|
|
607
|
+
}
|
|
608
|
+
} catch (error) {}
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
function $f9cb001fbb908626$export$9c80c6617f0386da(autoSaveId, panels, storage) {
|
|
612
|
+
const state = $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage);
|
|
613
|
+
if (state) {
|
|
614
|
+
const key = $f9cb001fbb908626$var$getSerializationKey(panels);
|
|
615
|
+
var _state_key;
|
|
616
|
+
return (_state_key = state[key]) !== null && _state_key !== void 0 ? _state_key : null;
|
|
617
|
+
}
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
function $f9cb001fbb908626$export$af183b313c61be4f(autoSaveId, panels, sizes, storage) {
|
|
621
|
+
const key = $f9cb001fbb908626$var$getSerializationKey(panels);
|
|
622
|
+
const state = $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage) || {};
|
|
623
|
+
state[key] = sizes;
|
|
624
|
+
try {
|
|
625
|
+
storage.setItem(`PanelGroup:sizes:${autoSaveId}`, JSON.stringify(state));
|
|
626
|
+
} catch (error) {
|
|
627
|
+
console.error(error);
|
|
626
628
|
}
|
|
627
|
-
return true;
|
|
628
629
|
}
|
|
629
630
|
|
|
630
631
|
|
|
631
|
-
|
|
632
|
-
// Limit the frequency of localStorage updates.
|
|
633
|
-
const $cec4cafe75f3db78$var$savePanelGroupLayoutDebounced = (0, $2e8572579e31d898$export$2e2bcd8739ae039)((0, $f9cb001fbb908626$export$af183b313c61be4f), 100);
|
|
632
|
+
const $cec4cafe75f3db78$var$debounceMap = {};
|
|
634
633
|
function $cec4cafe75f3db78$var$throwServerError() {
|
|
635
634
|
throw new Error('PanelGroup "storage" prop required for server rendering.');
|
|
636
635
|
}
|
|
@@ -665,6 +664,10 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
665
664
|
sizes: sizes
|
|
666
665
|
});
|
|
667
666
|
(0, $6e687094f9ca8395$export$d5a552a76deda3c2)(forwardedRef, ()=>({
|
|
667
|
+
getLayout: ()=>{
|
|
668
|
+
const { sizes: sizes } = committedValuesRef.current;
|
|
669
|
+
return sizes;
|
|
670
|
+
},
|
|
668
671
|
setLayout: (sizes)=>{
|
|
669
672
|
const total = sizes.reduce((accumulated, current)=>accumulated + current, 0);
|
|
670
673
|
(0, $3b727a2145ecd6f8$export$a7a9523472993e97)(total === 100, "Panel sizes must add up to 100%");
|
|
@@ -755,7 +758,9 @@ function $cec4cafe75f3db78$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
|
|
|
755
758
|
if (autoSaveId) {
|
|
756
759
|
if (sizes.length === 0 || sizes.length !== panels.size) return;
|
|
757
760
|
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
758
|
-
|
|
761
|
+
// Limit the frequency of localStorage updates.
|
|
762
|
+
if (!$cec4cafe75f3db78$var$debounceMap[autoSaveId]) $cec4cafe75f3db78$var$debounceMap[autoSaveId] = (0, $2e8572579e31d898$export$2e2bcd8739ae039)((0, $f9cb001fbb908626$export$af183b313c61be4f), 100);
|
|
763
|
+
$cec4cafe75f3db78$var$debounceMap[autoSaveId](autoSaveId, panelsArray, sizes, storage);
|
|
759
764
|
}
|
|
760
765
|
}, [
|
|
761
766
|
autoSaveId,
|