react-resizable-panels 4.0.14 → 4.0.15
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 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
|
|
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 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);
|
|
@@ -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
|
|
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 } =
|
|
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
|
|
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 }))
|
|
@@ -195,7 +195,7 @@ function te({
|
|
|
195
195
|
}
|
|
196
196
|
return o;
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function k(e) {
|
|
199
199
|
return parseFloat(e.toFixed(3));
|
|
200
200
|
}
|
|
201
201
|
function me(e) {
|
|
@@ -216,7 +216,7 @@ function me(e) {
|
|
|
216
216
|
panelElement: i,
|
|
217
217
|
styleProp: s.collapsedSize
|
|
218
218
|
});
|
|
219
|
-
l =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
246
|
+
u = k(f / n * 100);
|
|
247
247
|
}
|
|
248
248
|
return {
|
|
249
249
|
collapsedSize: l,
|
|
@@ -295,7 +295,7 @@ class at {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
function C(e, t, n = 0) {
|
|
298
|
-
return Math.abs(
|
|
298
|
+
return Math.abs(k(e) - k(t)) <= n;
|
|
299
299
|
}
|
|
300
300
|
let R = {
|
|
301
301
|
cursorFlags: 0,
|
|
@@ -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 =
|
|
364
|
+
return t = Math.min(i, t), t = k(t), t;
|
|
365
365
|
}
|
|
366
366
|
function q({
|
|
367
367
|
delta: e,
|
|
@@ -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 =
|
|
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 =
|
|
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
|
});
|
|
@@ -1050,13 +1050,13 @@ function Ce(e) {
|
|
|
1050
1050
|
for (const s of e)
|
|
1051
1051
|
if (s.defaultSize !== void 0) {
|
|
1052
1052
|
t++;
|
|
1053
|
-
const l =
|
|
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 =
|
|
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
|
}
|
|
@@ -1072,7 +1072,7 @@ function xt(e, t, n) {
|
|
|
1072
1072
|
const s = W({ group: e });
|
|
1073
1073
|
i.onResize(
|
|
1074
1074
|
{
|
|
1075
|
-
asPercentage:
|
|
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
|
|
1101
|
+
function wt(e) {
|
|
1093
1102
|
let t = !0;
|
|
1094
1103
|
z(
|
|
1095
1104
|
e.element.ownerDocument.defaultView,
|
|
@@ -1136,11 +1145,11 @@ function bt(e) {
|
|
|
1136
1145
|
});
|
|
1137
1146
|
const l = W({ group: e }), r = me(e), a = e.panels.map(({ id: c }) => c).join(",");
|
|
1138
1147
|
let u = e.defaultLayout;
|
|
1139
|
-
u && e.panels
|
|
1148
|
+
u && (bt(e.panels, u) || (u = void 0));
|
|
1140
1149
|
const f = e.inMemoryLayouts[a] ?? u ?? Ce(r), p = _({
|
|
1141
1150
|
layout: f,
|
|
1142
1151
|
panelConstraints: r
|
|
1143
|
-
}), m =
|
|
1152
|
+
}), m = ke(e), h = e.element.ownerDocument;
|
|
1144
1153
|
return E((c) => {
|
|
1145
1154
|
const d = /* @__PURE__ */ new Map();
|
|
1146
1155
|
return j.set(
|
|
@@ -1201,7 +1210,7 @@ function ce(...e) {
|
|
|
1201
1210
|
});
|
|
1202
1211
|
});
|
|
1203
1212
|
}
|
|
1204
|
-
function
|
|
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
|
|
1226
|
+
function Pt(e, t) {
|
|
1218
1227
|
const n = D({
|
|
1219
1228
|
getLayout: () => ({}),
|
|
1220
1229
|
setLayout: ut
|
|
@@ -1226,7 +1235,7 @@ function Lt(e, t) {
|
|
|
1226
1235
|
);
|
|
1227
1236
|
});
|
|
1228
1237
|
}
|
|
1229
|
-
function
|
|
1238
|
+
function Tt({
|
|
1230
1239
|
children: e,
|
|
1231
1240
|
className: t,
|
|
1232
1241
|
defaultLayout: n,
|
|
@@ -1242,11 +1251,11 @@ function Ot({
|
|
|
1242
1251
|
}) {
|
|
1243
1252
|
const m = D({}), h = ue((b) => {
|
|
1244
1253
|
V(m.current, b) || (m.current = b, a?.(b));
|
|
1245
|
-
}), c = le(r), [d, y] =
|
|
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
|
-
|
|
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 =
|
|
1275
|
+
), A = Lt({
|
|
1267
1276
|
defaultLayout: n,
|
|
1268
1277
|
disableCursor: o
|
|
1269
1278
|
}), U = D(null);
|
|
@@ -1283,7 +1292,7 @@ function Ot({
|
|
|
1283
1292
|
separators: P
|
|
1284
1293
|
};
|
|
1285
1294
|
U.current = b;
|
|
1286
|
-
const M =
|
|
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
1298
|
!F && H.length > 0 && (g(ee), h?.(ee));
|
|
@@ -1362,7 +1371,7 @@ function Ot({
|
|
|
1362
1371
|
}
|
|
1363
1372
|
) });
|
|
1364
1373
|
}
|
|
1365
|
-
function
|
|
1374
|
+
function Ct(e, t = 10) {
|
|
1366
1375
|
let n = null;
|
|
1367
1376
|
return (o) => {
|
|
1368
1377
|
n !== null && clearTimeout(n), n = setTimeout(() => {
|
|
@@ -1370,16 +1379,16 @@ function Pt(e, t = 10) {
|
|
|
1370
1379
|
}, t);
|
|
1371
1380
|
};
|
|
1372
1381
|
}
|
|
1373
|
-
function
|
|
1382
|
+
function Rt(e) {
|
|
1374
1383
|
return `react-resizable-panels:${e}`;
|
|
1375
1384
|
}
|
|
1376
|
-
function
|
|
1385
|
+
function _t({
|
|
1377
1386
|
debounceSaveMs: e = 100,
|
|
1378
1387
|
storage: t,
|
|
1379
1388
|
...n
|
|
1380
1389
|
}) {
|
|
1381
|
-
const o = "id" in n ? n.id : n.groupId, i =
|
|
1382
|
-
|
|
1390
|
+
const o = "id" in n ? n.id : n.groupId, i = Rt(o), s = Ze(
|
|
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 ?
|
|
1405
|
+
return e > 0 ? Ct(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
|
|
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
|
|
1429
|
+
function Mt({
|
|
1421
1430
|
groupId: e,
|
|
1422
1431
|
panelId: t
|
|
1423
1432
|
}) {
|
|
@@ -1514,7 +1523,7 @@ function Et({
|
|
|
1514
1523
|
switch (typeof r) {
|
|
1515
1524
|
case "number": {
|
|
1516
1525
|
const { group: f } = n(), p = W({ group: f });
|
|
1517
|
-
u =
|
|
1526
|
+
u = k(r / p * 100);
|
|
1518
1527
|
break;
|
|
1519
1528
|
}
|
|
1520
1529
|
case "string": {
|
|
@@ -1527,7 +1536,7 @@ function Et({
|
|
|
1527
1536
|
}
|
|
1528
1537
|
};
|
|
1529
1538
|
}
|
|
1530
|
-
function
|
|
1539
|
+
function It(e, t) {
|
|
1531
1540
|
const { id: n } = fe(), o = D({
|
|
1532
1541
|
collapse: re,
|
|
1533
1542
|
expand: re,
|
|
@@ -1541,11 +1550,11 @@ function Mt(e, t) {
|
|
|
1541
1550
|
Ee(t, () => o.current, []), N(() => {
|
|
1542
1551
|
Object.assign(
|
|
1543
1552
|
o.current,
|
|
1544
|
-
|
|
1553
|
+
Mt({ groupId: n, panelId: e })
|
|
1545
1554
|
);
|
|
1546
1555
|
});
|
|
1547
1556
|
}
|
|
1548
|
-
function
|
|
1557
|
+
function $t({
|
|
1549
1558
|
children: e,
|
|
1550
1559
|
className: t,
|
|
1551
1560
|
collapsedSize: n = "0%",
|
|
@@ -1560,7 +1569,7 @@ function At({
|
|
|
1560
1569
|
style: p,
|
|
1561
1570
|
...m
|
|
1562
1571
|
}) {
|
|
1563
|
-
const h = !!l, c = le(l), [d, y] =
|
|
1572
|
+
const h = !!l, c = le(l), [d, y] = I(null), v = ce(y, s), { id: S, registerPanel: x } = fe(), g = u !== null, w = ue((P) => {
|
|
1564
1573
|
u?.(P, l);
|
|
1565
1574
|
});
|
|
1566
1575
|
N(() => {
|
|
@@ -1590,7 +1599,7 @@ function At({
|
|
|
1590
1599
|
a,
|
|
1591
1600
|
w,
|
|
1592
1601
|
x
|
|
1593
|
-
]),
|
|
1602
|
+
]), It(c, f);
|
|
1594
1603
|
const L = je(S, c);
|
|
1595
1604
|
return /* @__PURE__ */ K(
|
|
1596
1605
|
"div",
|
|
@@ -1642,13 +1651,13 @@ const kt = {
|
|
|
1642
1651
|
padding: "unset",
|
|
1643
1652
|
margin: "unset"
|
|
1644
1653
|
};
|
|
1645
|
-
function $t() {
|
|
1646
|
-
return k(null);
|
|
1647
|
-
}
|
|
1648
1654
|
function Ft() {
|
|
1655
|
+
return I(null);
|
|
1656
|
+
}
|
|
1657
|
+
function Ht() {
|
|
1649
1658
|
return D(null);
|
|
1650
1659
|
}
|
|
1651
|
-
function
|
|
1660
|
+
function Gt({
|
|
1652
1661
|
layout: e,
|
|
1653
1662
|
panelConstraints: t,
|
|
1654
1663
|
panelId: n,
|
|
@@ -1689,7 +1698,7 @@ function It({
|
|
|
1689
1698
|
valueNow: l
|
|
1690
1699
|
};
|
|
1691
1700
|
}
|
|
1692
|
-
function
|
|
1701
|
+
function jt({
|
|
1693
1702
|
children: e,
|
|
1694
1703
|
className: t,
|
|
1695
1704
|
elementRef: n,
|
|
@@ -1697,7 +1706,7 @@ function Ht({
|
|
|
1697
1706
|
style: i,
|
|
1698
1707
|
...s
|
|
1699
1708
|
}) {
|
|
1700
|
-
const l = le(o), [r, a] =
|
|
1709
|
+
const l = le(o), [r, a] = I({}), [u, f] = I("inactive"), [p, m] = I(null), h = ce(m, n), {
|
|
1701
1710
|
id: c,
|
|
1702
1711
|
orientation: d,
|
|
1703
1712
|
registerSeparator: y
|
|
@@ -1726,7 +1735,7 @@ function Ht({
|
|
|
1726
1735
|
if (Q) {
|
|
1727
1736
|
const A = Q[0], U = J.panels.indexOf(A);
|
|
1728
1737
|
a(
|
|
1729
|
-
|
|
1738
|
+
Gt({
|
|
1730
1739
|
layout: Y,
|
|
1731
1740
|
panelConstraints: P,
|
|
1732
1741
|
panelId: A.id,
|
|
@@ -1770,13 +1779,13 @@ function Ht({
|
|
|
1770
1779
|
);
|
|
1771
1780
|
}
|
|
1772
1781
|
export {
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1782
|
+
Tt as Group,
|
|
1783
|
+
$t as Panel,
|
|
1784
|
+
jt as Separator,
|
|
1785
|
+
_t as useDefaultLayout,
|
|
1786
|
+
Nt as useGroupCallbackRef,
|
|
1787
|
+
At as useGroupRef,
|
|
1788
|
+
Ft as usePanelCallbackRef,
|
|
1789
|
+
Ht as usePanelRef
|
|
1781
1790
|
};
|
|
1782
1791
|
//# sourceMappingURL=react-resizable-panels.js.map
|