react-resizable-panels 4.0.14 → 4.0.16

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.
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import { jsx as K } from "react/jsx-runtime";
3
- import { useId as Ke, useLayoutEffect as Xe, useEffect as Re, useRef as D, useCallback as qe, createContext as Ye, useImperativeHandle as Ee, useState as k, useMemo as ie, useSyncExternalStore as Ze, useContext as Je } from "react";
3
+ import { useId as Ke, useLayoutEffect as Xe, useEffect as Ce, useRef as D, useCallback as qe, createContext as Ye, useImperativeHandle as Ee, useState as I, useMemo as ie, useSyncExternalStore as Ze, useContext as Je } from "react";
4
4
  function z(e, t = "Assertion error") {
5
5
  if (!e)
6
6
  throw Error(t);
7
7
  }
8
- function W({
8
+ function V({
9
9
  group: e
10
10
  }) {
11
11
  const { orientation: t, panels: n } = e;
@@ -27,7 +27,7 @@ function et(e, t) {
27
27
  function Me(e) {
28
28
  return e !== null && typeof e == "object" && "nodeType" in e && e.nodeType === Node.ELEMENT_NODE;
29
29
  }
30
- function ke(e, t) {
30
+ function Ie(e, t) {
31
31
  return {
32
32
  x: e.x >= t.left && e.x <= t.right ? 0 : Math.min(
33
33
  Math.abs(e.x - t.left),
@@ -50,12 +50,12 @@ function tt({
50
50
  };
51
51
  let i, s = Number.MAX_VALUE;
52
52
  for (const l of t) {
53
- const { x: r, y: a } = ke(o, l), u = e === "horizontal" ? r : a;
53
+ const { x: r, y: a } = Ie(o, l), u = e === "horizontal" ? r : a;
54
54
  u < s && (s = u, i = l);
55
55
  }
56
56
  return z(i, "No rect found"), i;
57
57
  }
58
- function Ie(e) {
58
+ function ke(e) {
59
59
  const { element: t, orientation: n, panels: o, separators: i } = e, s = se(
60
60
  n,
61
61
  Array.from(t.children).filter(Me).map((f) => ({ element: f }))
@@ -64,19 +64,19 @@ function Ie(e) {
64
64
  for (const f of s)
65
65
  if (f.hasAttribute("data-panel")) {
66
66
  const p = o.find(
67
- (m) => m.element === f
67
+ (h) => h.element === f
68
68
  );
69
69
  if (p) {
70
70
  if (a) {
71
- const m = a.element.getBoundingClientRect(), h = f.getBoundingClientRect();
71
+ const h = a.element.getBoundingClientRect(), m = f.getBoundingClientRect();
72
72
  let c;
73
73
  if (r) {
74
- const d = n === "horizontal" ? new DOMRect(m.right, m.top, 0, m.height) : new DOMRect(
75
- m.left,
76
- m.bottom,
77
- m.width,
74
+ const d = n === "horizontal" ? new DOMRect(h.right, h.top, 0, h.height) : new DOMRect(
75
+ h.left,
76
+ h.bottom,
77
+ h.width,
78
78
  0
79
- ), y = n === "horizontal" ? new DOMRect(h.left, h.top, 0, h.height) : new DOMRect(h.left, h.top, h.width, 0);
79
+ ), y = n === "horizontal" ? new DOMRect(m.left, m.top, 0, m.height) : new DOMRect(m.left, m.top, m.width, 0);
80
80
  switch (u.length) {
81
81
  case 0: {
82
82
  c = [
@@ -88,12 +88,12 @@ function Ie(e) {
88
88
  case 1: {
89
89
  const v = u[0], S = tt({
90
90
  orientation: n,
91
- rects: [m, h],
91
+ rects: [h, m],
92
92
  targetRect: v.element.getBoundingClientRect()
93
93
  });
94
94
  c = [
95
95
  v,
96
- S === m ? y : d
96
+ S === h ? y : d
97
97
  ];
98
98
  break;
99
99
  }
@@ -105,21 +105,21 @@ function Ie(e) {
105
105
  } else
106
106
  u.length ? c = u : c = [
107
107
  n === "horizontal" ? new DOMRect(
108
- m.right,
109
- h.top,
110
- h.left - m.right,
111
- h.height
108
+ h.right,
109
+ m.top,
110
+ m.left - h.right,
111
+ m.height
112
112
  ) : new DOMRect(
113
- h.left,
114
- m.bottom,
115
- h.width,
116
- h.top - m.bottom
113
+ m.left,
114
+ h.bottom,
115
+ m.width,
116
+ m.top - h.bottom
117
117
  )
118
118
  ];
119
119
  for (const d of c)
120
120
  l.push({
121
121
  group: e,
122
- groupSize: W({ group: e }),
122
+ groupSize: V({ group: e }),
123
123
  panels: [a, p],
124
124
  separator: "width" in d ? void 0 : d,
125
125
  rect: "width" in d ? d : d.element.getBoundingClientRect()
@@ -129,7 +129,7 @@ function Ie(e) {
129
129
  }
130
130
  } else if (f.hasAttribute("data-separator")) {
131
131
  const p = i.find(
132
- (m) => m.element === f
132
+ (h) => h.element === f
133
133
  );
134
134
  p ? u.push(p) : (a = void 0, u = []);
135
135
  } else
@@ -195,11 +195,11 @@ function te({
195
195
  }
196
196
  return o;
197
197
  }
198
- function I(e) {
198
+ function k(e) {
199
199
  return parseFloat(e.toFixed(3));
200
200
  }
201
201
  function me(e) {
202
- const { panels: t } = e, n = W({ group: e });
202
+ const { panels: t } = e, n = V({ group: e });
203
203
  return n === 0 ? t.map((o) => ({
204
204
  collapsedSize: 0,
205
205
  collapsible: o.panelConstraints.collapsible === !0,
@@ -216,7 +216,7 @@ function me(e) {
216
216
  panelElement: i,
217
217
  styleProp: s.collapsedSize
218
218
  });
219
- l = I(f / n * 100);
219
+ l = k(f / n * 100);
220
220
  }
221
221
  let r;
222
222
  if (s.defaultSize) {
@@ -225,7 +225,7 @@ function me(e) {
225
225
  panelElement: i,
226
226
  styleProp: s.defaultSize
227
227
  });
228
- r = I(f / n * 100);
228
+ r = k(f / n * 100);
229
229
  }
230
230
  let a = 0;
231
231
  if (s.minSize) {
@@ -234,7 +234,7 @@ function me(e) {
234
234
  panelElement: i,
235
235
  styleProp: s.minSize
236
236
  });
237
- a = I(f / n * 100);
237
+ a = k(f / n * 100);
238
238
  }
239
239
  let u = 100;
240
240
  if (s.maxSize) {
@@ -243,7 +243,7 @@ function me(e) {
243
243
  panelElement: i,
244
244
  styleProp: s.maxSize
245
245
  });
246
- u = I(f / n * 100);
246
+ u = k(f / n * 100);
247
247
  }
248
248
  return {
249
249
  collapsedSize: l,
@@ -294,37 +294,37 @@ class at {
294
294
  }
295
295
  }
296
296
  }
297
- function C(e, t, n = 0) {
298
- return Math.abs(I(e) - I(t)) <= n;
297
+ function R(e, t, n = 0) {
298
+ return Math.abs(k(e) - k(t)) <= n;
299
299
  }
300
- let R = {
300
+ let C = {
301
301
  cursorFlags: 0,
302
302
  interactionState: {
303
303
  state: "inactive"
304
304
  },
305
305
  mountedGroups: /* @__PURE__ */ new Map()
306
306
  };
307
- const T = new at();
307
+ const O = new at();
308
308
  function G() {
309
- return R;
309
+ return C;
310
310
  }
311
311
  function E(e) {
312
- const t = typeof e == "function" ? e(R) : e;
313
- if (R === t)
314
- return R;
315
- const n = R;
316
- return R = {
317
- ...R,
312
+ const t = typeof e == "function" ? e(C) : e;
313
+ if (C === t)
314
+ return C;
315
+ const n = C;
316
+ return C = {
317
+ ...C,
318
318
  ...t
319
- }, t.cursorFlags !== void 0 && T.emit("cursorFlagsChange", R.cursorFlags), t.interactionState !== void 0 && T.emit("interactionStateChange", R.interactionState), t.mountedGroups !== void 0 && (R.mountedGroups.forEach((o, i) => {
319
+ }, t.cursorFlags !== void 0 && O.emit("cursorFlagsChange", C.cursorFlags), t.interactionState !== void 0 && O.emit("interactionStateChange", C.interactionState), t.mountedGroups !== void 0 && (C.mountedGroups.forEach((o, i) => {
320
320
  o.derivedPanelConstraints.forEach((s) => {
321
321
  if (s.collapsible) {
322
322
  const { layout: l } = n.mountedGroups.get(i) ?? {};
323
323
  if (l) {
324
- const r = C(
324
+ const r = R(
325
325
  s.collapsedSize,
326
326
  o.layout[s.panelId]
327
- ), a = C(
327
+ ), a = R(
328
328
  s.collapsedSize,
329
329
  l[s.panelId]
330
330
  );
@@ -332,7 +332,7 @@ function E(e) {
332
332
  }
333
333
  }
334
334
  });
335
- }), T.emit("mountedGroupsChange", R.mountedGroups)), R;
335
+ }), O.emit("mountedGroupsChange", C.mountedGroups)), C;
336
336
  }
337
337
  function lt(e, t) {
338
338
  if (e.length !== t.length)
@@ -343,7 +343,7 @@ function lt(e, t) {
343
343
  return !0;
344
344
  }
345
345
  function X(e, t) {
346
- return C(e, t) ? 0 : e > t ? 1 : -1;
346
+ return R(e, t) ? 0 : e > t ? 1 : -1;
347
347
  }
348
348
  function B({
349
349
  panelConstraints: e,
@@ -361,7 +361,7 @@ function B({
361
361
  X(t, l) < 0 ? t = n : t = s;
362
362
  } else
363
363
  t = s;
364
- return t = Math.min(i, t), t = I(t), t;
364
+ return t = Math.min(i, t), t = k(t), t;
365
365
  }
366
366
  function q({
367
367
  delta: e,
@@ -371,7 +371,7 @@ function q({
371
371
  prevLayout: i,
372
372
  trigger: s
373
373
  }) {
374
- if (C(e, 0))
374
+ if (R(e, 0))
375
375
  return t;
376
376
  const l = Object.values(t), r = Object.values(i), a = [...l], [u, f] = o;
377
377
  z(u != null, "Invalid first pivot index"), z(f != null, "Invalid second pivot index");
@@ -393,7 +393,7 @@ function q({
393
393
  if (z(
394
394
  x != null,
395
395
  `Previous layout not found for panel index ${c}`
396
- ), C(x, y)) {
396
+ ), R(x, y)) {
397
397
  const g = S - x;
398
398
  X(g, Math.abs(e)) > 0 && (e = e < 0 ? 0 - g : g);
399
399
  }
@@ -415,7 +415,7 @@ function q({
415
415
  if (z(
416
416
  x != null,
417
417
  `Previous layout not found for panel index ${c}`
418
- ), C(x, S)) {
418
+ ), R(x, S)) {
419
419
  const g = x - y;
420
420
  X(g, Math.abs(e)) > 0 && (e = e < 0 ? 0 - g : g);
421
421
  }
@@ -453,7 +453,7 @@ function q({
453
453
  panelConstraints: n[d],
454
454
  size: S
455
455
  });
456
- if (!C(v, x) && (p += v - x, a[d] = x, p.toFixed(3).localeCompare(Math.abs(e).toFixed(3), void 0, {
456
+ if (!R(v, x) && (p += v - x, a[d] = x, p.toFixed(3).localeCompare(Math.abs(e).toFixed(3), void 0, {
457
457
  numeric: !0
458
458
  }) >= 0))
459
459
  break;
@@ -472,7 +472,7 @@ function q({
472
472
  panelConstraints: n[c],
473
473
  size: y
474
474
  });
475
- if (a[c] = v, !C(v, y)) {
475
+ if (a[c] = v, !R(v, y)) {
476
476
  let S = y - v, g = e < 0 ? f : u;
477
477
  for (; g >= 0 && g < n.length; ) {
478
478
  const w = a[g];
@@ -484,20 +484,20 @@ function q({
484
484
  panelConstraints: n[g],
485
485
  size: L
486
486
  });
487
- if (C(w, P) || (S -= P - w, a[g] = P), C(S, 0))
487
+ if (R(w, P) || (S -= P - w, a[g] = P), R(S, 0))
488
488
  break;
489
489
  e > 0 ? g-- : g++;
490
490
  }
491
491
  }
492
492
  }
493
- const m = Object.values(a).reduce(
493
+ const h = Object.values(a).reduce(
494
494
  (c, d) => d + c,
495
495
  0
496
496
  );
497
- if (!C(m, 100, 0.1))
497
+ if (!R(h, 100, 0.1))
498
498
  return i;
499
- const h = Object.keys(i);
500
- return a.reduce((c, d, y) => (c[h[y]] = d, c), {});
499
+ const m = Object.keys(i);
500
+ return a.reduce((c, d, y) => (c[m[y]] = d, c), {});
501
501
  }
502
502
  function oe(e) {
503
503
  const t = e.parentElement;
@@ -508,7 +508,7 @@ function oe(e) {
508
508
  return o;
509
509
  throw Error("Could not find parent Group for separator element");
510
510
  }
511
- function V(e, t) {
511
+ function W(e, t) {
512
512
  if (Object.keys(e).length !== Object.keys(t).length)
513
513
  return !1;
514
514
  for (const n in e)
@@ -528,7 +528,7 @@ function _({
528
528
  throw Error(
529
529
  `Invalid ${t.length} panel layout: ${o.map((r) => `${r}%`).join(", ")}`
530
530
  );
531
- if (!C(i, 100) && o.length > 0)
531
+ if (!R(i, 100) && o.length > 0)
532
532
  for (let r = 0; r < t.length; r++) {
533
533
  const a = o[r];
534
534
  z(a != null, `No layout data found for index ${r}`);
@@ -545,7 +545,7 @@ function _({
545
545
  });
546
546
  a != u && (s += a - u, o[r] = u);
547
547
  }
548
- if (!C(s, 0))
548
+ if (!R(s, 0))
549
549
  for (let r = 0; r < t.length; r++) {
550
550
  const a = o[r];
551
551
  z(a != null, `No layout data found for index ${r}`);
@@ -553,7 +553,7 @@ function _({
553
553
  panelConstraints: t[r],
554
554
  size: u
555
555
  });
556
- if (a !== f && (s -= f - a, o[r] = f, C(s, 0)))
556
+ if (a !== f && (s -= f - a, o[r] = f, R(s, 0)))
557
557
  break;
558
558
  }
559
559
  const l = Object.keys(e);
@@ -585,7 +585,7 @@ function Ge({
585
585
  layout: n,
586
586
  panelConstraints: i
587
587
  });
588
- return o ? l : (V(l, a) || E((u) => ({
588
+ return o ? l : (W(l, a) || E((u) => ({
589
589
  mountedGroups: new Map(u.mountedGroups).set(s, {
590
590
  defaultLayoutDeferred: o,
591
591
  derivedPanelConstraints: i,
@@ -600,7 +600,7 @@ function De(e) {
600
600
  const { mountedGroups: t } = G(), n = t.get(e);
601
601
  return z(n, `Mounted Group ${e.id} not found`), n;
602
602
  }
603
- function O(e, t) {
603
+ function T(e, t) {
604
604
  const n = oe(e), o = De(n), i = n.separators.find(
605
605
  (p) => p.element === e
606
606
  );
@@ -618,7 +618,7 @@ function O(e, t) {
618
618
  layout: u,
619
619
  panelConstraints: o.derivedPanelConstraints
620
620
  });
621
- V(a, f) || E((p) => ({
621
+ W(a, f) || E((p) => ({
622
622
  mountedGroups: new Map(p.mountedGroups).set(n, {
623
623
  defaultLayoutDeferred: o.defaultLayoutDeferred,
624
624
  derivedPanelConstraints: o.derivedPanelConstraints,
@@ -634,23 +634,23 @@ function ye(e) {
634
634
  if (!n.disabled)
635
635
  switch (e.key) {
636
636
  case "ArrowDown": {
637
- e.preventDefault(), n.orientation === "vertical" && O(t, 5);
637
+ e.preventDefault(), n.orientation === "vertical" && T(t, 5);
638
638
  break;
639
639
  }
640
640
  case "ArrowLeft": {
641
- e.preventDefault(), n.orientation === "horizontal" && O(t, -5);
641
+ e.preventDefault(), n.orientation === "horizontal" && T(t, -5);
642
642
  break;
643
643
  }
644
644
  case "ArrowRight": {
645
- e.preventDefault(), n.orientation === "horizontal" && O(t, 5);
645
+ e.preventDefault(), n.orientation === "horizontal" && T(t, 5);
646
646
  break;
647
647
  }
648
648
  case "ArrowUp": {
649
- e.preventDefault(), n.orientation === "vertical" && O(t, -5);
649
+ e.preventDefault(), n.orientation === "vertical" && T(t, -5);
650
650
  break;
651
651
  }
652
652
  case "End": {
653
- e.preventDefault(), O(t, 100);
653
+ e.preventDefault(), T(t, 100);
654
654
  break;
655
655
  }
656
656
  case "Enter": {
@@ -665,8 +665,8 @@ function ye(e) {
665
665
  (p) => p.panelId === u.id
666
666
  );
667
667
  if (z(f, "Panel metadata not found"), f.collapsible) {
668
- const p = s[u.id], m = f.collapsedSize === p ? o.inMemoryLastExpandedPanelSizes[u.id] ?? f.minSize : f.collapsedSize;
669
- O(t, m - p);
668
+ const p = s[u.id], h = f.collapsedSize === p ? o.inMemoryLastExpandedPanelSizes[u.id] ?? f.minSize : f.collapsedSize;
669
+ T(t, h - p);
670
670
  }
671
671
  break;
672
672
  }
@@ -683,13 +683,13 @@ function ye(e) {
683
683
  break;
684
684
  }
685
685
  case "Home": {
686
- e.preventDefault(), O(t, -100);
686
+ e.preventDefault(), T(t, -100);
687
687
  break;
688
688
  }
689
689
  }
690
690
  }
691
691
  const ut = (e) => e, re = () => {
692
- }, Oe = 1, Te = 2, _e = 4, Ne = 8, ge = {
692
+ }, Te = 1, Oe = 2, _e = 4, Ne = 8, ge = {
693
693
  coarse: 10,
694
694
  precise: 5
695
695
  };
@@ -699,7 +699,7 @@ function ct(e, t, n) {
699
699
  y: 1 / 0
700
700
  };
701
701
  for (const s of t) {
702
- const l = ke(n, s.rect);
702
+ const l = Ie(n, s.rect);
703
703
  switch (e) {
704
704
  case "horizontal": {
705
705
  l.x <= i.x && (o = s, i = l);
@@ -811,7 +811,7 @@ function $e(e, t) {
811
811
  return t.forEach((o, i) => {
812
812
  if (i.disabled)
813
813
  return;
814
- const s = ft() ? ge.coarse : ge.precise, l = Ie(i), r = ct(i.orientation, l, {
814
+ const s = ft() ? ge.coarse : ge.precise, l = ke(i), r = ct(i.orientation, l, {
815
815
  x: e.clientX,
816
816
  y: e.clientY
817
817
  });
@@ -869,7 +869,7 @@ function St({
869
869
  return null;
870
870
  switch (n) {
871
871
  case "active": {
872
- const s = (e & Oe) !== 0, l = (e & Te) !== 0, r = (e & _e) !== 0, a = (e & Ne) !== 0;
872
+ const s = (e & Te) !== 0, l = (e & Oe) !== 0, r = (e & _e) !== 0, a = (e & Ne) !== 0;
873
873
  if (e) {
874
874
  if (s)
875
875
  return r ? "se-resize" : a ? "ne-resize" : "e-resize";
@@ -887,7 +887,7 @@ function St({
887
887
  }
888
888
  const be = /* @__PURE__ */ new WeakMap();
889
889
  function ae(e) {
890
- if (e.defaultView === null)
890
+ if (e.defaultView === null || e.defaultView === void 0)
891
891
  return;
892
892
  let { prevStyle: t, styleSheet: n } = be.get(e) ?? {};
893
893
  n === void 0 && (n = new e.defaultView.CSSStyleSheet(), e.adoptedStyleSheets = [n]);
@@ -926,9 +926,9 @@ function Fe({
926
926
  let l = 0;
927
927
  const r = new Map(i);
928
928
  n.forEach((a) => {
929
- const { group: u, groupSize: f } = a, { disableCursor: p, orientation: m, panels: h } = u;
929
+ const { group: u, groupSize: f } = a, { disableCursor: p, orientation: h, panels: m } = u;
930
930
  let c = 0;
931
- s ? m === "horizontal" ? c = (t.clientX - s.x) / f * 100 : c = (t.clientY - s.y) / f * 100 : m === "horizontal" ? c = t.clientX < 0 ? -100 : 100 : c = t.clientY < 0 ? -100 : 100;
931
+ s ? h === "horizontal" ? c = (t.clientX - s.x) / f * 100 : c = (t.clientY - s.y) / f * 100 : h === "horizontal" ? c = t.clientX < 0 ? -100 : 100 : c = t.clientY < 0 ? -100 : 100;
932
932
  const d = o.get(u), {
933
933
  defaultLayoutDeferred: y,
934
934
  derivedPanelConstraints: v,
@@ -940,15 +940,15 @@ function Fe({
940
940
  delta: c,
941
941
  initialLayout: d,
942
942
  panelConstraints: v,
943
- pivotIndices: a.panels.map((w) => h.indexOf(w)),
943
+ pivotIndices: a.panels.map((w) => m.indexOf(w)),
944
944
  prevLayout: S,
945
945
  trigger: "mouse-or-touch"
946
946
  });
947
- if (V(g, S)) {
947
+ if (W(g, S)) {
948
948
  if (c !== 0 && !p)
949
- switch (m) {
949
+ switch (h) {
950
950
  case "horizontal": {
951
- l |= c < 0 ? Oe : Te;
951
+ l |= c < 0 ? Te : Oe;
952
952
  break;
953
953
  }
954
954
  case "vertical": {
@@ -1044,19 +1044,19 @@ function Pe(e) {
1044
1044
  }), ae(e.currentTarget);
1045
1045
  }
1046
1046
  }
1047
- function Ce(e) {
1047
+ function Re(e) {
1048
1048
  let t = 0, n = 0;
1049
1049
  const o = {};
1050
1050
  for (const s of e)
1051
1051
  if (s.defaultSize !== void 0) {
1052
1052
  t++;
1053
- const l = I(s.defaultSize);
1053
+ const l = k(s.defaultSize);
1054
1054
  n += l, o[s.panelId] = l;
1055
1055
  } else
1056
1056
  o[s.panelId] = void 0;
1057
1057
  const i = e.length - t;
1058
1058
  if (i !== 0) {
1059
- const s = I((100 - n) / i);
1059
+ const s = k((100 - n) / i);
1060
1060
  for (const l of e)
1061
1061
  l.defaultSize === void 0 && (o[l.panelId] = s);
1062
1062
  }
@@ -1069,10 +1069,10 @@ function xt(e, t, n) {
1069
1069
  const i = e.panels.find((l) => l.element === t);
1070
1070
  if (!i || !i.onResize)
1071
1071
  return;
1072
- const s = W({ group: e });
1072
+ const s = V({ group: e });
1073
1073
  i.onResize(
1074
1074
  {
1075
- asPercentage: I(
1075
+ asPercentage: k(
1076
1076
  o.inlineSize / s * 100
1077
1077
  ),
1078
1078
  inPixels: o.inlineSize
@@ -1088,8 +1088,17 @@ function zt(e, t) {
1088
1088
  return !1;
1089
1089
  return !0;
1090
1090
  }
1091
+ function bt(e, t) {
1092
+ const n = e.map((i) => i.id), o = Object.keys(t);
1093
+ if (n.length !== o.length)
1094
+ return !1;
1095
+ for (const i of n)
1096
+ if (!o.includes(i))
1097
+ return !1;
1098
+ return !0;
1099
+ }
1091
1100
  const j = /* @__PURE__ */ new Map();
1092
- function bt(e) {
1101
+ function wt(e) {
1093
1102
  let t = !0;
1094
1103
  z(
1095
1104
  e.element.ownerDocument.defaultView,
@@ -1100,16 +1109,16 @@ function bt(e) {
1100
1109
  const { borderBoxSize: y, target: v } = d;
1101
1110
  if (v === e.element) {
1102
1111
  if (t) {
1103
- if (W({ group: e }) === 0)
1112
+ if (V({ group: e }) === 0)
1104
1113
  return;
1105
1114
  E((x) => {
1106
1115
  const g = x.mountedGroups.get(e);
1107
1116
  if (g) {
1108
- const w = me(e), L = g.defaultLayoutDeferred ? Ce(w) : g.layout, P = _({
1117
+ const w = me(e), L = g.defaultLayoutDeferred ? Re(w) : g.layout, P = _({
1109
1118
  layout: L,
1110
1119
  panelConstraints: w
1111
1120
  });
1112
- return !g.defaultLayoutDeferred && V(L, P) && zt(
1121
+ return !g.defaultLayoutDeferred && W(L, P) && zt(
1113
1122
  g.derivedPanelConstraints,
1114
1123
  w
1115
1124
  ) ? x : {
@@ -1134,19 +1143,19 @@ function bt(e) {
1134
1143
  `Panel ids must be unique; id "${c.id}" was used more than once`
1135
1144
  ), o.add(c.id), c.onResize && s.observe(c.element);
1136
1145
  });
1137
- const l = W({ group: e }), r = me(e), a = e.panels.map(({ id: c }) => c).join(",");
1146
+ const l = V({ group: e }), r = me(e), a = e.panels.map(({ id: c }) => c).join(",");
1138
1147
  let u = e.defaultLayout;
1139
- u && e.panels.length !== Object.keys(u).length && (u = void 0);
1140
- const f = e.inMemoryLayouts[a] ?? u ?? Ce(r), p = _({
1148
+ u && (bt(e.panels, u) || (u = void 0));
1149
+ const f = e.inMemoryLayouts[a] ?? u ?? Re(r), p = _({
1141
1150
  layout: f,
1142
1151
  panelConstraints: r
1143
- }), m = Ie(e), h = e.element.ownerDocument;
1152
+ }), h = ke(e), m = e.element.ownerDocument;
1144
1153
  return E((c) => {
1145
1154
  const d = /* @__PURE__ */ new Map();
1146
1155
  return j.set(
1147
- h,
1148
- (j.get(h) ?? 0) + 1
1149
- ), m.forEach((y) => {
1156
+ m,
1157
+ (j.get(m) ?? 0) + 1
1158
+ ), h.forEach((y) => {
1150
1159
  y.separator && d.set(y.separator, y.panels);
1151
1160
  }), {
1152
1161
  mountedGroups: new Map(c.mountedGroups).set(e, {
@@ -1161,23 +1170,23 @@ function bt(e) {
1161
1170
  !i.has(c.id),
1162
1171
  `Separator ids must be unique; id "${c.id}" was used more than once`
1163
1172
  ), i.add(c.id), c.element.addEventListener("keydown", ye);
1164
- }), j.get(h) === 1 && (h.addEventListener("pointerdown", ze), h.addEventListener("pointerleave", we), h.addEventListener("pointermove", Le), h.addEventListener("pointerup", Pe)), function() {
1173
+ }), j.get(m) === 1 && (m.addEventListener("pointerdown", ze), m.addEventListener("pointerleave", we), m.addEventListener("pointermove", Le), m.addEventListener("pointerup", Pe)), function() {
1165
1174
  t = !1, j.set(
1166
- h,
1167
- Math.max(0, (j.get(h) ?? 0) - 1)
1175
+ m,
1176
+ Math.max(0, (j.get(m) ?? 0) - 1)
1168
1177
  ), E((d) => {
1169
1178
  const y = new Map(d.mountedGroups);
1170
1179
  return y.delete(e), { mountedGroups: y };
1171
1180
  }), e.separators.forEach((d) => {
1172
1181
  d.element.removeEventListener("keydown", ye);
1173
- }), j.get(h) || (h.removeEventListener("pointerdown", ze), h.removeEventListener("pointerleave", we), h.removeEventListener("pointermove", Le), h.removeEventListener("pointerup", Pe)), s.disconnect();
1182
+ }), j.get(m) || (m.removeEventListener("pointerdown", ze), m.removeEventListener("pointerleave", we), m.removeEventListener("pointermove", Le), m.removeEventListener("pointerup", Pe)), s.disconnect();
1174
1183
  };
1175
1184
  }
1176
1185
  function le(e) {
1177
1186
  const t = Ke();
1178
1187
  return `${e ?? t}`;
1179
1188
  }
1180
- const N = typeof window < "u" ? Xe : Re;
1189
+ const N = typeof window < "u" ? Xe : Ce;
1181
1190
  function ue(e) {
1182
1191
  const t = D(e);
1183
1192
  return N(() => {
@@ -1201,7 +1210,7 @@ function ce(...e) {
1201
1210
  });
1202
1211
  });
1203
1212
  }
1204
- function wt(e) {
1213
+ function Lt(e) {
1205
1214
  const t = D({ ...e });
1206
1215
  return N(() => {
1207
1216
  for (const n in e)
@@ -1214,7 +1223,7 @@ function je(e, t) {
1214
1223
  return `--react-resizable-panels--${n}--${o}`;
1215
1224
  }
1216
1225
  const Be = Ye(null);
1217
- function Lt(e, t) {
1226
+ function Pt(e, t) {
1218
1227
  const n = D({
1219
1228
  getLayout: () => ({}),
1220
1229
  setLayout: ut
@@ -1240,13 +1249,13 @@ function Ot({
1240
1249
  style: f,
1241
1250
  ...p
1242
1251
  }) {
1243
- const m = D({}), h = ue((b) => {
1244
- V(m.current, b) || (m.current = b, a?.(b));
1245
- }), c = le(r), [d, y] = k(!1), [v, S] = k(null), [x, g] = k(n ?? {}), [w, L] = k([]), [P, Y] = k([]), Z = D({
1252
+ const h = D({}), m = ue((b) => {
1253
+ W(h.current, b) || (h.current = b, a?.(b));
1254
+ }), c = le(r), [d, y] = I(!1), [v, S] = I(null), [x, g] = I(n ?? {}), [w, L] = I([]), [P, Y] = I([]), Z = D({
1246
1255
  lastExpandedPanelSizes: {},
1247
1256
  layouts: {}
1248
1257
  }), J = ce(S, s);
1249
- Lt(c, l);
1258
+ Pt(c, l);
1250
1259
  const Q = ie(
1251
1260
  () => ({
1252
1261
  id: c,
@@ -1263,7 +1272,7 @@ function Ot({
1263
1272
  })
1264
1273
  }),
1265
1274
  [c, u]
1266
- ), A = wt({
1275
+ ), A = Lt({
1267
1276
  defaultLayout: n,
1268
1277
  disableCursor: o
1269
1278
  }), U = D(null);
@@ -1283,12 +1292,12 @@ function Ot({
1283
1292
  separators: P
1284
1293
  };
1285
1294
  U.current = b;
1286
- const M = bt(b), pe = G().mountedGroups.get(b);
1295
+ const M = wt(b), pe = G().mountedGroups.get(b);
1287
1296
  if (pe) {
1288
1297
  const { defaultLayoutDeferred: F, derivedPanelConstraints: H, layout: ee } = pe;
1289
- !F && H.length > 0 && (g(ee), h?.(ee));
1298
+ !F && H.length > 0 && (g(ee), m?.(ee));
1290
1299
  }
1291
- const We = T.addListener(
1300
+ const Ve = O.addListener(
1292
1301
  "interactionStateChange",
1293
1302
  (F) => {
1294
1303
  switch (F.state) {
@@ -1306,7 +1315,7 @@ function Ot({
1306
1315
  }
1307
1316
  }
1308
1317
  }
1309
- ), Ve = T.addListener(
1318
+ ), We = O.addListener(
1310
1319
  "mountedGroupsChange",
1311
1320
  (F) => {
1312
1321
  const H = F.get(b);
@@ -1314,23 +1323,23 @@ function Ot({
1314
1323
  const { defaultLayoutDeferred: ee, derivedPanelConstraints: Ue, layout: he } = H;
1315
1324
  if (ee || Ue.length === 0)
1316
1325
  return;
1317
- g(he), h?.(he);
1326
+ g(he), m?.(he);
1318
1327
  }
1319
1328
  }
1320
1329
  );
1321
1330
  return () => {
1322
- U.current = null, M(), We(), Ve();
1331
+ U.current = null, M(), Ve(), We();
1323
1332
  };
1324
1333
  }, [
1325
1334
  i,
1326
1335
  v,
1327
1336
  c,
1328
- h,
1337
+ m,
1329
1338
  u,
1330
1339
  w,
1331
1340
  P,
1332
1341
  A
1333
- ]), Re(() => {
1342
+ ]), Ce(() => {
1334
1343
  const b = U.current;
1335
1344
  b && (b.defaultLayout = n, b.disableCursor = !!o);
1336
1345
  });
@@ -1362,7 +1371,7 @@ function Ot({
1362
1371
  }
1363
1372
  ) });
1364
1373
  }
1365
- function Pt(e, t = 10) {
1374
+ function Rt(e, t = 10) {
1366
1375
  let n = null;
1367
1376
  return (o) => {
1368
1377
  n !== null && clearTimeout(n), n = setTimeout(() => {
@@ -1373,13 +1382,13 @@ function Pt(e, t = 10) {
1373
1382
  function Ct(e) {
1374
1383
  return `react-resizable-panels:${e}`;
1375
1384
  }
1376
- function Tt({
1385
+ function _t({
1377
1386
  debounceSaveMs: e = 100,
1378
1387
  storage: t,
1379
1388
  ...n
1380
1389
  }) {
1381
1390
  const o = "id" in n ? n.id : n.groupId, i = Ct(o), s = Ze(
1382
- Rt,
1391
+ Et,
1383
1392
  () => t.getItem(i),
1384
1393
  () => t.getItem(i)
1385
1394
  ), l = ie(
@@ -1393,21 +1402,21 @@ function Tt({
1393
1402
  console.error(f);
1394
1403
  }
1395
1404
  };
1396
- return e > 0 ? Pt(a, e) : a;
1405
+ return e > 0 ? Rt(a, e) : a;
1397
1406
  }, [e, t, i]);
1398
1407
  return {
1399
1408
  defaultLayout: l,
1400
1409
  onLayoutChange: r
1401
1410
  };
1402
1411
  }
1403
- function Rt() {
1412
+ function Et() {
1404
1413
  return function() {
1405
1414
  };
1406
1415
  }
1407
- function _t() {
1408
- return k(null);
1409
- }
1410
1416
  function Nt() {
1417
+ return I(null);
1418
+ }
1419
+ function At() {
1411
1420
  return D(null);
1412
1421
  }
1413
1422
  function fe() {
@@ -1417,7 +1426,7 @@ function fe() {
1417
1426
  "Group Context not found; did you render a Panel or Separator outside of a Group?"
1418
1427
  ), e;
1419
1428
  }
1420
- function Et({
1429
+ function Mt({
1421
1430
  groupId: e,
1422
1431
  panelId: t
1423
1432
  }) {
@@ -1429,7 +1438,7 @@ function Et({
1429
1438
  defaultLayoutDeferred: u,
1430
1439
  derivedPanelConstraints: f,
1431
1440
  layout: p,
1432
- separatorToPanels: m
1441
+ separatorToPanels: h
1433
1442
  }
1434
1443
  ] of r)
1435
1444
  if (a.id === e)
@@ -1438,7 +1447,7 @@ function Et({
1438
1447
  derivedPanelConstraints: f,
1439
1448
  group: a,
1440
1449
  layout: p,
1441
- separatorToPanels: m
1450
+ separatorToPanels: h
1442
1451
  };
1443
1452
  throw Error(`Group ${e} not found`);
1444
1453
  }, o = () => {
@@ -1466,36 +1475,39 @@ function Et({
1466
1475
  defaultLayoutDeferred: u,
1467
1476
  derivedPanelConstraints: f,
1468
1477
  group: p,
1469
- layout: m,
1470
- separatorToPanels: h
1478
+ layout: h,
1479
+ separatorToPanels: m
1471
1480
  } = n(), c = p.panels.findIndex((S) => S.id === t), d = c === p.panels.length - 1, y = q({
1472
1481
  delta: d ? a - r : r - a,
1473
- initialLayout: m,
1482
+ initialLayout: h,
1474
1483
  panelConstraints: f,
1475
1484
  pivotIndices: d ? [c - 1, c] : [c, c + 1],
1476
- prevLayout: m,
1485
+ prevLayout: h,
1477
1486
  trigger: "imperative-api"
1478
1487
  }), v = _({
1479
1488
  layout: y,
1480
1489
  panelConstraints: f
1481
1490
  });
1482
- V(m, v) || E((S) => ({
1491
+ W(h, v) || E((S) => ({
1483
1492
  mountedGroups: new Map(S.mountedGroups).set(p, {
1484
1493
  defaultLayoutDeferred: u,
1485
1494
  derivedPanelConstraints: f,
1486
1495
  layout: v,
1487
- separatorToPanels: h
1496
+ separatorToPanels: m
1488
1497
  })
1489
1498
  }));
1490
1499
  };
1491
1500
  return {
1492
1501
  collapse: () => {
1493
- const { collapsible: r, collapsedSize: a } = o(), u = s();
1494
- r && u !== a && l(a);
1502
+ const { collapsible: r, collapsedSize: a } = o(), { expandToSizeRef: u } = i(), f = s();
1503
+ r && f !== a && (u.current = f, l(a));
1495
1504
  },
1496
1505
  expand: () => {
1497
- const { collapsible: r, collapsedSize: a, minSize: u } = o(), f = s();
1498
- r && f === a && l(u);
1506
+ const { collapsible: r, collapsedSize: a, minSize: u } = o(), { expandToSizeRef: f } = i(), p = s();
1507
+ if (r && p === a) {
1508
+ let h = f.current ?? u;
1509
+ h === 0 && (h = 1), l(h);
1510
+ }
1499
1511
  },
1500
1512
  getSize: () => {
1501
1513
  const { group: r } = n(), a = s(), { element: u } = i(), f = r.orientation === "horizontal" ? u.offsetWidth : u.offsetHeight;
@@ -1506,15 +1518,15 @@ function Et({
1506
1518
  },
1507
1519
  isCollapsed: () => {
1508
1520
  const { collapsible: r, collapsedSize: a } = o(), u = s();
1509
- return r && C(a, u);
1521
+ return r && R(a, u);
1510
1522
  },
1511
1523
  resize: (r) => {
1512
1524
  if (s() !== r) {
1513
1525
  let u;
1514
1526
  switch (typeof r) {
1515
1527
  case "number": {
1516
- const { group: f } = n(), p = W({ group: f });
1517
- u = I(r / p * 100);
1528
+ const { group: f } = n(), p = V({ group: f });
1529
+ u = k(r / p * 100);
1518
1530
  break;
1519
1531
  }
1520
1532
  case "string": {
@@ -1527,7 +1539,7 @@ function Et({
1527
1539
  }
1528
1540
  };
1529
1541
  }
1530
- function Mt(e, t) {
1542
+ function It(e, t) {
1531
1543
  const { id: n } = fe(), o = D({
1532
1544
  collapse: re,
1533
1545
  expand: re,
@@ -1541,11 +1553,11 @@ function Mt(e, t) {
1541
1553
  Ee(t, () => o.current, []), N(() => {
1542
1554
  Object.assign(
1543
1555
  o.current,
1544
- Et({ groupId: n, panelId: e })
1556
+ Mt({ groupId: n, panelId: e })
1545
1557
  );
1546
1558
  });
1547
1559
  }
1548
- function At({
1560
+ function $t({
1549
1561
  children: e,
1550
1562
  className: t,
1551
1563
  collapsedSize: n = "0%",
@@ -1558,17 +1570,18 @@ function At({
1558
1570
  onResize: u,
1559
1571
  panelRef: f,
1560
1572
  style: p,
1561
- ...m
1573
+ ...h
1562
1574
  }) {
1563
- const h = !!l, c = le(l), [d, y] = k(null), v = ce(y, s), { id: S, registerPanel: x } = fe(), g = u !== null, w = ue((P) => {
1575
+ const m = !!l, c = le(l), [d, y] = I(null), v = ce(y, s), { id: S, registerPanel: x } = fe(), g = u !== null, w = ue((P) => {
1564
1576
  u?.(P, l);
1565
1577
  });
1566
1578
  N(() => {
1567
1579
  if (d !== null)
1568
1580
  return x({
1569
1581
  element: d,
1582
+ expandToSizeRef: { current: void 0 },
1570
1583
  id: c,
1571
- idIsStable: h,
1584
+ idIsStable: m,
1572
1585
  onResize: g ? w : void 0,
1573
1586
  panelConstraints: {
1574
1587
  collapsedSize: n,
@@ -1585,17 +1598,17 @@ function At({
1585
1598
  d,
1586
1599
  g,
1587
1600
  c,
1588
- h,
1601
+ m,
1589
1602
  r,
1590
1603
  a,
1591
1604
  w,
1592
1605
  x
1593
- ]), Mt(c, f);
1606
+ ]), It(c, f);
1594
1607
  const L = je(S, c);
1595
1608
  return /* @__PURE__ */ K(
1596
1609
  "div",
1597
1610
  {
1598
- ...m,
1611
+ ...h,
1599
1612
  "data-panel": !0,
1600
1613
  "data-testid": c,
1601
1614
  id: c,
@@ -1642,13 +1655,13 @@ const kt = {
1642
1655
  padding: "unset",
1643
1656
  margin: "unset"
1644
1657
  };
1645
- function $t() {
1646
- return k(null);
1647
- }
1648
1658
  function Ft() {
1659
+ return I(null);
1660
+ }
1661
+ function Ht() {
1649
1662
  return D(null);
1650
1663
  }
1651
- function It({
1664
+ function Gt({
1652
1665
  layout: e,
1653
1666
  panelConstraints: t,
1654
1667
  panelId: n,
@@ -1689,7 +1702,7 @@ function It({
1689
1702
  valueNow: l
1690
1703
  };
1691
1704
  }
1692
- function Ht({
1705
+ function jt({
1693
1706
  children: e,
1694
1707
  className: t,
1695
1708
  elementRef: n,
@@ -1697,7 +1710,7 @@ function Ht({
1697
1710
  style: i,
1698
1711
  ...s
1699
1712
  }) {
1700
- const l = le(o), [r, a] = k({}), [u, f] = k("inactive"), [p, m] = k(null), h = ce(m, n), {
1713
+ const l = le(o), [r, a] = I({}), [u, f] = I("inactive"), [p, h] = I(null), m = ce(h, n), {
1701
1714
  id: c,
1702
1715
  orientation: d,
1703
1716
  registerSeparator: y
@@ -1707,7 +1720,7 @@ function Ht({
1707
1720
  const S = {
1708
1721
  element: p,
1709
1722
  id: l
1710
- }, x = y(S), g = T.addListener(
1723
+ }, x = y(S), g = O.addListener(
1711
1724
  "interactionStateChange",
1712
1725
  (L) => {
1713
1726
  f(
@@ -1716,7 +1729,7 @@ function Ht({
1716
1729
  ) ? L.state : "inactive"
1717
1730
  );
1718
1731
  }
1719
- ), w = T.addListener(
1732
+ ), w = O.addListener(
1720
1733
  "mountedGroupsChange",
1721
1734
  (L) => {
1722
1735
  L.forEach(
@@ -1726,7 +1739,7 @@ function Ht({
1726
1739
  if (Q) {
1727
1740
  const A = Q[0], U = J.panels.indexOf(A);
1728
1741
  a(
1729
- It({
1742
+ Gt({
1730
1743
  layout: Y,
1731
1744
  panelConstraints: P,
1732
1745
  panelId: A.id,
@@ -1757,7 +1770,7 @@ function Ht({
1757
1770
  "data-separator": u,
1758
1771
  "data-testid": l,
1759
1772
  id: l,
1760
- ref: h,
1773
+ ref: m,
1761
1774
  role: "separator",
1762
1775
  style: {
1763
1776
  flexBasis: "auto",
@@ -1771,12 +1784,12 @@ function Ht({
1771
1784
  }
1772
1785
  export {
1773
1786
  Ot as Group,
1774
- At as Panel,
1775
- Ht as Separator,
1776
- Tt as useDefaultLayout,
1777
- _t as useGroupCallbackRef,
1778
- Nt as useGroupRef,
1779
- $t as usePanelCallbackRef,
1780
- Ft as usePanelRef
1787
+ $t as Panel,
1788
+ jt as Separator,
1789
+ _t as useDefaultLayout,
1790
+ Nt as useGroupCallbackRef,
1791
+ At as useGroupRef,
1792
+ Ft as usePanelCallbackRef,
1793
+ Ht as usePanelRef
1781
1794
  };
1782
1795
  //# sourceMappingURL=react-resizable-panels.js.map