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.
@@ -12,7 +12,6 @@ const { createElement: $ef07efbe5fa7d87e$export$c8a8987d4410bf2d , createContext
12
12
  const $ef07efbe5fa7d87e$export$f680877a34711e37 = $jhddX$react["useId".toString()];
13
13
 
14
14
 
15
-
16
15
  const $3f95d3e171760903$var$canUseEffectHooks = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
17
16
  const $3f95d3e171760903$var$useIsomorphicLayoutEffect = $3f95d3e171760903$var$canUseEffectHooks ? (0, $ef07efbe5fa7d87e$export$e5c5a5f917a5871c) : ()=>{};
18
17
  var $3f95d3e171760903$export$2e2bcd8739ae039 = $3f95d3e171760903$var$useIsomorphicLayoutEffect;
@@ -30,6 +29,7 @@ function $e504a2438473eda9$export$2e2bcd8739ae039(idFromParams = null) {
30
29
 
31
30
 
32
31
 
32
+
33
33
  const $af466b485b9d515d$export$7d8c6d083caec74a = (0, $ef07efbe5fa7d87e$export$fd42f52fd3ae1109)(null);
34
34
  // Workaround for Parcel scope hoisting (which renames objects/functions).
35
35
  // Casting to :any is required to avoid corrupting the generated TypeScript types.
@@ -61,37 +61,38 @@ function $c33df6d7c39fd3ee$var$PanelWithForwardedRef({ children: children = null
61
61
  defaultSize = minSize;
62
62
  }
63
63
  }
64
+ const style = getPanelStyle(panelId);
65
+ const committedValuesRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
66
+ size: $c33df6d7c39fd3ee$var$parseSizeFromStyle(style)
67
+ });
68
+ const panelDataRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
69
+ callbacksRef: callbacksRef,
70
+ collapsible: collapsible,
71
+ defaultSize: defaultSize,
72
+ id: panelId,
73
+ maxSize: maxSize,
74
+ minSize: minSize,
75
+ order: order
76
+ });
64
77
  (0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
65
- const panel = {
66
- callbacksRef: callbacksRef,
67
- collapsible: collapsible,
68
- defaultSize: defaultSize,
69
- id: panelId,
70
- maxSize: maxSize,
71
- minSize: minSize,
72
- order: order
73
- };
74
- registerPanel(panelId, panel);
78
+ committedValuesRef.current.size = $c33df6d7c39fd3ee$var$parseSizeFromStyle(style);
79
+ panelDataRef.current.callbacksRef = callbacksRef;
80
+ panelDataRef.current.collapsible = collapsible;
81
+ panelDataRef.current.defaultSize = defaultSize;
82
+ panelDataRef.current.id = panelId;
83
+ panelDataRef.current.maxSize = maxSize;
84
+ panelDataRef.current.minSize = minSize;
85
+ panelDataRef.current.order = order;
86
+ });
87
+ (0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
88
+ registerPanel(panelId, panelDataRef);
75
89
  return ()=>{
76
90
  unregisterPanel(panelId);
77
91
  };
78
92
  }, [
79
- collapsible,
80
- defaultSize,
81
- panelId,
82
- maxSize,
83
- minSize,
84
- order,
85
93
  registerPanel,
86
94
  unregisterPanel
87
95
  ]);
88
- const style = getPanelStyle(panelId);
89
- const committedValuesRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
90
- size: $c33df6d7c39fd3ee$var$parseSizeFromStyle(style)
91
- });
92
- (0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
93
- committedValuesRef.current.size = $c33df6d7c39fd3ee$var$parseSizeFromStyle(style);
94
- });
95
96
  (0, $ef07efbe5fa7d87e$export$d5a552a76deda3c2)(forwardedRef, ()=>({
96
97
  collapse: ()=>collapsePanel(panelId),
97
98
  expand: ()=>expandPanel(panelId),
@@ -141,45 +142,6 @@ function $c33df6d7c39fd3ee$var$parseSizeFromStyle(style) {
141
142
 
142
143
 
143
144
 
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
145
 
184
146
 
185
147
  const $a8e83be196252871$export$d6d3992f3becc879 = 10;
@@ -205,7 +167,7 @@ function $d6f7e4c3aa9e02d7$export$f50bae335f53943c(event, panels, idBefore, idAf
205
167
  // Max-bounds check the panel being expanded first.
206
168
  {
207
169
  const pivotId = delta < 0 ? idAfter : idBefore;
208
- const index = panelsArray.findIndex((panel)=>panel.id === pivotId);
170
+ const index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
209
171
  const panel = panelsArray[index];
210
172
  const baseSize = baseSizes[index];
211
173
  const nextSize = $d6f7e4c3aa9e02d7$var$safeResizePanel(panel, Math.abs(delta), baseSize, event);
@@ -217,14 +179,14 @@ function $d6f7e4c3aa9e02d7$export$f50bae335f53943c(event, panels, idBefore, idAf
217
179
  }
218
180
  }
219
181
  let pivotId = delta < 0 ? idBefore : idAfter;
220
- let index = panelsArray.findIndex((panel)=>panel.id === pivotId);
182
+ let index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
221
183
  while(true){
222
184
  const panel = panelsArray[index];
223
185
  const baseSize = baseSizes[index];
224
186
  const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
225
187
  const nextSize = $d6f7e4c3aa9e02d7$var$safeResizePanel(panel, 0 - deltaRemaining, baseSize, event);
226
188
  if (baseSize !== nextSize) {
227
- if (nextSize === 0 && baseSize > 0) panelSizeBeforeCollapse.set(panel.id, baseSize);
189
+ if (nextSize === 0 && baseSize > 0) panelSizeBeforeCollapse.set(panel.current.id, baseSize);
228
190
  deltaApplied += baseSize - nextSize;
229
191
  nextSizes[index] = nextSize;
230
192
  if (deltaApplied.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)).localeCompare(Math.abs(delta).toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)), undefined, {
@@ -242,7 +204,7 @@ function $d6f7e4c3aa9e02d7$export$f50bae335f53943c(event, panels, idBefore, idAf
242
204
  if (deltaApplied === 0) return baseSizes;
243
205
  // Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
244
206
  pivotId = delta < 0 ? idAfter : idBefore;
245
- index = panelsArray.findIndex((panel)=>panel.id === pivotId);
207
+ index = panelsArray.findIndex((panel)=>panel.current.id === pivotId);
246
208
  nextSizes[index] = baseSizes[index] + deltaApplied;
247
209
  return nextSizes;
248
210
  }
@@ -250,7 +212,7 @@ function $d6f7e4c3aa9e02d7$export$b8e48269e4faa934(panelsArray, prevSizes, nextS
250
212
  nextSizes.forEach((nextSize, index)=>{
251
213
  const prevSize = prevSizes[index];
252
214
  if (prevSize !== nextSize) {
253
- const { callbacksRef: callbacksRef , collapsible: collapsible } = panelsArray[index];
215
+ const { callbacksRef: callbacksRef , collapsible: collapsible } = panelsArray[index].current;
254
216
  const { onCollapse: onCollapse , onResize: onResize } = callbacksRef.current;
255
217
  if (onResize) onResize(nextSize);
256
218
  if (collapsible && onCollapse) {
@@ -267,14 +229,14 @@ function $d6f7e4c3aa9e02d7$export$5a5b0c1d38c23c3b(id, panelsArray) {
267
229
  null,
268
230
  null
269
231
  ];
270
- const index = panelsArray.findIndex((panel)=>panel.id === id);
232
+ const index = panelsArray.findIndex((panel)=>panel.current.id === id);
271
233
  if (index < 0) return [
272
234
  null,
273
235
  null
274
236
  ];
275
237
  const isLastPanel = index === panelsArray.length - 1;
276
- const idBefore = isLastPanel ? panelsArray[index - 1].id : id;
277
- const idAfter = isLastPanel ? id : panelsArray[index + 1].id;
238
+ const idBefore = isLastPanel ? panelsArray[index - 1].current.id : id;
239
+ const idAfter = isLastPanel ? id : panelsArray[index + 1].current.id;
278
240
  return [
279
241
  idBefore,
280
242
  idAfter
@@ -283,7 +245,7 @@ function $d6f7e4c3aa9e02d7$export$5a5b0c1d38c23c3b(id, panelsArray) {
283
245
  function $d6f7e4c3aa9e02d7$export$6f43503e166de6fb(panels, id, sizes) {
284
246
  if (panels.size === 1) return "100";
285
247
  const panelsArray = $d6f7e4c3aa9e02d7$export$a861c0ad45885494(panels);
286
- const index = panelsArray.findIndex((panel)=>panel.id === id);
248
+ const index = panelsArray.findIndex((panel)=>panel.current.id === id);
287
249
  const size = sizes[index];
288
250
  if (size == null) return "0";
289
251
  return size.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879));
@@ -315,14 +277,14 @@ function $d6f7e4c3aa9e02d7$export$ae14931f0a0256a3(groupId) {
315
277
  return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
316
278
  }
317
279
  function $d6f7e4c3aa9e02d7$export$68d3a33c21dfbe27(groupId, handleId, panelsArray) {
318
- var _panelsArray_index, _panelsArray_;
280
+ var _panelsArray_index, _panelsArray_index_current, _panelsArray_, _panelsArray__current;
319
281
  const handle = $d6f7e4c3aa9e02d7$export$2e27d3a347680388(handleId);
320
282
  const handles = $d6f7e4c3aa9e02d7$export$ae14931f0a0256a3(groupId);
321
283
  const index = handle ? handles.indexOf(handle) : -1;
322
- var _panelsArray_index_id;
323
- const idBefore = (_panelsArray_index_id = (_panelsArray_index = panelsArray[index]) === null || _panelsArray_index === void 0 ? void 0 : _panelsArray_index.id) !== null && _panelsArray_index_id !== void 0 ? _panelsArray_index_id : null;
324
- var _panelsArray__id;
325
- const idAfter = (_panelsArray__id = (_panelsArray_ = panelsArray[index + 1]) === null || _panelsArray_ === void 0 ? void 0 : _panelsArray_.id) !== null && _panelsArray__id !== void 0 ? _panelsArray__id : null;
284
+ var _panelsArray_index_current_id;
285
+ 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;
286
+ var _panelsArray__current_id;
287
+ 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;
326
288
  return [
327
289
  idBefore,
328
290
  idAfter
@@ -330,8 +292,8 @@ function $d6f7e4c3aa9e02d7$export$68d3a33c21dfbe27(groupId, handleId, panelsArra
330
292
  }
331
293
  function $d6f7e4c3aa9e02d7$export$a861c0ad45885494(panels) {
332
294
  return Array.from(panels.values()).sort((panelA, panelB)=>{
333
- const orderA = panelA.order;
334
- const orderB = panelB.order;
295
+ const orderA = panelA.current.order;
296
+ const orderB = panelB.current.order;
335
297
  if (orderA == null && orderB == null) return 0;
336
298
  else if (orderA == null) return -1;
337
299
  else if (orderB == null) return 1;
@@ -340,7 +302,7 @@ function $d6f7e4c3aa9e02d7$export$a861c0ad45885494(panels) {
340
302
  }
341
303
  function $d6f7e4c3aa9e02d7$var$safeResizePanel(panel, delta, prevSize, event) {
342
304
  const nextSizeUnsafe = prevSize + delta;
343
- if (panel.collapsible) {
305
+ if (panel.current.collapsible) {
344
306
  if (prevSize > 0) {
345
307
  if (nextSizeUnsafe <= 0) return 0;
346
308
  } else {
@@ -350,93 +312,15 @@ function $d6f7e4c3aa9e02d7$var$safeResizePanel(panel, delta, prevSize, event) {
350
312
  // Keyboard events should expand a collapsed panel to the min size,
351
313
  // but mouse events should wait until the panel has reached its min size
352
314
  // to avoid a visual flickering when dragging between collapsed and min size.
353
- if (nextSizeUnsafe < panel.minSize) return 0;
315
+ if (nextSizeUnsafe < panel.current.minSize) return 0;
354
316
  }
355
317
  }
356
318
  }
357
- const nextSize = Math.min(panel.maxSize, Math.max(panel.minSize, nextSizeUnsafe));
319
+ const nextSize = Math.min(panel.current.maxSize, Math.max(panel.current.minSize, nextSizeUnsafe));
358
320
  return nextSize;
359
321
  }
360
322
 
361
323
 
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
324
  function $5f33910cd46e8ae7$export$a7a9523472993e97(expectedCondition, message = "Assertion failed!") {
441
325
  if (!expectedCondition) {
442
326
  console.error(message);
@@ -462,12 +346,12 @@ function $4a90471e7083b52f$export$d9fcbe062527d159({ committedValuesRef: committ
462
346
  let totalMaxSize = 0;
463
347
  // A panel's effective min/max sizes also need to account for other panel's sizes.
464
348
  panelsArray.forEach((panelData)=>{
465
- if (panelData.id === idBefore) {
466
- maxSize = panelData.maxSize;
467
- minSize = panelData.minSize;
349
+ if (panelData.current.id === idBefore) {
350
+ maxSize = panelData.current.maxSize;
351
+ minSize = panelData.current.minSize;
468
352
  } else {
469
- totalMinSize += panelData.minSize;
470
- totalMaxSize += panelData.maxSize;
353
+ totalMinSize += panelData.current.minSize;
354
+ totalMaxSize += panelData.current.maxSize;
471
355
  }
472
356
  });
473
357
  const ariaValueMax = Math.min(maxSize, 100 - totalMinSize);
@@ -482,13 +366,13 @@ function $4a90471e7083b52f$export$d9fcbe062527d159({ committedValuesRef: committ
482
366
  case "Enter":
483
367
  {
484
368
  event.preventDefault();
485
- const index = panelsArray.findIndex((panel)=>panel.id === idBefore);
369
+ const index = panelsArray.findIndex((panel)=>panel.current.id === idBefore);
486
370
  if (index >= 0) {
487
371
  const panelData = panelsArray[index];
488
372
  const size = sizes[index];
489
373
  if (size != null) {
490
374
  let delta = 0;
491
- if (size.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)) <= panelData.minSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
375
+ if (size.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)) <= panelData.current.minSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
492
376
  else delta = -(direction === "horizontal" ? width : height);
493
377
  const nextSizes = (0, $d6f7e4c3aa9e02d7$export$f50bae335f53943c)(event, panels, idBefore, idAfter, delta, sizes, panelSizeBeforeCollapse.current, null);
494
378
  if (sizes !== nextSizes) setSizes(nextSizes);
@@ -563,6 +447,91 @@ function $4a90471e7083b52f$export$33b0bea6ac3ffb03({ disabled: disabled , handle
563
447
  }
564
448
 
565
449
 
450
+
451
+ function $c892f0f705e6ded5$export$b141efd0b0fb9174(arrayA, arrayB) {
452
+ if (arrayA.length !== arrayB.length) return false;
453
+ for(let index = 0; index < arrayA.length; index++){
454
+ if (arrayA[index] !== arrayB[index]) return false;
455
+ }
456
+ return true;
457
+ }
458
+
459
+
460
+
461
+
462
+
463
+ function $8f51c2d77bf1da88$export$ec391ce65b083ed4(event, handleId, direction, initialOffset = 0, initialHandleElementRect = null) {
464
+ const isHorizontal = direction === "horizontal";
465
+ let pointerOffset = 0;
466
+ if ($8f51c2d77bf1da88$export$764db16956f554f8(event)) pointerOffset = isHorizontal ? event.clientX : event.clientY;
467
+ else if ($8f51c2d77bf1da88$export$c4dfce035d43d1e0(event)) {
468
+ const firstTouch = event.touches[0];
469
+ pointerOffset = isHorizontal ? firstTouch.screenX : firstTouch.screenY;
470
+ } else return 0;
471
+ const handleElement = (0, $d6f7e4c3aa9e02d7$export$2e27d3a347680388)(handleId);
472
+ const rect = initialHandleElementRect || handleElement.getBoundingClientRect();
473
+ const elementOffset = isHorizontal ? rect.left : rect.top;
474
+ return pointerOffset - elementOffset - initialOffset;
475
+ }
476
+ function $8f51c2d77bf1da88$export$354b17c0684607ed(event, groupId, handleId, panelsArray, direction, prevSizes, initialDragState) {
477
+ const { dragOffset: dragOffset = 0 , dragHandleRect: dragHandleRect , sizes: initialSizes } = initialDragState || {};
478
+ // If we're resizing by mouse or touch, use the initial sizes as a base.
479
+ // This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
480
+ const baseSizes = initialSizes || prevSizes;
481
+ if ($8f51c2d77bf1da88$export$e7bf60a870f429b0(event)) {
482
+ const isHorizontal = direction === "horizontal";
483
+ const groupElement = (0, $d6f7e4c3aa9e02d7$export$5e67632cf3550a9c)(groupId);
484
+ const rect = groupElement.getBoundingClientRect();
485
+ const groupSizeInPixels = isHorizontal ? rect.width : rect.height;
486
+ const denominator = event.shiftKey ? 10 : 100;
487
+ const delta = groupSizeInPixels / denominator;
488
+ let movement = 0;
489
+ switch(event.key){
490
+ case "ArrowDown":
491
+ movement = isHorizontal ? 0 : delta;
492
+ break;
493
+ case "ArrowLeft":
494
+ movement = isHorizontal ? -delta : 0;
495
+ break;
496
+ case "ArrowRight":
497
+ movement = isHorizontal ? delta : 0;
498
+ break;
499
+ case "ArrowUp":
500
+ movement = isHorizontal ? 0 : -delta;
501
+ break;
502
+ case "End":
503
+ movement = groupSizeInPixels;
504
+ break;
505
+ case "Home":
506
+ movement = -groupSizeInPixels;
507
+ break;
508
+ }
509
+ // If the Panel being resized is collapsible,
510
+ // we need to special case resizing around the minSize boundary.
511
+ // If contracting, Panels should shrink to their minSize and then snap to fully collapsed.
512
+ // If expanding from collapsed, they should snap back to their minSize.
513
+ const [idBefore, idAfter] = (0, $d6f7e4c3aa9e02d7$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
514
+ const targetPanelId = movement < 0 ? idBefore : idAfter;
515
+ const targetPanelIndex = panelsArray.findIndex((panel)=>panel.current.id === targetPanelId);
516
+ const targetPanel = panelsArray[targetPanelIndex];
517
+ if (targetPanel.current.collapsible) {
518
+ const baseSize = baseSizes[targetPanelIndex];
519
+ if (baseSize === 0 || baseSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)) === targetPanel.current.minSize.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879))) movement = movement < 0 ? -targetPanel.current.minSize * groupSizeInPixels : targetPanel.current.minSize * groupSizeInPixels;
520
+ }
521
+ return movement;
522
+ } else return $8f51c2d77bf1da88$export$ec391ce65b083ed4(event, handleId, direction, dragOffset, dragHandleRect);
523
+ }
524
+ function $8f51c2d77bf1da88$export$e7bf60a870f429b0(event) {
525
+ return event.type === "keydown";
526
+ }
527
+ function $8f51c2d77bf1da88$export$764db16956f554f8(event) {
528
+ return event.type.startsWith("mouse");
529
+ }
530
+ function $8f51c2d77bf1da88$export$c4dfce035d43d1e0(event) {
531
+ return event.type.startsWith("touch");
532
+ }
533
+
534
+
566
535
  let $8d9d88bebf1a8ace$var$currentState = null;
567
536
  let $8d9d88bebf1a8ace$var$element = null;
568
537
  function $8d9d88bebf1a8ace$export$fa35f3322c52262f(state) {
@@ -612,18 +581,49 @@ function $f7d932e9304c1581$export$2e2bcd8739ae039(callback, durationMs = 10) {
612
581
  }
613
582
 
614
583
 
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;
584
+
585
+ // Note that Panel ids might be user-provided (stable) or useId generated (non-deterministic)
586
+ // so they should not be used as part of the serialization key.
587
+ // Using an attribute like minSize instead should work well enough.
588
+ // Pre-sorting by minSize allows remembering layouts even if panels are re-ordered/dragged.
589
+ function $6889c3a3ed41cfd1$var$getSerializationKey(panels) {
590
+ return panels.map((panel)=>{
591
+ const { minSize: minSize , order: order } = panel.current;
592
+ return order ? `${order}:${minSize}` : `${minSize}`;
593
+ }).sort((a, b)=>a.localeCompare(b)).join(",");
594
+ }
595
+ function $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage) {
596
+ try {
597
+ const serialized = storage.getItem(`PanelGroup:sizes:${autoSaveId}`);
598
+ if (serialized) {
599
+ const parsed = JSON.parse(serialized);
600
+ if (typeof parsed === "object" && parsed != null) return parsed;
601
+ }
602
+ } catch (error) {}
603
+ return null;
604
+ }
605
+ function $6889c3a3ed41cfd1$export$9c80c6617f0386da(autoSaveId, panels, storage) {
606
+ const state = $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage);
607
+ if (state) {
608
+ const key = $6889c3a3ed41cfd1$var$getSerializationKey(panels);
609
+ var _state_key;
610
+ return (_state_key = state[key]) !== null && _state_key !== void 0 ? _state_key : null;
611
+ }
612
+ return null;
613
+ }
614
+ function $6889c3a3ed41cfd1$export$af183b313c61be4f(autoSaveId, panels, sizes, storage) {
615
+ const key = $6889c3a3ed41cfd1$var$getSerializationKey(panels);
616
+ const state = $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage) || {};
617
+ state[key] = sizes;
618
+ try {
619
+ storage.setItem(`PanelGroup:sizes:${autoSaveId}`, JSON.stringify(state));
620
+ } catch (error) {
621
+ console.error(error);
619
622
  }
620
- return true;
621
623
  }
622
624
 
623
625
 
624
-
625
- // Limit the frequency of localStorage updates.
626
- const $3daa5d4c086ea816$var$savePanelGroupLayoutDebounced = (0, $f7d932e9304c1581$export$2e2bcd8739ae039)((0, $6889c3a3ed41cfd1$export$af183b313c61be4f), 100);
626
+ const $3daa5d4c086ea816$var$debounceMap = {};
627
627
  function $3daa5d4c086ea816$var$throwServerError() {
628
628
  throw new Error('PanelGroup "storage" prop required for server rendering.');
629
629
  }
@@ -658,6 +658,10 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
658
658
  sizes: sizes
659
659
  });
660
660
  (0, $ef07efbe5fa7d87e$export$d5a552a76deda3c2)(forwardedRef, ()=>({
661
+ getLayout: ()=>{
662
+ const { sizes: sizes } = committedValuesRef.current;
663
+ return sizes;
664
+ },
661
665
  setLayout: (sizes)=>{
662
666
  const total = sizes.reduce((accumulated, current)=>accumulated + current, 0);
663
667
  (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(total === 100, "Panel sizes must add up to 100%");
@@ -727,15 +731,15 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
727
731
  // 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.
728
732
  // For now, these logic edge cases are left to the user to handle via props.
729
733
  panelsArray.forEach((panel)=>{
730
- totalMinSize += panel.minSize;
731
- if (panel.defaultSize === null) panelsWithNullDefaultSize++;
732
- else totalDefaultSize += panel.defaultSize;
734
+ totalMinSize += panel.current.minSize;
735
+ if (panel.current.defaultSize === null) panelsWithNullDefaultSize++;
736
+ else totalDefaultSize += panel.current.defaultSize;
733
737
  });
734
738
  if (totalDefaultSize > 100) throw new Error(`The sum of the defaultSize of all panels in a group cannot exceed 100.`);
735
739
  else if (totalMinSize > 100) throw new Error(`The sum of the minSize of all panels in a group cannot exceed 100.`);
736
740
  setSizes(panelsArray.map((panel)=>{
737
- if (panel.defaultSize === null) return (100 - totalDefaultSize) / panelsWithNullDefaultSize;
738
- return panel.defaultSize;
741
+ if (panel.current.defaultSize === null) return (100 - totalDefaultSize) / panelsWithNullDefaultSize;
742
+ return panel.current.defaultSize;
739
743
  }));
740
744
  }
741
745
  }, [
@@ -748,7 +752,9 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
748
752
  if (autoSaveId) {
749
753
  if (sizes.length === 0 || sizes.length !== panels.size) return;
750
754
  const panelsArray = (0, $d6f7e4c3aa9e02d7$export$a861c0ad45885494)(panels);
751
- $3daa5d4c086ea816$var$savePanelGroupLayoutDebounced(autoSaveId, panelsArray, sizes, storage);
755
+ // Limit the frequency of localStorage updates.
756
+ if (!$3daa5d4c086ea816$var$debounceMap[autoSaveId]) $3daa5d4c086ea816$var$debounceMap[autoSaveId] = (0, $f7d932e9304c1581$export$2e2bcd8739ae039)((0, $6889c3a3ed41cfd1$export$af183b313c61be4f), 100);
757
+ $3daa5d4c086ea816$var$debounceMap[autoSaveId](autoSaveId, panelsArray, sizes, storage);
752
758
  }
753
759
  }, [
754
760
  autoSaveId,
@@ -784,11 +790,11 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
784
790
  disablePointerEventsDuringResize,
785
791
  sizes
786
792
  ]);
787
- const registerPanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id, panel)=>{
793
+ const registerPanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id, panelRef)=>{
788
794
  setPanels((prevPanels)=>{
789
795
  if (prevPanels.has(id)) return prevPanels;
790
796
  const nextPanels = new Map(prevPanels);
791
- nextPanels.set(id, panel);
797
+ nextPanels.set(id, panelRef);
792
798
  return nextPanels;
793
799
  });
794
800
  }, []);
@@ -846,7 +852,7 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
846
852
  const collapsePanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id)=>{
847
853
  const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
848
854
  const panel = panels.get(id);
849
- if (panel == null || !panel.collapsible) return;
855
+ if (panel == null || !panel.current.collapsible) return;
850
856
  const panelsArray = (0, $d6f7e4c3aa9e02d7$export$a861c0ad45885494)(panels);
851
857
  const index = panelsArray.indexOf(panel);
852
858
  if (index < 0) return;
@@ -869,7 +875,7 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
869
875
  const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
870
876
  const panel = panels.get(id);
871
877
  if (panel == null) return;
872
- const sizeBeforeCollapse = panelSizeBeforeCollapse.current.get(id) || panel.minSize;
878
+ const sizeBeforeCollapse = panelSizeBeforeCollapse.current.get(id) || panel.current.minSize;
873
879
  if (!sizeBeforeCollapse) return;
874
880
  const panelsArray = (0, $d6f7e4c3aa9e02d7$export$a861c0ad45885494)(panels);
875
881
  const index = panelsArray.indexOf(panel);
@@ -897,8 +903,8 @@ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSave
897
903
  if (index < 0) return;
898
904
  const currentSize = prevSizes[index];
899
905
  if (currentSize === nextSize) return;
900
- if (panel.collapsible && nextSize === 0) ;
901
- else nextSize = Math.min(panel.maxSize, Math.max(panel.minSize, nextSize));
906
+ if (panel.current.collapsible && nextSize === 0) ;
907
+ else nextSize = Math.min(panel.current.maxSize, Math.max(panel.current.minSize, nextSize));
902
908
  const [idBefore, idAfter] = (0, $d6f7e4c3aa9e02d7$export$5a5b0c1d38c23c3b)(id, panelsArray);
903
909
  if (idBefore == null || idAfter == null) return;
904
910
  const isLastPanel = index === panelsArray.length - 1;