react-resizable-panels 0.0.42 → 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.
@@ -141,45 +141,6 @@ function $c33df6d7c39fd3ee$var$parseSizeFromStyle(style) {
141
141
 
142
142
 
143
143
 
144
- // Note that Panel ids might be user-provided (stable) or useId generated (non-deterministic)
145
- // so they should not be used as part of the serialization key.
146
- // Using an attribute like minSize instead should work well enough.
147
- // Pre-sorting by minSize allows remembering layouts even if panels are re-ordered/dragged.
148
- function $6889c3a3ed41cfd1$var$getSerializationKey(panels) {
149
- return panels.map((panel)=>{
150
- const { minSize: minSize , order: order } = panel;
151
- return order ? `${order}:${minSize}` : `${minSize}`;
152
- }).sort((a, b)=>a.localeCompare(b)).join(",");
153
- }
154
- function $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage) {
155
- try {
156
- const serialized = storage.getItem(`PanelGroup:sizes:${autoSaveId}`);
157
- if (serialized) {
158
- const parsed = JSON.parse(serialized);
159
- if (typeof parsed === "object" && parsed != null) return parsed;
160
- }
161
- } catch (error) {}
162
- return null;
163
- }
164
- function $6889c3a3ed41cfd1$export$9c80c6617f0386da(autoSaveId, panels, storage) {
165
- const state = $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage);
166
- if (state) {
167
- const key = $6889c3a3ed41cfd1$var$getSerializationKey(panels);
168
- var _state_key;
169
- return (_state_key = state[key]) !== null && _state_key !== void 0 ? _state_key : null;
170
- }
171
- return null;
172
- }
173
- function $6889c3a3ed41cfd1$export$af183b313c61be4f(autoSaveId, panels, sizes, storage) {
174
- const key = $6889c3a3ed41cfd1$var$getSerializationKey(panels);
175
- const state = $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage) || {};
176
- state[key] = sizes;
177
- try {
178
- storage.setItem(`PanelGroup:sizes:${autoSaveId}`, JSON.stringify(state));
179
- } catch (error) {
180
- console.error(error);
181
- }
182
- }
183
144
 
184
145
 
185
146
  const $a8e83be196252871$export$d6d3992f3becc879 = 10;
@@ -359,84 +320,6 @@ function $d6f7e4c3aa9e02d7$var$safeResizePanel(panel, delta, prevSize, event) {
359
320
  }
360
321
 
361
322
 
362
- function $8f51c2d77bf1da88$export$ec391ce65b083ed4(event, handleId, direction, initialOffset = 0, initialHandleElementRect = null) {
363
- const isHorizontal = direction === "horizontal";
364
- let pointerOffset = 0;
365
- if ($8f51c2d77bf1da88$export$764db16956f554f8(event)) pointerOffset = isHorizontal ? event.clientX : event.clientY;
366
- else if ($8f51c2d77bf1da88$export$c4dfce035d43d1e0(event)) {
367
- const firstTouch = event.touches[0];
368
- pointerOffset = isHorizontal ? firstTouch.screenX : firstTouch.screenY;
369
- } else return 0;
370
- const handleElement = (0, $d6f7e4c3aa9e02d7$export$2e27d3a347680388)(handleId);
371
- const rect = initialHandleElementRect || handleElement.getBoundingClientRect();
372
- const elementOffset = isHorizontal ? rect.left : rect.top;
373
- return pointerOffset - elementOffset - initialOffset;
374
- }
375
- function $8f51c2d77bf1da88$export$354b17c0684607ed(event, groupId, handleId, panelsArray, direction, prevSizes, initialDragState) {
376
- const { dragOffset: dragOffset = 0 , dragHandleRect: dragHandleRect , sizes: initialSizes } = initialDragState || {};
377
- // If we're resizing by mouse or touch, use the initial sizes as a base.
378
- // This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
379
- const baseSizes = initialSizes || prevSizes;
380
- if ($8f51c2d77bf1da88$export$e7bf60a870f429b0(event)) {
381
- const isHorizontal = direction === "horizontal";
382
- const groupElement = (0, $d6f7e4c3aa9e02d7$export$5e67632cf3550a9c)(groupId);
383
- const rect = groupElement.getBoundingClientRect();
384
- const groupSizeInPixels = isHorizontal ? rect.width : rect.height;
385
- const denominator = event.shiftKey ? 10 : 100;
386
- const delta = groupSizeInPixels / denominator;
387
- let movement = 0;
388
- switch(event.key){
389
- case "ArrowDown":
390
- movement = isHorizontal ? 0 : delta;
391
- break;
392
- case "ArrowLeft":
393
- movement = isHorizontal ? -delta : 0;
394
- break;
395
- case "ArrowRight":
396
- movement = isHorizontal ? delta : 0;
397
- break;
398
- case "ArrowUp":
399
- movement = isHorizontal ? 0 : -delta;
400
- break;
401
- case "End":
402
- movement = groupSizeInPixels;
403
- break;
404
- case "Home":
405
- movement = -groupSizeInPixels;
406
- break;
407
- }
408
- // If the Panel being resized is collapsible,
409
- // we need to special case resizing around the minSize boundary.
410
- // If contracting, Panels should shrink to their minSize and then snap to fully collapsed.
411
- // If expanding from collapsed, they should snap back to their minSize.
412
- const [idBefore, idAfter] = (0, $d6f7e4c3aa9e02d7$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
413
- const targetPanelId = movement < 0 ? idBefore : idAfter;
414
- const targetPanelIndex = panelsArray.findIndex((panel)=>panel.id === targetPanelId);
415
- const targetPanel = panelsArray[targetPanelIndex];
416
- if (targetPanel.collapsible) {
417
- const baseSize = baseSizes[targetPanelIndex];
418
- if (baseSize === 0 || baseSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)) === targetPanel.minSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879))) movement = movement < 0 ? -targetPanel.minSize * groupSizeInPixels : targetPanel.minSize * groupSizeInPixels;
419
- }
420
- return movement;
421
- } else return $8f51c2d77bf1da88$export$ec391ce65b083ed4(event, handleId, direction, dragOffset, dragHandleRect);
422
- }
423
- function $8f51c2d77bf1da88$export$e7bf60a870f429b0(event) {
424
- return event.type === "keydown";
425
- }
426
- function $8f51c2d77bf1da88$export$764db16956f554f8(event) {
427
- return event.type.startsWith("mouse");
428
- }
429
- function $8f51c2d77bf1da88$export$c4dfce035d43d1e0(event) {
430
- return event.type.startsWith("touch");
431
- }
432
-
433
-
434
-
435
-
436
-
437
-
438
-
439
-
440
323
  function $5f33910cd46e8ae7$export$a7a9523472993e97(expectedCondition, message = "Assertion failed!") {
441
324
  if (!expectedCondition) {
442
325
  console.error(message);
@@ -563,6 +446,91 @@ function $4a90471e7083b52f$export$33b0bea6ac3ffb03({ disabled: disabled , handle
563
446
  }
564
447
 
565
448
 
449
+
450
+ function $c892f0f705e6ded5$export$b141efd0b0fb9174(arrayA, arrayB) {
451
+ if (arrayA.length !== arrayB.length) return false;
452
+ for(let index = 0; index < arrayA.length; index++){
453
+ if (arrayA[index] !== arrayB[index]) return false;
454
+ }
455
+ return true;
456
+ }
457
+
458
+
459
+
460
+
461
+
462
+ function $8f51c2d77bf1da88$export$ec391ce65b083ed4(event, handleId, direction, initialOffset = 0, initialHandleElementRect = null) {
463
+ const isHorizontal = direction === "horizontal";
464
+ let pointerOffset = 0;
465
+ if ($8f51c2d77bf1da88$export$764db16956f554f8(event)) pointerOffset = isHorizontal ? event.clientX : event.clientY;
466
+ else if ($8f51c2d77bf1da88$export$c4dfce035d43d1e0(event)) {
467
+ const firstTouch = event.touches[0];
468
+ pointerOffset = isHorizontal ? firstTouch.screenX : firstTouch.screenY;
469
+ } else return 0;
470
+ const handleElement = (0, $d6f7e4c3aa9e02d7$export$2e27d3a347680388)(handleId);
471
+ const rect = initialHandleElementRect || handleElement.getBoundingClientRect();
472
+ const elementOffset = isHorizontal ? rect.left : rect.top;
473
+ return pointerOffset - elementOffset - initialOffset;
474
+ }
475
+ function $8f51c2d77bf1da88$export$354b17c0684607ed(event, groupId, handleId, panelsArray, direction, prevSizes, initialDragState) {
476
+ const { dragOffset: dragOffset = 0 , dragHandleRect: dragHandleRect , sizes: initialSizes } = initialDragState || {};
477
+ // If we're resizing by mouse or touch, use the initial sizes as a base.
478
+ // This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
479
+ const baseSizes = initialSizes || prevSizes;
480
+ if ($8f51c2d77bf1da88$export$e7bf60a870f429b0(event)) {
481
+ const isHorizontal = direction === "horizontal";
482
+ const groupElement = (0, $d6f7e4c3aa9e02d7$export$5e67632cf3550a9c)(groupId);
483
+ const rect = groupElement.getBoundingClientRect();
484
+ const groupSizeInPixels = isHorizontal ? rect.width : rect.height;
485
+ const denominator = event.shiftKey ? 10 : 100;
486
+ const delta = groupSizeInPixels / denominator;
487
+ let movement = 0;
488
+ switch(event.key){
489
+ case "ArrowDown":
490
+ movement = isHorizontal ? 0 : delta;
491
+ break;
492
+ case "ArrowLeft":
493
+ movement = isHorizontal ? -delta : 0;
494
+ break;
495
+ case "ArrowRight":
496
+ movement = isHorizontal ? delta : 0;
497
+ break;
498
+ case "ArrowUp":
499
+ movement = isHorizontal ? 0 : -delta;
500
+ break;
501
+ case "End":
502
+ movement = groupSizeInPixels;
503
+ break;
504
+ case "Home":
505
+ movement = -groupSizeInPixels;
506
+ break;
507
+ }
508
+ // If the Panel being resized is collapsible,
509
+ // we need to special case resizing around the minSize boundary.
510
+ // If contracting, Panels should shrink to their minSize and then snap to fully collapsed.
511
+ // If expanding from collapsed, they should snap back to their minSize.
512
+ const [idBefore, idAfter] = (0, $d6f7e4c3aa9e02d7$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
513
+ const targetPanelId = movement < 0 ? idBefore : idAfter;
514
+ const targetPanelIndex = panelsArray.findIndex((panel)=>panel.id === targetPanelId);
515
+ const targetPanel = panelsArray[targetPanelIndex];
516
+ if (targetPanel.collapsible) {
517
+ const baseSize = baseSizes[targetPanelIndex];
518
+ if (baseSize === 0 || baseSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)) === targetPanel.minSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879))) movement = movement < 0 ? -targetPanel.minSize * groupSizeInPixels : targetPanel.minSize * groupSizeInPixels;
519
+ }
520
+ return movement;
521
+ } else return $8f51c2d77bf1da88$export$ec391ce65b083ed4(event, handleId, direction, dragOffset, dragHandleRect);
522
+ }
523
+ function $8f51c2d77bf1da88$export$e7bf60a870f429b0(event) {
524
+ return event.type === "keydown";
525
+ }
526
+ function $8f51c2d77bf1da88$export$764db16956f554f8(event) {
527
+ return event.type.startsWith("mouse");
528
+ }
529
+ function $8f51c2d77bf1da88$export$c4dfce035d43d1e0(event) {
530
+ return event.type.startsWith("touch");
531
+ }
532
+
533
+
566
534
  let $8d9d88bebf1a8ace$var$currentState = null;
567
535
  let $8d9d88bebf1a8ace$var$element = null;
568
536
  function $8d9d88bebf1a8ace$export$fa35f3322c52262f(state) {
@@ -612,18 +580,49 @@ function $f7d932e9304c1581$export$2e2bcd8739ae039(callback, durationMs = 10) {
612
580
  }
613
581
 
614
582
 
615
- function $c892f0f705e6ded5$export$b141efd0b0fb9174(arrayA, arrayB) {
616
- if (arrayA.length !== arrayB.length) return false;
617
- for(let index = 0; index < arrayA.length; index++){
618
- if (arrayA[index] !== arrayB[index]) return false;
583
+
584
+ // Note that Panel ids might be user-provided (stable) or useId generated (non-deterministic)
585
+ // so they should not be used as part of the serialization key.
586
+ // Using an attribute like minSize instead should work well enough.
587
+ // Pre-sorting by minSize allows remembering layouts even if panels are re-ordered/dragged.
588
+ function $6889c3a3ed41cfd1$var$getSerializationKey(panels) {
589
+ return panels.map((panel)=>{
590
+ const { minSize: minSize , order: order } = panel;
591
+ return order ? `${order}:${minSize}` : `${minSize}`;
592
+ }).sort((a, b)=>a.localeCompare(b)).join(",");
593
+ }
594
+ function $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage) {
595
+ try {
596
+ const serialized = storage.getItem(`PanelGroup:sizes:${autoSaveId}`);
597
+ if (serialized) {
598
+ const parsed = JSON.parse(serialized);
599
+ if (typeof parsed === "object" && parsed != null) return parsed;
600
+ }
601
+ } catch (error) {}
602
+ return null;
603
+ }
604
+ function $6889c3a3ed41cfd1$export$9c80c6617f0386da(autoSaveId, panels, storage) {
605
+ const state = $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage);
606
+ if (state) {
607
+ const key = $6889c3a3ed41cfd1$var$getSerializationKey(panels);
608
+ var _state_key;
609
+ return (_state_key = state[key]) !== null && _state_key !== void 0 ? _state_key : null;
610
+ }
611
+ return null;
612
+ }
613
+ function $6889c3a3ed41cfd1$export$af183b313c61be4f(autoSaveId, panels, sizes, storage) {
614
+ const key = $6889c3a3ed41cfd1$var$getSerializationKey(panels);
615
+ const state = $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage) || {};
616
+ state[key] = sizes;
617
+ try {
618
+ storage.setItem(`PanelGroup:sizes:${autoSaveId}`, JSON.stringify(state));
619
+ } catch (error) {
620
+ console.error(error);
619
621
  }
620
- return true;
621
622
  }
622
623
 
623
624
 
624
-
625
- // Limit the frequency of localStorage updates.
626
- const $3daa5d4c086ea816$var$savePanelGroupLayoutDebounced = (0, $f7d932e9304c1581$export$2e2bcd8739ae039)((0, $6889c3a3ed41cfd1$export$af183b313c61be4f), 100);
625
+ const $3daa5d4c086ea816$var$debounceMap = {};
627
626
  function $3daa5d4c086ea816$var$throwServerError() {
628
627
  throw new Error('PanelGroup "storage" prop required for server rendering.');
629
628
  }
@@ -658,6 +657,10 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
658
657
  sizes: sizes
659
658
  });
660
659
  (0, $ef07efbe5fa7d87e$export$d5a552a76deda3c2)(forwardedRef, ()=>({
660
+ getLayout: ()=>{
661
+ const { sizes: sizes } = committedValuesRef.current;
662
+ return sizes;
663
+ },
661
664
  setLayout: (sizes)=>{
662
665
  const total = sizes.reduce((accumulated, current)=>accumulated + current, 0);
663
666
  (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(total === 100, "Panel sizes must add up to 100%");
@@ -748,7 +751,9 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
748
751
  if (autoSaveId) {
749
752
  if (sizes.length === 0 || sizes.length !== panels.size) return;
750
753
  const panelsArray = (0, $d6f7e4c3aa9e02d7$export$a861c0ad45885494)(panels);
751
- $3daa5d4c086ea816$var$savePanelGroupLayoutDebounced(autoSaveId, panelsArray, sizes, storage);
754
+ // Limit the frequency of localStorage updates.
755
+ if (!$3daa5d4c086ea816$var$debounceMap[autoSaveId]) $3daa5d4c086ea816$var$debounceMap[autoSaveId] = (0, $f7d932e9304c1581$export$2e2bcd8739ae039)((0, $6889c3a3ed41cfd1$export$af183b313c61be4f), 100);
756
+ $3daa5d4c086ea816$var$debounceMap[autoSaveId](autoSaveId, panelsArray, sizes, storage);
752
757
  }
753
758
  }, [
754
759
  autoSaveId,