react-resizable-panels 4.0.2 → 4.0.4
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,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as W } from "react/jsx-runtime";
|
|
3
|
-
import { useId as $e, useLayoutEffect as Ne, useEffect as _e, useRef as T, useCallback as xe, createContext as
|
|
3
|
+
import { useId as $e, useLayoutEffect as Ne, useEffect as _e, useRef as T, useCallback as xe, createContext as Fe, useImperativeHandle as ze, useState as G, useMemo as be, useSyncExternalStore as He, useContext as We } from "react";
|
|
4
4
|
function z(e, t = "Assertion error") {
|
|
5
5
|
if (!e)
|
|
6
6
|
throw Error(t);
|
|
@@ -22,41 +22,41 @@ function we(e) {
|
|
|
22
22
|
const { element: t, orientation: n, panels: o, separators: r } = e, s = se(
|
|
23
23
|
n,
|
|
24
24
|
Array.from(t.children).filter((l) => l instanceof HTMLElement).map((l) => ({ element: l }))
|
|
25
|
-
).map(({ element: l }) => l),
|
|
25
|
+
).map(({ element: l }) => l), c = [];
|
|
26
26
|
let i, a;
|
|
27
27
|
for (const l of s) {
|
|
28
28
|
const f = o.find(
|
|
29
|
-
(
|
|
29
|
+
(u) => u.element === l
|
|
30
30
|
);
|
|
31
31
|
if (f) {
|
|
32
32
|
if (i) {
|
|
33
|
-
const
|
|
34
|
-
|
|
33
|
+
const u = i.element.getBoundingClientRect(), m = l.getBoundingClientRect();
|
|
34
|
+
c.push({
|
|
35
35
|
group: e,
|
|
36
36
|
panels: [i, f],
|
|
37
37
|
separator: a,
|
|
38
38
|
rect: n === "horizontal" ? new DOMRect(
|
|
39
|
-
|
|
39
|
+
u.right,
|
|
40
40
|
m.top,
|
|
41
|
-
m.left -
|
|
41
|
+
m.left - u.right,
|
|
42
42
|
m.height
|
|
43
43
|
) : new DOMRect(
|
|
44
44
|
m.left,
|
|
45
|
-
|
|
45
|
+
u.bottom,
|
|
46
46
|
m.width,
|
|
47
|
-
m.top -
|
|
47
|
+
m.top - u.bottom
|
|
48
48
|
)
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
i = f, a = void 0;
|
|
52
52
|
} else {
|
|
53
|
-
const
|
|
53
|
+
const u = r.find(
|
|
54
54
|
(m) => m.element === l
|
|
55
55
|
);
|
|
56
|
-
|
|
56
|
+
u ? a = u : (i = void 0, a = void 0);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
return
|
|
59
|
+
return c;
|
|
60
60
|
}
|
|
61
61
|
function Ue(e, t) {
|
|
62
62
|
const n = getComputedStyle(e), o = parseFloat(n.fontSize);
|
|
@@ -130,14 +130,14 @@ function pe(e) {
|
|
|
130
130
|
const { panels: t } = e, n = ae({ group: e });
|
|
131
131
|
return t.map((o) => {
|
|
132
132
|
const { element: r, panelConstraints: s } = o;
|
|
133
|
-
let
|
|
133
|
+
let c = 0;
|
|
134
134
|
if (s.collapsedSize) {
|
|
135
135
|
const f = J({
|
|
136
136
|
groupSize: n,
|
|
137
137
|
panelElement: r,
|
|
138
138
|
styleProp: s.collapsedSize
|
|
139
139
|
});
|
|
140
|
-
|
|
140
|
+
c = I(f / n * 100);
|
|
141
141
|
}
|
|
142
142
|
let i;
|
|
143
143
|
if (s.defaultSize) {
|
|
@@ -167,7 +167,7 @@ function pe(e) {
|
|
|
167
167
|
l = I(f / n * 100);
|
|
168
168
|
}
|
|
169
169
|
return {
|
|
170
|
-
collapsedSize:
|
|
170
|
+
collapsedSize: c,
|
|
171
171
|
collapsible: s.collapsible === !0,
|
|
172
172
|
defaultSize: i,
|
|
173
173
|
minSize: a,
|
|
@@ -191,9 +191,9 @@ class qe {
|
|
|
191
191
|
o[0].call(null, n);
|
|
192
192
|
else {
|
|
193
193
|
let r = !1, s = null;
|
|
194
|
-
const
|
|
195
|
-
for (let i = 0; i <
|
|
196
|
-
const a =
|
|
194
|
+
const c = Array.from(o);
|
|
195
|
+
for (let i = 0; i < c.length; i++) {
|
|
196
|
+
const a = c[i];
|
|
197
197
|
try {
|
|
198
198
|
a.call(null, n);
|
|
199
199
|
} catch (l) {
|
|
@@ -240,16 +240,16 @@ function C(e) {
|
|
|
240
240
|
}, t.cursorFlags !== void 0 && A.emit("cursorFlagsChange", R.cursorFlags), t.interactionState !== void 0 && A.emit("interactionStateChange", R.interactionState), t.mountedGroups !== void 0 && (R.mountedGroups.forEach((o, r) => {
|
|
241
241
|
o.derivedPanelConstraints.forEach((s) => {
|
|
242
242
|
if (s.collapsible) {
|
|
243
|
-
const { layout:
|
|
244
|
-
if (
|
|
243
|
+
const { layout: c } = n.mountedGroups.get(r) ?? {};
|
|
244
|
+
if (c) {
|
|
245
245
|
const i = w(
|
|
246
246
|
s.collapsedSize,
|
|
247
247
|
o.layout[s.panelId]
|
|
248
248
|
), a = w(
|
|
249
249
|
s.collapsedSize,
|
|
250
|
-
|
|
250
|
+
c[s.panelId]
|
|
251
251
|
);
|
|
252
|
-
i && !a && (r.inMemoryLastExpandedPanelSizes[s.panelId] =
|
|
252
|
+
i && !a && (r.inMemoryLastExpandedPanelSizes[s.panelId] = c[s.panelId]);
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
});
|
|
@@ -287,11 +287,11 @@ function Je({
|
|
|
287
287
|
return null;
|
|
288
288
|
switch (n) {
|
|
289
289
|
case "active": {
|
|
290
|
-
const s = (e & Le) !== 0,
|
|
290
|
+
const s = (e & Le) !== 0, c = (e & Pe) !== 0, i = (e & Ee) !== 0, a = (e & Re) !== 0;
|
|
291
291
|
if (e) {
|
|
292
292
|
if (s)
|
|
293
293
|
return i ? "se-resize" : a ? "ne-resize" : "e-resize";
|
|
294
|
-
if (
|
|
294
|
+
if (c)
|
|
295
295
|
return i ? "sw-resize" : a ? "nw-resize" : "w-resize";
|
|
296
296
|
if (i)
|
|
297
297
|
return "s-resize";
|
|
@@ -303,7 +303,7 @@ function Je({
|
|
|
303
303
|
}
|
|
304
304
|
return o > 0 && r > 0 ? "move" : o > 0 ? "ew-resize" : "ns-resize";
|
|
305
305
|
}
|
|
306
|
-
let ie
|
|
306
|
+
let ie, k;
|
|
307
307
|
function le() {
|
|
308
308
|
k === void 0 && (k = new CSSStyleSheet(), document.adoptedStyleSheets = [k]);
|
|
309
309
|
const { cursorFlags: e, interactionState: t } = O();
|
|
@@ -312,16 +312,16 @@ function le() {
|
|
|
312
312
|
case "hover": {
|
|
313
313
|
const n = Je({
|
|
314
314
|
cursorFlags: e,
|
|
315
|
-
groups: t.hitRegions.map((
|
|
315
|
+
groups: t.hitRegions.map((r) => r.group),
|
|
316
316
|
state: t.state
|
|
317
|
-
});
|
|
318
|
-
if (ie ===
|
|
317
|
+
}), o = `*{cursor: ${n} !important; ${t.state === "active" ? "touch-action: none;" : ""} }`;
|
|
318
|
+
if (ie === o)
|
|
319
319
|
return;
|
|
320
|
-
ie =
|
|
320
|
+
ie = o, n ? k.cssRules.length === 0 ? k.insertRule(o) : k.replaceSync(o) : k.cssRules.length === 1 && k.deleteRule(0);
|
|
321
321
|
break;
|
|
322
322
|
}
|
|
323
323
|
case "inactive": {
|
|
324
|
-
ie =
|
|
324
|
+
ie = void 0, k.cssRules.length === 1 && k.deleteRule(0);
|
|
325
325
|
break;
|
|
326
326
|
}
|
|
327
327
|
}
|
|
@@ -337,7 +337,7 @@ function Qe(e, t) {
|
|
|
337
337
|
function j(e, t) {
|
|
338
338
|
return w(e, t) ? 0 : e > t ? 1 : -1;
|
|
339
339
|
}
|
|
340
|
-
function
|
|
340
|
+
function F({
|
|
341
341
|
panelConstraints: e,
|
|
342
342
|
size: t
|
|
343
343
|
}) {
|
|
@@ -349,8 +349,8 @@ function H({
|
|
|
349
349
|
} = e;
|
|
350
350
|
if (j(t, s) < 0)
|
|
351
351
|
if (o) {
|
|
352
|
-
const
|
|
353
|
-
j(t,
|
|
352
|
+
const c = (n + s) / 2;
|
|
353
|
+
j(t, c) < 0 ? t = n : t = s;
|
|
354
354
|
} else
|
|
355
355
|
t = s;
|
|
356
356
|
return t = Math.min(r, t), t = I(t), t;
|
|
@@ -365,9 +365,9 @@ function B({
|
|
|
365
365
|
}) {
|
|
366
366
|
if (w(e, 0))
|
|
367
367
|
return t;
|
|
368
|
-
const
|
|
368
|
+
const c = Object.values(t), i = Object.values(r), a = [...c], [l, f] = o;
|
|
369
369
|
z(l != null, "Invalid first pivot index"), z(f != null, "Invalid second pivot index");
|
|
370
|
-
let
|
|
370
|
+
let u = 0;
|
|
371
371
|
if (s === "keyboard") {
|
|
372
372
|
{
|
|
373
373
|
const d = e < 0 ? f : l, p = n[d];
|
|
@@ -381,7 +381,7 @@ function B({
|
|
|
381
381
|
minSize: g = 0
|
|
382
382
|
} = p;
|
|
383
383
|
if (h) {
|
|
384
|
-
const x =
|
|
384
|
+
const x = c[d];
|
|
385
385
|
if (z(
|
|
386
386
|
x != null,
|
|
387
387
|
`Previous layout not found for panel index ${d}`
|
|
@@ -403,7 +403,7 @@ function B({
|
|
|
403
403
|
minSize: g = 0
|
|
404
404
|
} = p;
|
|
405
405
|
if (h) {
|
|
406
|
-
const x =
|
|
406
|
+
const x = c[d];
|
|
407
407
|
if (z(
|
|
408
408
|
x != null,
|
|
409
409
|
`Previous layout not found for panel index ${d}`
|
|
@@ -418,12 +418,12 @@ function B({
|
|
|
418
418
|
const d = e < 0 ? 1 : -1;
|
|
419
419
|
let p = e < 0 ? f : l, v = 0;
|
|
420
420
|
for (; ; ) {
|
|
421
|
-
const g =
|
|
421
|
+
const g = c[p];
|
|
422
422
|
z(
|
|
423
423
|
g != null,
|
|
424
424
|
`Previous layout not found for panel index ${p}`
|
|
425
425
|
);
|
|
426
|
-
const y =
|
|
426
|
+
const y = F({
|
|
427
427
|
panelConstraints: n[p],
|
|
428
428
|
size: 100
|
|
429
429
|
}) - g;
|
|
@@ -436,16 +436,16 @@ function B({
|
|
|
436
436
|
{
|
|
437
437
|
let p = e < 0 ? l : f;
|
|
438
438
|
for (; p >= 0 && p < n.length; ) {
|
|
439
|
-
const v = Math.abs(e) - Math.abs(
|
|
439
|
+
const v = Math.abs(e) - Math.abs(u), h = c[p];
|
|
440
440
|
z(
|
|
441
441
|
h != null,
|
|
442
442
|
`Previous layout not found for panel index ${p}`
|
|
443
443
|
);
|
|
444
|
-
const g = h - v, x =
|
|
444
|
+
const g = h - v, x = F({
|
|
445
445
|
panelConstraints: n[p],
|
|
446
446
|
size: g
|
|
447
447
|
});
|
|
448
|
-
if (!w(h, x) && (
|
|
448
|
+
if (!w(h, x) && (u += h - x, a[p] = x, u.toFixed(3).localeCompare(Math.abs(e).toFixed(3), void 0, {
|
|
449
449
|
numeric: !0
|
|
450
450
|
}) >= 0))
|
|
451
451
|
break;
|
|
@@ -455,12 +455,12 @@ function B({
|
|
|
455
455
|
if (Qe(i, a))
|
|
456
456
|
return r;
|
|
457
457
|
{
|
|
458
|
-
const d = e < 0 ? f : l, p =
|
|
458
|
+
const d = e < 0 ? f : l, p = c[d];
|
|
459
459
|
z(
|
|
460
460
|
p != null,
|
|
461
461
|
`Previous layout not found for panel index ${d}`
|
|
462
462
|
);
|
|
463
|
-
const v = p +
|
|
463
|
+
const v = p + u, h = F({
|
|
464
464
|
panelConstraints: n[d],
|
|
465
465
|
size: v
|
|
466
466
|
});
|
|
@@ -472,7 +472,7 @@ function B({
|
|
|
472
472
|
L != null,
|
|
473
473
|
`Previous layout not found for panel index ${y}`
|
|
474
474
|
);
|
|
475
|
-
const P = L + g, E =
|
|
475
|
+
const P = L + g, E = F({
|
|
476
476
|
panelConstraints: n[y],
|
|
477
477
|
size: P
|
|
478
478
|
});
|
|
@@ -507,9 +507,9 @@ function Ce({
|
|
|
507
507
|
pointerDownAtPoint: r
|
|
508
508
|
}) {
|
|
509
509
|
let s = 0;
|
|
510
|
-
const
|
|
510
|
+
const c = new Map(o);
|
|
511
511
|
t.forEach((i) => {
|
|
512
|
-
const { disableCursor: a, element: l, orientation: f, panels:
|
|
512
|
+
const { disableCursor: a, element: l, orientation: f, panels: u } = i.group;
|
|
513
513
|
let m = 0;
|
|
514
514
|
r ? f === "horizontal" ? m = (e.clientX - r.x) / l.offsetWidth * 100 : m = (e.clientY - r.y) / l.offsetHeight * 100 : f === "horizontal" ? m = e.clientX < 0 ? -100 : 100 : m = e.clientY < 0 ? -100 : 100;
|
|
515
515
|
const S = n.get(i.group), {
|
|
@@ -522,7 +522,7 @@ function Ce({
|
|
|
522
522
|
delta: m,
|
|
523
523
|
initialLayout: S,
|
|
524
524
|
panelConstraints: d,
|
|
525
|
-
pivotIndices: i.panels.map((g) =>
|
|
525
|
+
pivotIndices: i.panels.map((g) => u.indexOf(g)),
|
|
526
526
|
prevLayout: p,
|
|
527
527
|
trigger: "mouse-or-touch"
|
|
528
528
|
});
|
|
@@ -539,7 +539,7 @@ function Ce({
|
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
541
|
} else {
|
|
542
|
-
|
|
542
|
+
c.set(i.group, {
|
|
543
543
|
derivedPanelConstraints: d,
|
|
544
544
|
layout: h,
|
|
545
545
|
separatorToPanels: v
|
|
@@ -550,7 +550,7 @@ function Ce({
|
|
|
550
550
|
}
|
|
551
551
|
}), C({
|
|
552
552
|
cursorFlags: s,
|
|
553
|
-
mountedGroups:
|
|
553
|
+
mountedGroups: c
|
|
554
554
|
}), le();
|
|
555
555
|
}
|
|
556
556
|
function he(e) {
|
|
@@ -558,6 +558,8 @@ function he(e) {
|
|
|
558
558
|
return;
|
|
559
559
|
if (e.relatedTarget !== null)
|
|
560
560
|
return;
|
|
561
|
+
if (e.clientX === 0 && e.clientY === 0)
|
|
562
|
+
return;
|
|
561
563
|
const { interactionState: t, mountedGroups: n } = O();
|
|
562
564
|
switch (t.state) {
|
|
563
565
|
case "active":
|
|
@@ -603,7 +605,7 @@ function $({
|
|
|
603
605
|
for (let i = 0; i < t.length; i++) {
|
|
604
606
|
const a = o[i];
|
|
605
607
|
z(a != null, `No layout data found for index ${i}`);
|
|
606
|
-
const l =
|
|
608
|
+
const l = F({
|
|
607
609
|
panelConstraints: t[i],
|
|
608
610
|
size: a
|
|
609
611
|
});
|
|
@@ -613,15 +615,15 @@ function $({
|
|
|
613
615
|
for (let i = 0; i < t.length; i++) {
|
|
614
616
|
const a = o[i];
|
|
615
617
|
z(a != null, `No layout data found for index ${i}`);
|
|
616
|
-
const l = a + s, f =
|
|
618
|
+
const l = a + s, f = F({
|
|
617
619
|
panelConstraints: t[i],
|
|
618
620
|
size: l
|
|
619
621
|
});
|
|
620
622
|
if (a !== f && (s -= f - a, o[i] = f, w(s, 0)))
|
|
621
623
|
break;
|
|
622
624
|
}
|
|
623
|
-
const
|
|
624
|
-
return o.reduce((i, a, l) => (i[
|
|
625
|
+
const c = Object.keys(e);
|
|
626
|
+
return o.reduce((i, a, l) => (i[c[l]] = a, i), {});
|
|
625
627
|
}
|
|
626
628
|
function Me({
|
|
627
629
|
groupId: e
|
|
@@ -643,7 +645,7 @@ function Me({
|
|
|
643
645
|
derivedPanelConstraints: o,
|
|
644
646
|
group: r,
|
|
645
647
|
layout: s,
|
|
646
|
-
separatorToPanels:
|
|
648
|
+
separatorToPanels: c
|
|
647
649
|
} = t(), i = $({
|
|
648
650
|
layout: n,
|
|
649
651
|
panelConstraints: o
|
|
@@ -652,7 +654,7 @@ function Me({
|
|
|
652
654
|
mountedGroups: new Map(a.mountedGroups).set(r, {
|
|
653
655
|
derivedPanelConstraints: o,
|
|
654
656
|
layout: i,
|
|
655
|
-
separatorToPanels:
|
|
657
|
+
separatorToPanels: c
|
|
656
658
|
})
|
|
657
659
|
})), i;
|
|
658
660
|
}
|
|
@@ -664,24 +666,24 @@ function Ge(e) {
|
|
|
664
666
|
}
|
|
665
667
|
function D(e, t) {
|
|
666
668
|
const n = ee(e), o = Ge(n), r = n.separators.find(
|
|
667
|
-
(
|
|
669
|
+
(u) => u.element === e
|
|
668
670
|
);
|
|
669
671
|
z(r, "Matching separator not found");
|
|
670
672
|
const s = o.separatorToPanels.get(r);
|
|
671
673
|
z(s, "Matching panels not found");
|
|
672
|
-
const
|
|
674
|
+
const c = s.map((u) => n.panels.indexOf(u)), a = Me({ groupId: n.id }).getLayout(), l = B({
|
|
673
675
|
delta: t,
|
|
674
676
|
initialLayout: a,
|
|
675
677
|
panelConstraints: o.derivedPanelConstraints,
|
|
676
|
-
pivotIndices:
|
|
678
|
+
pivotIndices: c,
|
|
677
679
|
prevLayout: a,
|
|
678
680
|
trigger: "keyboard"
|
|
679
681
|
}), f = $({
|
|
680
682
|
layout: l,
|
|
681
683
|
panelConstraints: o.derivedPanelConstraints
|
|
682
684
|
});
|
|
683
|
-
U(a, f) || C((
|
|
684
|
-
mountedGroups: new Map(
|
|
685
|
+
U(a, f) || C((u) => ({
|
|
686
|
+
mountedGroups: new Map(u.mountedGroups).set(n, {
|
|
685
687
|
derivedPanelConstraints: o.derivedPanelConstraints,
|
|
686
688
|
layout: f,
|
|
687
689
|
separatorToPanels: o.separatorToPanels
|
|
@@ -716,18 +718,18 @@ function ve(e) {
|
|
|
716
718
|
}
|
|
717
719
|
case "Enter": {
|
|
718
720
|
e.preventDefault();
|
|
719
|
-
const o = ee(t), { derivedPanelConstraints: r, layout: s, separatorToPanels:
|
|
720
|
-
(
|
|
721
|
+
const o = ee(t), { derivedPanelConstraints: r, layout: s, separatorToPanels: c } = Ge(o), i = o.separators.find(
|
|
722
|
+
(u) => u.element === t
|
|
721
723
|
);
|
|
722
724
|
z(i, "Matching separator not found");
|
|
723
|
-
const a =
|
|
725
|
+
const a = c.get(i);
|
|
724
726
|
z(a, "Matching panels not found");
|
|
725
727
|
const l = a[0], f = r.find(
|
|
726
|
-
(
|
|
728
|
+
(u) => u.panelId === l.id
|
|
727
729
|
);
|
|
728
730
|
if (z(f, "Panel metadata not found"), f.collapsible) {
|
|
729
|
-
const
|
|
730
|
-
D(t, m -
|
|
731
|
+
const u = s[l.id], m = f.collapsedSize === u ? o.inMemoryLastExpandedPanelSizes[l.id] ?? f.minSize : f.collapsedSize;
|
|
732
|
+
D(t, m - u);
|
|
731
733
|
}
|
|
732
734
|
break;
|
|
733
735
|
}
|
|
@@ -739,8 +741,8 @@ function ve(e) {
|
|
|
739
741
|
(a) => a === e.currentTarget
|
|
740
742
|
);
|
|
741
743
|
z(s !== null, "Index not found");
|
|
742
|
-
const
|
|
743
|
-
r[
|
|
744
|
+
const c = e.shiftKey ? s > 0 ? s - 1 : r.length - 1 : s + 1 < r.length ? s + 1 : 0;
|
|
745
|
+
r[c].focus();
|
|
744
746
|
break;
|
|
745
747
|
}
|
|
746
748
|
case "Home": {
|
|
@@ -767,14 +769,14 @@ function tt(e, t, n) {
|
|
|
767
769
|
y: 1 / 0
|
|
768
770
|
};
|
|
769
771
|
for (const s of t) {
|
|
770
|
-
const
|
|
772
|
+
const c = et(n, s.rect);
|
|
771
773
|
switch (e) {
|
|
772
774
|
case "horizontal": {
|
|
773
|
-
|
|
775
|
+
c.x <= r.x && (o = s, r = c);
|
|
774
776
|
break;
|
|
775
777
|
}
|
|
776
778
|
case "vertical": {
|
|
777
|
-
|
|
779
|
+
c.y <= r.y && (o = s, r = c);
|
|
778
780
|
break;
|
|
779
781
|
}
|
|
780
782
|
}
|
|
@@ -793,7 +795,7 @@ function Ie(e, t) {
|
|
|
793
795
|
return t.forEach((o, r) => {
|
|
794
796
|
if (r.disabled)
|
|
795
797
|
return;
|
|
796
|
-
const s = nt() ? me.coarse : me.precise,
|
|
798
|
+
const s = nt() ? me.coarse : me.precise, c = we(r), i = tt(r.orientation, c, {
|
|
797
799
|
x: e.clientX,
|
|
798
800
|
y: e.clientY
|
|
799
801
|
});
|
|
@@ -803,17 +805,18 @@ function Ie(e, t) {
|
|
|
803
805
|
function ge(e) {
|
|
804
806
|
if (e.defaultPrevented)
|
|
805
807
|
return;
|
|
806
|
-
const { mountedGroups: t } = O(), n = Ie(e, t), o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(),
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
808
|
+
const { mountedGroups: t } = O(), n = Ie(e, t), o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
|
|
809
|
+
let i = !1;
|
|
810
|
+
n.forEach((a) => {
|
|
811
|
+
o.add(a.group), a.panels.forEach((f) => {
|
|
812
|
+
r.add(f);
|
|
813
|
+
}), a.separator && (s.add(a.separator), i || (i = !0, a.separator.element.focus()));
|
|
814
|
+
const l = t.get(a.group);
|
|
815
|
+
l && c.set(a.group, l.layout);
|
|
813
816
|
}), C({
|
|
814
817
|
interactionState: {
|
|
815
818
|
hitRegions: n,
|
|
816
|
-
initialLayoutMap:
|
|
819
|
+
initialLayoutMap: c,
|
|
817
820
|
pointerDownAtPoint: { x: e.clientX, y: e.clientY },
|
|
818
821
|
state: "active"
|
|
819
822
|
}
|
|
@@ -883,15 +886,15 @@ function ot(e) {
|
|
|
883
886
|
for (const s of e)
|
|
884
887
|
if (s.defaultSize !== void 0) {
|
|
885
888
|
t++;
|
|
886
|
-
const
|
|
887
|
-
n +=
|
|
889
|
+
const c = I(s.defaultSize);
|
|
890
|
+
n += c, o[s.panelId] = c;
|
|
888
891
|
} else
|
|
889
892
|
o[s.panelId] = void 0;
|
|
890
893
|
const r = e.length - t;
|
|
891
894
|
if (r !== 0) {
|
|
892
895
|
const s = I((100 - n) / r);
|
|
893
|
-
for (const
|
|
894
|
-
|
|
896
|
+
for (const c of e)
|
|
897
|
+
c.defaultSize === void 0 && (o[c.panelId] = s);
|
|
895
898
|
}
|
|
896
899
|
return o;
|
|
897
900
|
}
|
|
@@ -899,7 +902,7 @@ function it(e, t, n) {
|
|
|
899
902
|
const o = n[0];
|
|
900
903
|
if (!o)
|
|
901
904
|
return;
|
|
902
|
-
const r = e.panels.find((
|
|
905
|
+
const r = e.panels.find((c) => c.element === t);
|
|
903
906
|
if (!r || !r.onResize)
|
|
904
907
|
return;
|
|
905
908
|
const s = ae({ group: e });
|
|
@@ -919,8 +922,8 @@ function st(e) {
|
|
|
919
922
|
e.separators.length === 0 || e.separators.length < e.panels.length,
|
|
920
923
|
"Invalid Group configuration; too many Separator components"
|
|
921
924
|
);
|
|
922
|
-
const n = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), r = new ResizeObserver((
|
|
923
|
-
for (const m of
|
|
925
|
+
const n = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), r = new ResizeObserver((u) => {
|
|
926
|
+
for (const m of u) {
|
|
924
927
|
const { borderBoxSize: S, target: d } = m;
|
|
925
928
|
d === e.element ? t && C((p) => {
|
|
926
929
|
const v = p.mountedGroups.get(e);
|
|
@@ -941,17 +944,17 @@ function st(e) {
|
|
|
941
944
|
}) : it(e, d, S);
|
|
942
945
|
}
|
|
943
946
|
});
|
|
944
|
-
r.observe(e.element), e.panels.forEach((
|
|
947
|
+
r.observe(e.element), e.panels.forEach((u) => {
|
|
945
948
|
z(
|
|
946
|
-
!n.has(
|
|
947
|
-
`Panel ids must be unique; id "${
|
|
948
|
-
), n.add(
|
|
949
|
+
!n.has(u.id),
|
|
950
|
+
`Panel ids must be unique; id "${u.id}" was used more than once`
|
|
951
|
+
), n.add(u.id), u.onResize && r.observe(u.element);
|
|
949
952
|
});
|
|
950
|
-
const s = pe(e),
|
|
953
|
+
const s = pe(e), c = e.panels.map(({ id: u }) => u).join(","), i = e.inMemoryLayouts[c] ?? e.defaultLayout ?? ot(s), a = $({
|
|
951
954
|
layout: i,
|
|
952
955
|
panelConstraints: s
|
|
953
|
-
}), l = we(e), f = C((
|
|
954
|
-
mountedGroups: new Map(
|
|
956
|
+
}), l = we(e), f = C((u) => ({
|
|
957
|
+
mountedGroups: new Map(u.mountedGroups).set(e, {
|
|
955
958
|
derivedPanelConstraints: s,
|
|
956
959
|
layout: a,
|
|
957
960
|
separatorToPanels: new Map(
|
|
@@ -959,11 +962,11 @@ function st(e) {
|
|
|
959
962
|
)
|
|
960
963
|
})
|
|
961
964
|
}));
|
|
962
|
-
return e.element.addEventListener("pointerleave", he), e.separators.forEach((
|
|
965
|
+
return e.element.addEventListener("pointerleave", he), e.separators.forEach((u) => {
|
|
963
966
|
z(
|
|
964
|
-
!o.has(
|
|
965
|
-
`Separator ids must be unique; id "${
|
|
966
|
-
), o.add(
|
|
967
|
+
!o.has(u.id),
|
|
968
|
+
`Separator ids must be unique; id "${u.id}" was used more than once`
|
|
969
|
+
), o.add(u.id), u.element.addEventListener("keydown", ve);
|
|
967
970
|
}), f.mountedGroups.size === 1 && (window.addEventListener("pointerdown", ge), window.addEventListener("pointermove", ye), window.addEventListener("pointerup", Se)), function() {
|
|
968
971
|
t = !1;
|
|
969
972
|
const m = C((S) => {
|
|
@@ -975,19 +978,19 @@ function st(e) {
|
|
|
975
978
|
}), m.mountedGroups.size === 0 && (window.removeEventListener("pointerdown", ge), window.removeEventListener("pointermove", ye), window.removeEventListener("pointerup", Se)), r.disconnect();
|
|
976
979
|
};
|
|
977
980
|
}
|
|
978
|
-
function
|
|
981
|
+
function ce(e) {
|
|
979
982
|
const t = $e();
|
|
980
983
|
return `${e ?? t}`;
|
|
981
984
|
}
|
|
982
|
-
const
|
|
983
|
-
function
|
|
985
|
+
const H = typeof window < "u" ? Ne : _e;
|
|
986
|
+
function ue(e) {
|
|
984
987
|
const t = T(e);
|
|
985
|
-
return
|
|
988
|
+
return H(() => {
|
|
986
989
|
t.current = e;
|
|
987
990
|
}, [e]), xe((n) => t.current?.(n), [t]);
|
|
988
991
|
}
|
|
989
992
|
function fe(...e) {
|
|
990
|
-
return
|
|
993
|
+
return ue((t) => {
|
|
991
994
|
e.forEach((n) => {
|
|
992
995
|
if (n)
|
|
993
996
|
switch (typeof n) {
|
|
@@ -1008,13 +1011,13 @@ function Oe(e, t) {
|
|
|
1008
1011
|
const n = e.replace(/[^a-zA-Z0-9\-_]/g, ""), o = t.replace(/[^a-zA-Z0-9\-_]/g, "");
|
|
1009
1012
|
return `--react-resizable-panels--${n}--${o}`;
|
|
1010
1013
|
}
|
|
1011
|
-
const Te =
|
|
1014
|
+
const Te = Fe(null);
|
|
1012
1015
|
function rt(e, t) {
|
|
1013
1016
|
const n = T({
|
|
1014
1017
|
getLayout: () => ({}),
|
|
1015
1018
|
setLayout: Ze
|
|
1016
1019
|
});
|
|
1017
|
-
ze(t, () => n.current, []),
|
|
1020
|
+
ze(t, () => n.current, []), H(() => {
|
|
1018
1021
|
Object.assign(
|
|
1019
1022
|
n.current,
|
|
1020
1023
|
Me({ groupId: e })
|
|
@@ -1028,17 +1031,17 @@ function ht({
|
|
|
1028
1031
|
disableCursor: o,
|
|
1029
1032
|
disabled: r,
|
|
1030
1033
|
elementRef: s,
|
|
1031
|
-
groupRef:
|
|
1034
|
+
groupRef: c,
|
|
1032
1035
|
id: i,
|
|
1033
1036
|
onLayoutChange: a,
|
|
1034
1037
|
orientation: l = "horizontal",
|
|
1035
1038
|
style: f,
|
|
1036
|
-
...
|
|
1039
|
+
...u
|
|
1037
1040
|
}) {
|
|
1038
|
-
const m = T({}), S =
|
|
1041
|
+
const m = T({}), S = ue((b) => {
|
|
1039
1042
|
U(m.current, b) || (m.current = b, a?.(b));
|
|
1040
|
-
}), d =
|
|
1041
|
-
rt(d,
|
|
1043
|
+
}), d = ce(i), [p, v] = G(!1), [h, g] = G(null), [x, y] = G(n ?? {}), [L, P] = G([]), [E, K] = G([]), te = T({}), V = T({}), X = fe(g, s);
|
|
1044
|
+
rt(d, c);
|
|
1042
1045
|
const Y = be(
|
|
1043
1046
|
() => ({
|
|
1044
1047
|
id: d,
|
|
@@ -1056,7 +1059,7 @@ function ht({
|
|
|
1056
1059
|
}),
|
|
1057
1060
|
[d, l]
|
|
1058
1061
|
);
|
|
1059
|
-
|
|
1062
|
+
H(() => {
|
|
1060
1063
|
if (h !== null && L.length > 0) {
|
|
1061
1064
|
const b = {
|
|
1062
1065
|
defaultLayout: n,
|
|
@@ -1118,7 +1121,7 @@ function ht({
|
|
|
1118
1121
|
return /* @__PURE__ */ W(Te.Provider, { value: Y, children: /* @__PURE__ */ W(
|
|
1119
1122
|
"div",
|
|
1120
1123
|
{
|
|
1121
|
-
...
|
|
1124
|
+
...u,
|
|
1122
1125
|
"aria-orientation": l,
|
|
1123
1126
|
className: t,
|
|
1124
1127
|
"data-group": !0,
|
|
@@ -1155,12 +1158,12 @@ function vt({
|
|
|
1155
1158
|
groupId: e,
|
|
1156
1159
|
storage: t
|
|
1157
1160
|
}) {
|
|
1158
|
-
const n =
|
|
1161
|
+
const n = He(
|
|
1159
1162
|
lt,
|
|
1160
1163
|
() => t.getItem(re(e)),
|
|
1161
1164
|
() => t.getItem(re(e))
|
|
1162
1165
|
), o = be(
|
|
1163
|
-
() => n ? JSON.parse(n) :
|
|
1166
|
+
() => n ? JSON.parse(n) : void 0,
|
|
1164
1167
|
[n]
|
|
1165
1168
|
), r = xe(
|
|
1166
1169
|
(s) => at({
|
|
@@ -1192,7 +1195,7 @@ function de() {
|
|
|
1192
1195
|
"Group Context not found; did you render a Panel or Separator outside of a Group?"
|
|
1193
1196
|
), e;
|
|
1194
1197
|
}
|
|
1195
|
-
function
|
|
1198
|
+
function ct({
|
|
1196
1199
|
groupId: e,
|
|
1197
1200
|
panelId: t
|
|
1198
1201
|
}) {
|
|
@@ -1200,10 +1203,10 @@ function ut({
|
|
|
1200
1203
|
const { mountedGroups: i } = O();
|
|
1201
1204
|
for (const [
|
|
1202
1205
|
a,
|
|
1203
|
-
{ derivedPanelConstraints: l, layout: f, separatorToPanels:
|
|
1206
|
+
{ derivedPanelConstraints: l, layout: f, separatorToPanels: u }
|
|
1204
1207
|
] of i)
|
|
1205
1208
|
if (a.id === e)
|
|
1206
|
-
return { derivedPanelConstraints: l, group: a, layout: f, separatorToPanels:
|
|
1209
|
+
return { derivedPanelConstraints: l, group: a, layout: f, separatorToPanels: u };
|
|
1207
1210
|
throw Error(`Group ${e} not found`);
|
|
1208
1211
|
}, o = () => {
|
|
1209
1212
|
const i = n().derivedPanelConstraints.find(
|
|
@@ -1222,27 +1225,27 @@ function ut({
|
|
|
1222
1225
|
if (i !== void 0)
|
|
1223
1226
|
return i;
|
|
1224
1227
|
throw Error(`Layout not found for Panel ${t}`);
|
|
1225
|
-
},
|
|
1228
|
+
}, c = (i) => {
|
|
1226
1229
|
const a = s();
|
|
1227
1230
|
if (i === a)
|
|
1228
1231
|
return;
|
|
1229
1232
|
const {
|
|
1230
1233
|
derivedPanelConstraints: l,
|
|
1231
1234
|
group: f,
|
|
1232
|
-
layout:
|
|
1235
|
+
layout: u,
|
|
1233
1236
|
separatorToPanels: m
|
|
1234
1237
|
} = n(), S = f.panels.findIndex((h) => h.id === t), d = S === f.panels.length - 1, p = B({
|
|
1235
1238
|
delta: d ? a - i : i - a,
|
|
1236
|
-
initialLayout:
|
|
1239
|
+
initialLayout: u,
|
|
1237
1240
|
panelConstraints: l,
|
|
1238
1241
|
pivotIndices: d ? [S - 1, S] : [S, S + 1],
|
|
1239
|
-
prevLayout:
|
|
1242
|
+
prevLayout: u,
|
|
1240
1243
|
trigger: "imperative-api"
|
|
1241
1244
|
}), v = $({
|
|
1242
1245
|
layout: p,
|
|
1243
1246
|
panelConstraints: l
|
|
1244
1247
|
});
|
|
1245
|
-
U(
|
|
1248
|
+
U(u, v) || C((h) => ({
|
|
1246
1249
|
mountedGroups: new Map(h.mountedGroups).set(f, {
|
|
1247
1250
|
derivedPanelConstraints: l,
|
|
1248
1251
|
layout: v,
|
|
@@ -1253,11 +1256,11 @@ function ut({
|
|
|
1253
1256
|
return {
|
|
1254
1257
|
collapse: () => {
|
|
1255
1258
|
const { collapsible: i, collapsedSize: a } = o(), l = s();
|
|
1256
|
-
i && l !== a &&
|
|
1259
|
+
i && l !== a && c(a);
|
|
1257
1260
|
},
|
|
1258
1261
|
expand: () => {
|
|
1259
1262
|
const { collapsible: i, collapsedSize: a, minSize: l } = o(), f = s();
|
|
1260
|
-
i && f === a &&
|
|
1263
|
+
i && f === a && c(l);
|
|
1261
1264
|
},
|
|
1262
1265
|
getSize: () => {
|
|
1263
1266
|
const { group: i } = n(), a = s(), { element: l } = r(), f = i.orientation === "horizontal" ? l.offsetWidth : l.offsetHeight;
|
|
@@ -1275,8 +1278,8 @@ function ut({
|
|
|
1275
1278
|
let l;
|
|
1276
1279
|
switch (typeof i) {
|
|
1277
1280
|
case "number": {
|
|
1278
|
-
const { group: f } = n(),
|
|
1279
|
-
l = I(i /
|
|
1281
|
+
const { group: f } = n(), u = ae({ group: f });
|
|
1282
|
+
l = I(i / u * 100);
|
|
1280
1283
|
break;
|
|
1281
1284
|
}
|
|
1282
1285
|
case "string": {
|
|
@@ -1284,12 +1287,12 @@ function ut({
|
|
|
1284
1287
|
break;
|
|
1285
1288
|
}
|
|
1286
1289
|
}
|
|
1287
|
-
|
|
1290
|
+
c(l);
|
|
1288
1291
|
}
|
|
1289
1292
|
}
|
|
1290
1293
|
};
|
|
1291
1294
|
}
|
|
1292
|
-
function
|
|
1295
|
+
function ut(e, t) {
|
|
1293
1296
|
const { id: n } = de(), o = T({
|
|
1294
1297
|
collapse: oe,
|
|
1295
1298
|
expand: oe,
|
|
@@ -1300,10 +1303,10 @@ function ct(e, t) {
|
|
|
1300
1303
|
isCollapsed: () => !1,
|
|
1301
1304
|
resize: oe
|
|
1302
1305
|
});
|
|
1303
|
-
ze(t, () => o.current, []),
|
|
1306
|
+
ze(t, () => o.current, []), H(() => {
|
|
1304
1307
|
Object.assign(
|
|
1305
1308
|
o.current,
|
|
1306
|
-
|
|
1309
|
+
ct({ groupId: n, panelId: e })
|
|
1307
1310
|
);
|
|
1308
1311
|
});
|
|
1309
1312
|
}
|
|
@@ -1314,18 +1317,18 @@ function St({
|
|
|
1314
1317
|
collapsible: o = !1,
|
|
1315
1318
|
defaultSize: r,
|
|
1316
1319
|
elementRef: s,
|
|
1317
|
-
id:
|
|
1320
|
+
id: c,
|
|
1318
1321
|
maxSize: i = "100",
|
|
1319
1322
|
minSize: a = "0",
|
|
1320
1323
|
onResize: l,
|
|
1321
1324
|
panelRef: f,
|
|
1322
|
-
style:
|
|
1325
|
+
style: u,
|
|
1323
1326
|
...m
|
|
1324
1327
|
}) {
|
|
1325
|
-
const S = !!
|
|
1326
|
-
l?.(E,
|
|
1328
|
+
const S = !!c, d = ce(c), [p, v] = G(null), h = fe(v, s), { id: g, registerPanel: x } = de(), y = l !== null, L = ue((E) => {
|
|
1329
|
+
l?.(E, c);
|
|
1327
1330
|
});
|
|
1328
|
-
|
|
1331
|
+
H(() => {
|
|
1329
1332
|
if (p !== null)
|
|
1330
1333
|
return x({
|
|
1331
1334
|
element: p,
|
|
@@ -1352,7 +1355,7 @@ function St({
|
|
|
1352
1355
|
a,
|
|
1353
1356
|
L,
|
|
1354
1357
|
x
|
|
1355
|
-
]),
|
|
1358
|
+
]), ut(d, f);
|
|
1356
1359
|
const P = Oe(g, d);
|
|
1357
1360
|
return /* @__PURE__ */ W(
|
|
1358
1361
|
"div",
|
|
@@ -1380,7 +1383,7 @@ function St({
|
|
|
1380
1383
|
style: {
|
|
1381
1384
|
width: "100%",
|
|
1382
1385
|
height: "100%",
|
|
1383
|
-
...
|
|
1386
|
+
...u
|
|
1384
1387
|
},
|
|
1385
1388
|
children: e
|
|
1386
1389
|
}
|
|
@@ -1417,14 +1420,14 @@ function dt({
|
|
|
1417
1420
|
panelIndex: o
|
|
1418
1421
|
}) {
|
|
1419
1422
|
let r, s;
|
|
1420
|
-
const
|
|
1423
|
+
const c = e[n], i = t.find(
|
|
1421
1424
|
(a) => a.panelId === n
|
|
1422
1425
|
);
|
|
1423
1426
|
if (i) {
|
|
1424
1427
|
const a = i.maxSize, l = s = i.collapsible ? i.collapsedSize : i.minSize, f = [o, o + 1];
|
|
1425
1428
|
s = $({
|
|
1426
1429
|
layout: B({
|
|
1427
|
-
delta: l -
|
|
1430
|
+
delta: l - c,
|
|
1428
1431
|
initialLayout: e,
|
|
1429
1432
|
panelConstraints: t,
|
|
1430
1433
|
pivotIndices: f,
|
|
@@ -1434,7 +1437,7 @@ function dt({
|
|
|
1434
1437
|
panelConstraints: t
|
|
1435
1438
|
})[n], r = $({
|
|
1436
1439
|
layout: B({
|
|
1437
|
-
delta: a -
|
|
1440
|
+
delta: a - c,
|
|
1438
1441
|
initialLayout: e,
|
|
1439
1442
|
panelConstraints: t,
|
|
1440
1443
|
pivotIndices: f,
|
|
@@ -1448,7 +1451,7 @@ function dt({
|
|
|
1448
1451
|
valueControls: n,
|
|
1449
1452
|
valueMax: r,
|
|
1450
1453
|
valueMin: s,
|
|
1451
|
-
valueNow:
|
|
1454
|
+
valueNow: c
|
|
1452
1455
|
};
|
|
1453
1456
|
}
|
|
1454
1457
|
function bt({
|
|
@@ -1459,16 +1462,16 @@ function bt({
|
|
|
1459
1462
|
style: r,
|
|
1460
1463
|
...s
|
|
1461
1464
|
}) {
|
|
1462
|
-
const
|
|
1465
|
+
const c = ce(o), [i, a] = G({}), [l, f] = G("inactive"), [u, m] = G(null), S = fe(m, n), {
|
|
1463
1466
|
id: d,
|
|
1464
1467
|
orientation: p,
|
|
1465
1468
|
registerSeparator: v
|
|
1466
1469
|
} = de(), h = p === "horizontal" ? "vertical" : "horizontal";
|
|
1467
|
-
return
|
|
1468
|
-
if (
|
|
1470
|
+
return H(() => {
|
|
1471
|
+
if (u !== null) {
|
|
1469
1472
|
const g = {
|
|
1470
|
-
element:
|
|
1471
|
-
id:
|
|
1473
|
+
element: u,
|
|
1474
|
+
id: c
|
|
1472
1475
|
}, x = v(g), y = A.addListener(
|
|
1473
1476
|
"interactionStateChange",
|
|
1474
1477
|
(P) => {
|
|
@@ -1505,7 +1508,7 @@ function bt({
|
|
|
1505
1508
|
y(), L(), x();
|
|
1506
1509
|
};
|
|
1507
1510
|
}
|
|
1508
|
-
}, [
|
|
1511
|
+
}, [u, d, c, v]), /* @__PURE__ */ W(
|
|
1509
1512
|
"div",
|
|
1510
1513
|
{
|
|
1511
1514
|
...s,
|
|
@@ -1517,8 +1520,8 @@ function bt({
|
|
|
1517
1520
|
children: e,
|
|
1518
1521
|
className: t,
|
|
1519
1522
|
"data-separator": l,
|
|
1520
|
-
"data-testid":
|
|
1521
|
-
id:
|
|
1523
|
+
"data-testid": c,
|
|
1524
|
+
id: c,
|
|
1522
1525
|
ref: S,
|
|
1523
1526
|
role: "separator",
|
|
1524
1527
|
style: {
|