react-panel-layout 0.4.1 → 0.4.2
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.
- package/README.md +291 -0
- package/dist/FloatingPanelFrame-SOrLGjZd.js +67 -0
- package/dist/FloatingPanelFrame-SOrLGjZd.js.map +1 -0
- package/dist/FloatingPanelFrame-XtBcHANI.cjs +2 -0
- package/dist/FloatingPanelFrame-XtBcHANI.cjs.map +1 -0
- package/dist/{GridLayout-DZCV1X-3.js → GridLayout-CLvW8jID.js} +516 -502
- package/dist/GridLayout-CLvW8jID.js.map +1 -0
- package/dist/GridLayout-qufTyOQM.cjs +2 -0
- package/dist/GridLayout-qufTyOQM.cjs.map +1 -0
- package/dist/components/pivot/PivotLayer.d.ts +14 -0
- package/dist/config/PanelContentDeclaration.d.ts +20 -0
- package/dist/config/panelRouter.d.ts +3 -1
- package/dist/config.cjs +1 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.js +125 -76
- package/dist/config.js.map +1 -1
- package/dist/constants/styles.d.ts +8 -0
- package/dist/floating.cjs +1 -1
- package/dist/floating.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +573 -500
- package/dist/index.js.map +1 -1
- package/dist/modules/panels/rendering/ContentRegistry.d.ts +50 -0
- package/dist/modules/panels/rendering/RenderContext.d.ts +1 -0
- package/dist/modules/panels/state/types.d.ts +2 -2
- package/dist/modules/pivot/PivotContent.d.ts +29 -0
- package/dist/modules/pivot/index.d.ts +5 -0
- package/dist/modules/pivot/types.d.ts +62 -0
- package/dist/modules/pivot/usePivot.d.ts +28 -0
- package/dist/pivot/index.d.ts +8 -0
- package/dist/pivot.cjs +2 -0
- package/dist/pivot.cjs.map +1 -0
- package/dist/pivot.js +5 -0
- package/dist/pivot.js.map +1 -0
- package/dist/styles-DcG3aIFx.cjs +2 -0
- package/dist/styles-DcG3aIFx.cjs.map +1 -0
- package/dist/styles-w0ZixggV.js +51 -0
- package/dist/styles-w0ZixggV.js.map +1 -0
- package/dist/types.d.ts +27 -0
- package/dist/usePivot-C8q0pMgW.cjs +2 -0
- package/dist/usePivot-C8q0pMgW.cjs.map +1 -0
- package/dist/usePivot-z9gumDf-.js +97 -0
- package/dist/usePivot-z9gumDf-.js.map +1 -0
- package/package.json +6 -1
- package/dist/FloatingPanelFrame-BeP9z8EI.js +0 -98
- package/dist/FloatingPanelFrame-BeP9z8EI.js.map +0 -1
- package/dist/FloatingPanelFrame-Cu50Y9xg.cjs +0 -2
- package/dist/FloatingPanelFrame-Cu50Y9xg.cjs.map +0 -1
- package/dist/GridLayout-CwuQEP7k.cjs +0 -2
- package/dist/GridLayout-CwuQEP7k.cjs.map +0 -1
- package/dist/GridLayout-DZCV1X-3.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import { D as
|
|
1
|
+
import { u as Dt, a as At, b as kt, c as J, d as Mt, e as M, t as _t, R as ot, G as st } from "./GridLayout-CLvW8jID.js";
|
|
2
|
+
import { D as Rr, f as Pr, r as Dr, g as Ar } from "./GridLayout-CLvW8jID.js";
|
|
3
3
|
import { jsx as m, jsxs as H, Fragment as et } from "react/jsx-runtime";
|
|
4
4
|
import * as l from "react";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import { t as Ot, u as Bt, v as Lt, H as Ht, y as Nt, z as $t, A as zt, B as Xt, E as Yt, I as Ft, T as jt, J as Kt, K as Vt, L as Ut, M as Wt, N as qt, O as Zt, S as Jt } from "./styles-w0ZixggV.js";
|
|
6
|
+
import { Q as Mr } from "./styles-w0ZixggV.js";
|
|
7
|
+
import { a as rt } from "./usePivot-z9gumDf-.js";
|
|
8
|
+
import { createPortal as Qt } from "react-dom";
|
|
9
|
+
const te = (t) => ({
|
|
10
|
+
width: Ht,
|
|
9
11
|
cursor: "col-resize",
|
|
10
12
|
position: "relative",
|
|
11
13
|
userSelect: "none",
|
|
12
|
-
backgroundColor: t === "drag" ?
|
|
13
|
-
}),
|
|
14
|
-
const { ref: n, isDragging: o, onPointerDown: s } =
|
|
14
|
+
backgroundColor: t === "drag" ? Ot : t === "hover" ? Bt : Lt
|
|
15
|
+
}), Tr = ({ onResize: t, component: e, element: r }) => {
|
|
16
|
+
const { ref: n, isDragging: o, onPointerDown: s } = Dt({
|
|
15
17
|
axis: "x",
|
|
16
18
|
onResize: t
|
|
17
19
|
}), [a, i] = l.useState(!1), c = {
|
|
18
20
|
ref: n,
|
|
19
|
-
style:
|
|
21
|
+
style: te(o ? "drag" : a ? "hover" : "idle"),
|
|
20
22
|
role: "separator",
|
|
21
23
|
"aria-orientation": "vertical",
|
|
22
24
|
"data-dragging": o ? "true" : void 0,
|
|
@@ -25,20 +27,20 @@ const Zt = (t) => ({
|
|
|
25
27
|
onPointerLeave: () => i(!1)
|
|
26
28
|
};
|
|
27
29
|
return r ? l.cloneElement(r, c) : e ? /* @__PURE__ */ m(e, { ...c }) : /* @__PURE__ */ m("div", { ...c });
|
|
28
|
-
},
|
|
29
|
-
const { layerId: t } =
|
|
30
|
+
}, xr = () => {
|
|
31
|
+
const { layerId: t } = At(), { getLayerHandleProps: e } = kt();
|
|
30
32
|
return l.useMemo(() => e(t), [e, t]);
|
|
31
|
-
},
|
|
32
|
-
const t = l.useContext(
|
|
33
|
+
}, dt = l.createContext(null), ee = () => {
|
|
34
|
+
const t = l.useContext(dt);
|
|
33
35
|
if (!t)
|
|
34
36
|
throw new Error("useKeybindings must be used within KeybindingsProvider");
|
|
35
37
|
return t;
|
|
36
|
-
},
|
|
38
|
+
}, re = (t) => {
|
|
37
39
|
const e = [];
|
|
38
40
|
t.metaKey && e.push("Mod"), t.ctrlKey && e.push("Ctrl"), t.altKey && e.push("Alt"), t.shiftKey && e.push("Shift");
|
|
39
41
|
const r = t.key.length === 1 ? t.key.toUpperCase() : t.key;
|
|
40
42
|
return e.push(r), e.join("-");
|
|
41
|
-
},
|
|
43
|
+
}, ne = ({ children: t, configure: e }) => {
|
|
42
44
|
const r = l.useRef({}), n = l.useCallback((a, i) => {
|
|
43
45
|
r.current = { ...r.current, [a]: i };
|
|
44
46
|
}, []), o = l.useCallback((a) => {
|
|
@@ -47,7 +49,7 @@ const Zt = (t) => ({
|
|
|
47
49
|
}, []);
|
|
48
50
|
l.useEffect(() => {
|
|
49
51
|
const a = (i) => {
|
|
50
|
-
const c =
|
|
52
|
+
const c = re(i), u = r.current[c];
|
|
51
53
|
u && u(i);
|
|
52
54
|
};
|
|
53
55
|
return window.addEventListener("keydown", a), () => {
|
|
@@ -57,8 +59,8 @@ const Zt = (t) => ({
|
|
|
57
59
|
const s = l.useMemo(() => ({ register: n, unregister: o }), [n, o]);
|
|
58
60
|
return l.useEffect(() => {
|
|
59
61
|
e && e(s);
|
|
60
|
-
}, [s, e]), /* @__PURE__ */ m(
|
|
61
|
-
},
|
|
62
|
+
}, [s, e]), /* @__PURE__ */ m(dt.Provider, { value: s, children: t });
|
|
63
|
+
}, oe = (t, e) => {
|
|
62
64
|
t.register("Mod-\\", (r) => {
|
|
63
65
|
r.preventDefault(), e.splitFocused("vertical");
|
|
64
66
|
}), t.register("Mod-Shift-\\", (r) => {
|
|
@@ -73,9 +75,9 @@ const Zt = (t) => ({
|
|
|
73
75
|
}), t.register("Alt-ArrowLeft", (r) => {
|
|
74
76
|
r.preventDefault(), e.focusPrevGroup();
|
|
75
77
|
});
|
|
76
|
-
},
|
|
78
|
+
}, se = (t) => t.type === "group", pt = (t, e = { x: 0, y: 0, w: 100, h: 100 }) => {
|
|
77
79
|
const r = /* @__PURE__ */ new Map(), n = (o, s) => {
|
|
78
|
-
if (
|
|
80
|
+
if (se(o)) {
|
|
79
81
|
r.set(o.groupId, s);
|
|
80
82
|
return;
|
|
81
83
|
}
|
|
@@ -88,8 +90,8 @@ const Zt = (t) => ({
|
|
|
88
90
|
n(o.a, { x: s.x, y: s.y, w: s.w, h: a }), n(o.b, { x: s.x, y: s.y + a, w: s.w, h: i });
|
|
89
91
|
};
|
|
90
92
|
return n(t, e), r;
|
|
91
|
-
},
|
|
92
|
-
const r =
|
|
93
|
+
}, ie = (t, e) => {
|
|
94
|
+
const r = pt(t.tree), n = {
|
|
93
95
|
areas: [["root"]],
|
|
94
96
|
rows: [{ size: "1fr" }],
|
|
95
97
|
columns: [{ size: "1fr" }],
|
|
@@ -114,41 +116,41 @@ const Zt = (t) => ({
|
|
|
114
116
|
};
|
|
115
117
|
});
|
|
116
118
|
return { config: n, layers: o };
|
|
117
|
-
},
|
|
118
|
-
const n =
|
|
119
|
-
for (const [
|
|
120
|
-
if (h >=
|
|
121
|
-
return
|
|
119
|
+
}, ae = (t, e, r) => {
|
|
120
|
+
const n = pt(t.tree), o = Array.from(new Set(Array.from(n.values()).flatMap((h) => [h.x, h.x + h.w]))).sort((h, w) => h - w), s = Array.from(new Set(Array.from(n.values()).flatMap((h) => [h.y, h.y + h.h]))).sort((h, w) => h - w), a = o.slice(1).map((h, w) => `${h - o[w]}fr`), i = s.slice(1).map((h, w) => `${h - s[w]}fr`), c = a.map((h) => ({ size: h, resizable: r })), u = i.map((h) => ({ size: h, resizable: r })), d = (h, w, I, T) => {
|
|
121
|
+
for (const [b, v] of n.entries())
|
|
122
|
+
if (h >= v.x && w <= v.x + v.w && I >= v.y && T <= v.y + v.h)
|
|
123
|
+
return b;
|
|
122
124
|
return ".";
|
|
123
|
-
},
|
|
125
|
+
}, f = [];
|
|
124
126
|
for (let h = 0; h < s.length - 1; h += 1) {
|
|
125
127
|
const w = [];
|
|
126
|
-
for (let
|
|
127
|
-
w.push(d(o[
|
|
128
|
-
|
|
128
|
+
for (let I = 0; I < o.length - 1; I += 1)
|
|
129
|
+
w.push(d(o[I], o[I + 1], s[h], s[h + 1]));
|
|
130
|
+
f.push(w);
|
|
129
131
|
}
|
|
130
|
-
const
|
|
131
|
-
areas:
|
|
132
|
+
const g = {
|
|
133
|
+
areas: f,
|
|
132
134
|
rows: u,
|
|
133
135
|
columns: c,
|
|
134
136
|
gap: "0px"
|
|
135
|
-
},
|
|
137
|
+
}, y = Array.from(n.keys()).map((h) => ({
|
|
136
138
|
id: h,
|
|
137
139
|
gridArea: h,
|
|
138
140
|
component: e(h)
|
|
139
141
|
}));
|
|
140
|
-
return { config:
|
|
141
|
-
},
|
|
142
|
-
const t = l.useContext(
|
|
142
|
+
return { config: g, layers: y };
|
|
143
|
+
}, ft = l.createContext(null), ce = () => {
|
|
144
|
+
const t = l.useContext(ft);
|
|
143
145
|
if (!t)
|
|
144
146
|
throw new Error("usePanelRenderContext must be used within PanelRenderProvider");
|
|
145
147
|
return t;
|
|
146
|
-
},
|
|
147
|
-
const t = l.useContext(
|
|
148
|
+
}, ue = ({ value: t, children: e }) => /* @__PURE__ */ m(ft.Provider, { value: t, children: e }), bt = l.createContext(null), gt = () => {
|
|
149
|
+
const t = l.useContext(bt);
|
|
148
150
|
if (!t)
|
|
149
151
|
throw new Error("useDomRegistry must be used within DomRegistryProvider");
|
|
150
152
|
return t;
|
|
151
|
-
},
|
|
153
|
+
}, le = ({ children: t }) => {
|
|
152
154
|
const e = l.useRef(/* @__PURE__ */ new Map()), r = l.useCallback((c) => {
|
|
153
155
|
const u = e.current.get(c);
|
|
154
156
|
if (u)
|
|
@@ -159,8 +161,8 @@ const Zt = (t) => ({
|
|
|
159
161
|
(c, u) => {
|
|
160
162
|
const d = r(c);
|
|
161
163
|
if (d.group = u, u === null) {
|
|
162
|
-
const
|
|
163
|
-
(
|
|
164
|
+
const f = e.current.get(c);
|
|
165
|
+
(f ? f.tabbar === null && f.content === null : !1) && e.current.delete(c);
|
|
164
166
|
}
|
|
165
167
|
},
|
|
166
168
|
[r]
|
|
@@ -168,8 +170,8 @@ const Zt = (t) => ({
|
|
|
168
170
|
(c, u) => {
|
|
169
171
|
const d = r(c);
|
|
170
172
|
if (d.tabbar = u, u === null) {
|
|
171
|
-
const
|
|
172
|
-
(
|
|
173
|
+
const f = e.current.get(c);
|
|
174
|
+
(f ? f.group === null && f.content === null : !1) && e.current.delete(c);
|
|
173
175
|
}
|
|
174
176
|
},
|
|
175
177
|
[r]
|
|
@@ -177,32 +179,32 @@ const Zt = (t) => ({
|
|
|
177
179
|
(c, u) => {
|
|
178
180
|
const d = r(c);
|
|
179
181
|
if (d.content = u, u === null) {
|
|
180
|
-
const
|
|
181
|
-
(
|
|
182
|
+
const f = e.current.get(c);
|
|
183
|
+
(f ? f.group === null && f.tabbar === null : !1) && e.current.delete(c);
|
|
182
184
|
}
|
|
183
185
|
},
|
|
184
186
|
[r]
|
|
185
187
|
), a = l.useCallback(() => e.current, []), i = l.useMemo(() => ({ setGroupEl: n, setTabbarEl: o, setContentEl: s, getAll: a }), [n, o, s, a]);
|
|
186
|
-
return /* @__PURE__ */ m(
|
|
187
|
-
},
|
|
188
|
+
return /* @__PURE__ */ m(bt.Provider, { value: i, children: t });
|
|
189
|
+
}, de = {
|
|
188
190
|
display: "flex",
|
|
189
191
|
flexDirection: "column",
|
|
190
192
|
width: "100%",
|
|
191
193
|
height: "100%"
|
|
192
|
-
},
|
|
194
|
+
}, pe = {
|
|
193
195
|
flex: "1 1 auto",
|
|
194
196
|
minWidth: 0,
|
|
195
197
|
minHeight: 0,
|
|
196
198
|
position: "relative",
|
|
197
199
|
overflow: "hidden"
|
|
198
200
|
};
|
|
199
|
-
function
|
|
201
|
+
function fe(t, e, r, n) {
|
|
200
202
|
return t ? l.cloneElement(t, r, n) : e ? /* @__PURE__ */ m(e, { ...r, children: n }) : /* @__PURE__ */ m("div", { ...r, children: n });
|
|
201
203
|
}
|
|
202
|
-
function
|
|
204
|
+
function be(t, e, r, n) {
|
|
203
205
|
return t ? l.cloneElement(t, r, n) : e ? /* @__PURE__ */ m(e, { ...r, children: n }) : /* @__PURE__ */ m("div", { ...r, children: n });
|
|
204
206
|
}
|
|
205
|
-
const
|
|
207
|
+
const ge = ({
|
|
206
208
|
group: t,
|
|
207
209
|
tabbar: e,
|
|
208
210
|
content: r,
|
|
@@ -216,21 +218,21 @@ const pe = ({
|
|
|
216
218
|
}) => {
|
|
217
219
|
const d = {
|
|
218
220
|
ref: o,
|
|
219
|
-
style:
|
|
221
|
+
style: de,
|
|
220
222
|
"data-group-id": t.id
|
|
221
|
-
},
|
|
223
|
+
}, g = fe(u, c, {
|
|
222
224
|
ref: s,
|
|
223
|
-
style:
|
|
225
|
+
style: pe,
|
|
224
226
|
"data-dnd-zone": "content",
|
|
225
227
|
onPointerDown: n
|
|
226
228
|
}, r);
|
|
227
|
-
return
|
|
229
|
+
return be(i, a, d, /* @__PURE__ */ H(et, { children: [
|
|
228
230
|
e,
|
|
229
|
-
|
|
231
|
+
g
|
|
230
232
|
] }));
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
const
|
|
233
|
+
}, ht = l.memo(ge, (t, e) => t.group.id !== e.group.id || t.group.activeTabId !== e.group.activeTabId || t.group.tabs.length !== e.group.tabs.length ? !1 : t.group.tabs === e.group.tabs);
|
|
234
|
+
ht.displayName = "PanelGroupView";
|
|
235
|
+
const K = (t, e, r) => {
|
|
234
236
|
const n = t.left, o = t.top, s = t.width, a = t.height, i = e - n, c = r - o, u = s / 3, d = a / 3;
|
|
235
237
|
return i > u && i < s - u && c > d && c < a - d ? "center" : i < c && i < s - i && c < a - c ? "left" : s - i < c && s - i < i && c < a - c ? "right" : c < i && c < a - c && i < s - i ? "top" : "bottom";
|
|
236
238
|
};
|
|
@@ -253,7 +255,7 @@ function A(t, e) {
|
|
|
253
255
|
enumerable: !0
|
|
254
256
|
}), r;
|
|
255
257
|
}
|
|
256
|
-
const
|
|
258
|
+
const he = (t, e) => {
|
|
257
259
|
const r = {};
|
|
258
260
|
return Object.keys(t).forEach((n) => {
|
|
259
261
|
const o = t[n];
|
|
@@ -262,7 +264,7 @@ const fe = (t, e) => {
|
|
|
262
264
|
return e(a), a;
|
|
263
265
|
});
|
|
264
266
|
}), r;
|
|
265
|
-
},
|
|
267
|
+
}, mt = (t, e) => {
|
|
266
268
|
const r = {};
|
|
267
269
|
return Object.keys(e).forEach((n) => {
|
|
268
270
|
const o = e[n];
|
|
@@ -273,7 +275,7 @@ const fe = (t, e) => {
|
|
|
273
275
|
throw new Error(`Missing action creator for key "${String(n)}"`);
|
|
274
276
|
r[s.type] = o;
|
|
275
277
|
}), r;
|
|
276
|
-
},
|
|
278
|
+
}, vt = { phase: { kind: "idle" }, suggest: null, pointer: null, tabbarHover: null, draggingTabElement: null }, D = {
|
|
277
279
|
startContent: A(
|
|
278
280
|
"START_CONTENT",
|
|
279
281
|
(t) => t
|
|
@@ -289,7 +291,7 @@ const fe = (t, e) => {
|
|
|
289
291
|
(t) => t
|
|
290
292
|
),
|
|
291
293
|
reset: A("RESET")
|
|
292
|
-
},
|
|
294
|
+
}, me = mt(D, {
|
|
293
295
|
startContent: (t, e) => ({
|
|
294
296
|
phase: {
|
|
295
297
|
kind: "content",
|
|
@@ -321,16 +323,16 @@ const fe = (t, e) => {
|
|
|
321
323
|
setSuggest: (t, e) => ({ ...t, suggest: e.payload }),
|
|
322
324
|
setPointer: (t, e) => ({ ...t, pointer: e.payload }),
|
|
323
325
|
setTabbarHover: (t, e) => ({ ...t, tabbarHover: e.payload }),
|
|
324
|
-
reset: () =>
|
|
325
|
-
}),
|
|
326
|
-
const r =
|
|
326
|
+
reset: () => vt
|
|
327
|
+
}), ve = (t, e) => {
|
|
328
|
+
const r = me[e.type];
|
|
327
329
|
return r ? r(t, e, void 0) : t;
|
|
328
|
-
},
|
|
329
|
-
const t = l.useContext(
|
|
330
|
+
}, It = l.createContext(null), W = () => {
|
|
331
|
+
const t = l.useContext(It);
|
|
330
332
|
if (!t)
|
|
331
333
|
throw new Error("usePanelInteractions must be used within InteractionsProvider");
|
|
332
334
|
return t;
|
|
333
|
-
},
|
|
335
|
+
}, Ie = ({
|
|
334
336
|
containerRef: t,
|
|
335
337
|
dragThresholdPx: e,
|
|
336
338
|
onCommitContentDrop: r,
|
|
@@ -338,122 +340,122 @@ const fe = (t, e) => {
|
|
|
338
340
|
isContentZoneAllowed: o,
|
|
339
341
|
children: s
|
|
340
342
|
}) => {
|
|
341
|
-
const [a, i] = l.useReducer(
|
|
342
|
-
const
|
|
343
|
-
return { groups:
|
|
344
|
-
}, [c]), d = J((
|
|
343
|
+
const [a, i] = l.useReducer(ve, vt), c = gt(), u = l.useCallback(() => {
|
|
344
|
+
const I = Array.from(c.getAll().entries()), T = I.map(([p, x]) => ({ gid: p, el: x.content ?? x.group })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() })), b = I.map(([p, x]) => ({ gid: p, el: x.tabbar })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() })), v = I.map(([p, x]) => ({ gid: p, el: x.content ?? x.group })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() }));
|
|
345
|
+
return { groups: T, tabbars: b, contents: v };
|
|
346
|
+
}, [c]), d = J((I) => {
|
|
345
347
|
if (!t.current)
|
|
346
348
|
return;
|
|
347
|
-
const
|
|
349
|
+
const b = I.clientX, v = I.clientY, p = a.phase;
|
|
348
350
|
if (p.kind === "idle")
|
|
349
351
|
return;
|
|
350
|
-
const
|
|
351
|
-
if (
|
|
352
|
+
const x = Math.abs(b - p.startX), E = Math.abs(v - p.startY);
|
|
353
|
+
if (x < e && E < e) {
|
|
352
354
|
a.phase.kind === "content" && i(D.setSuggest(null)), i(D.setPointer(null)), i(D.setTabbarHover(null));
|
|
353
355
|
return;
|
|
354
356
|
}
|
|
355
|
-
if (i(D.setPointer({ x:
|
|
356
|
-
const S = p.cache.groups.find(({ rect:
|
|
357
|
+
if (i(D.setPointer({ x: b, y: v })), p.kind === "content") {
|
|
358
|
+
const S = p.cache.groups.find(({ rect: G }) => b >= G.left && b <= G.right && v >= G.top && v <= G.bottom);
|
|
357
359
|
if (!S) {
|
|
358
360
|
i(D.setSuggest(null));
|
|
359
361
|
return;
|
|
360
362
|
}
|
|
361
|
-
const
|
|
362
|
-
if (o && !o({ targetGroupId: S.gid, zone:
|
|
363
|
+
const R = K(S.rect, b, v);
|
|
364
|
+
if (o && !o({ targetGroupId: S.gid, zone: R })) {
|
|
363
365
|
i(D.setSuggest(null));
|
|
364
366
|
return;
|
|
365
367
|
}
|
|
366
|
-
i(D.setSuggest({ rect: S.rect, zone:
|
|
368
|
+
i(D.setSuggest({ rect: S.rect, zone: R }));
|
|
367
369
|
return;
|
|
368
370
|
}
|
|
369
371
|
if (p.kind === "tab") {
|
|
370
|
-
const S = p.cache.tabbars.find(({ rect:
|
|
372
|
+
const S = p.cache.tabbars.find(({ rect: C }) => b >= C.left && b <= C.right && v >= C.top && v <= C.bottom);
|
|
371
373
|
if (S) {
|
|
372
|
-
const k = Array.from(S.el.querySelectorAll("[role='tab']")).map((
|
|
373
|
-
i(D.setTabbarHover({ groupId: S.gid, index: B, rect: S.rect, insertX:
|
|
374
|
+
const k = Array.from(S.el.querySelectorAll("[role='tab']")).map(($) => $.getBoundingClientRect()), P = k.map(($) => $.left + $.width / 2), O = P.findIndex(($) => b < $), B = O === -1 ? P.length : O, Pt = k.length === 0 ? S.rect.left + 8 : B === 0 ? k[0].left : B === k.length ? k[k.length - 1].right : (k[B - 1].right + k[B].left) / 2;
|
|
375
|
+
i(D.setTabbarHover({ groupId: S.gid, index: B, rect: S.rect, insertX: Pt }));
|
|
374
376
|
} else
|
|
375
377
|
i(D.setTabbarHover(null));
|
|
376
|
-
const
|
|
377
|
-
if (!
|
|
378
|
+
const R = p.cache.contents.find(({ rect: C }) => b >= C.left && b <= C.right && v >= C.top && v <= C.bottom);
|
|
379
|
+
if (!R) {
|
|
378
380
|
i(D.setSuggest(null));
|
|
379
381
|
return;
|
|
380
382
|
}
|
|
381
|
-
const
|
|
382
|
-
if (o && !o({ targetGroupId:
|
|
383
|
+
const G = K(R.rect, b, v);
|
|
384
|
+
if (o && !o({ targetGroupId: R.gid, zone: G })) {
|
|
383
385
|
i(D.setSuggest(null));
|
|
384
386
|
return;
|
|
385
387
|
}
|
|
386
|
-
i(D.setSuggest({ rect:
|
|
388
|
+
i(D.setSuggest({ rect: R.rect, zone: G }));
|
|
387
389
|
}
|
|
388
|
-
}),
|
|
389
|
-
const
|
|
390
|
-
if (i(D.reset()), !
|
|
390
|
+
}), f = J((I) => {
|
|
391
|
+
const T = t.current, b = a;
|
|
392
|
+
if (i(D.reset()), !T)
|
|
391
393
|
return;
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
+
const v = I.clientX, p = I.clientY;
|
|
395
|
+
if (b.phase.kind === "idle")
|
|
394
396
|
return;
|
|
395
|
-
const
|
|
396
|
-
if (!(
|
|
397
|
-
if (
|
|
398
|
-
const S =
|
|
397
|
+
const x = Math.abs(v - b.phase.startX), E = Math.abs(p - b.phase.startY);
|
|
398
|
+
if (!(x < e && E < e)) {
|
|
399
|
+
if (b.phase.kind === "content") {
|
|
400
|
+
const S = b.phase.cache.groups.find(({ rect: C }) => v >= C.left && v <= C.right && p >= C.top && p <= C.bottom);
|
|
399
401
|
if (!S)
|
|
400
402
|
return;
|
|
401
|
-
const
|
|
402
|
-
if (!
|
|
403
|
+
const R = S.gid ?? null;
|
|
404
|
+
if (!R)
|
|
403
405
|
return;
|
|
404
|
-
const
|
|
405
|
-
if (o && !o({ targetGroupId:
|
|
406
|
+
const G = K(S.rect, v, p);
|
|
407
|
+
if (o && !o({ targetGroupId: R, zone: G }))
|
|
406
408
|
return;
|
|
407
|
-
r({ fromGroupId:
|
|
409
|
+
r({ fromGroupId: b.phase.fromGroupId, tabId: b.phase.tabId, targetGroupId: R, zone: G });
|
|
408
410
|
return;
|
|
409
411
|
}
|
|
410
|
-
if (
|
|
411
|
-
const S =
|
|
412
|
+
if (b.phase.kind === "tab") {
|
|
413
|
+
const S = b.phase.cache.tabbars.find(({ rect: G }) => v >= G.left && v <= G.right && p >= G.top && p <= G.bottom);
|
|
412
414
|
if (S) {
|
|
413
|
-
const
|
|
414
|
-
if (!
|
|
415
|
+
const G = S.gid;
|
|
416
|
+
if (!G)
|
|
415
417
|
return;
|
|
416
418
|
const k = Array.from(S.el.querySelectorAll("[role='tab']")).map((B) => {
|
|
417
419
|
const Z = B.getBoundingClientRect();
|
|
418
420
|
return Z.left + Z.width / 2;
|
|
419
|
-
}),
|
|
420
|
-
n({ fromGroupId:
|
|
421
|
+
}), P = k.findIndex((B) => v < B), O = P === -1 ? k.length : P;
|
|
422
|
+
n({ fromGroupId: b.phase.fromGroupId, tabId: b.phase.tabId, targetGroupId: G, targetIndex: O });
|
|
421
423
|
return;
|
|
422
424
|
}
|
|
423
|
-
const
|
|
424
|
-
if (
|
|
425
|
-
const
|
|
426
|
-
if (!
|
|
425
|
+
const R = b.phase.cache.contents.find(({ rect: G }) => v >= G.left && v <= G.right && p >= G.top && p <= G.bottom);
|
|
426
|
+
if (R) {
|
|
427
|
+
const G = R.gid ?? null;
|
|
428
|
+
if (!G)
|
|
427
429
|
return;
|
|
428
|
-
const
|
|
429
|
-
if (o && !o({ targetGroupId:
|
|
430
|
+
const C = K(R.rect, v, p);
|
|
431
|
+
if (o && !o({ targetGroupId: G, zone: C }))
|
|
430
432
|
return;
|
|
431
|
-
r({ fromGroupId:
|
|
433
|
+
r({ fromGroupId: b.phase.fromGroupId, tabId: b.phase.tabId, targetGroupId: G, zone: C });
|
|
432
434
|
}
|
|
433
435
|
}
|
|
434
436
|
}
|
|
435
|
-
}),
|
|
437
|
+
}), g = J(() => {
|
|
436
438
|
i(D.reset());
|
|
437
439
|
});
|
|
438
440
|
l.useEffect(() => {
|
|
439
441
|
if (a.phase.kind !== "idle")
|
|
440
|
-
return window.addEventListener("pointermove", d), window.addEventListener("pointerup",
|
|
441
|
-
window.removeEventListener("pointermove", d), window.removeEventListener("pointerup",
|
|
442
|
+
return window.addEventListener("pointermove", d), window.addEventListener("pointerup", f, { once: !0 }), window.addEventListener("pointercancel", g, { once: !0 }), () => {
|
|
443
|
+
window.removeEventListener("pointermove", d), window.removeEventListener("pointerup", f), window.removeEventListener("pointercancel", g);
|
|
442
444
|
};
|
|
443
445
|
}, [a.phase.kind]);
|
|
444
|
-
const
|
|
445
|
-
if (
|
|
446
|
+
const y = l.useCallback((I, T, b) => {
|
|
447
|
+
if (b.button !== 0)
|
|
446
448
|
return;
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
i(D.startContent({ x:
|
|
450
|
-
}, [u]), h = l.useCallback((
|
|
451
|
-
if (
|
|
449
|
+
b.currentTarget.setPointerCapture(b.pointerId);
|
|
450
|
+
const v = u();
|
|
451
|
+
i(D.startContent({ x: b.clientX, y: b.clientY, groupId: I, tabId: T, cache: v }));
|
|
452
|
+
}, [u]), h = l.useCallback((I, T, b) => {
|
|
453
|
+
if (b.button !== 0)
|
|
452
454
|
return;
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
+
const v = b.currentTarget;
|
|
456
|
+
v && v.setPointerCapture(b.pointerId);
|
|
455
457
|
const p = u();
|
|
456
|
-
i(D.startTab({ x:
|
|
458
|
+
i(D.startTab({ x: b.clientX, y: b.clientY, groupId: T, tabId: I, cache: p, element: v }));
|
|
457
459
|
}, [u]), w = l.useMemo(() => ({
|
|
458
460
|
suggest: a.suggest,
|
|
459
461
|
isTabDragging: a.phase.kind === "tab",
|
|
@@ -461,15 +463,15 @@ const fe = (t, e) => {
|
|
|
461
463
|
dragPointer: a.pointer,
|
|
462
464
|
tabbarHover: a.tabbarHover,
|
|
463
465
|
draggingTabElement: a.draggingTabElement,
|
|
464
|
-
onStartContentDrag:
|
|
466
|
+
onStartContentDrag: y,
|
|
465
467
|
onStartTabDrag: h
|
|
466
|
-
}), [a.suggest, a.pointer, a.tabbarHover, a.phase, a.draggingTabElement,
|
|
467
|
-
return /* @__PURE__ */ m(
|
|
468
|
-
},
|
|
468
|
+
}), [a.suggest, a.pointer, a.tabbarHover, a.phase, a.draggingTabElement, y, h]);
|
|
469
|
+
return /* @__PURE__ */ m(It.Provider, { value: w, children: s });
|
|
470
|
+
}, it = {
|
|
469
471
|
display: "inline-flex",
|
|
470
472
|
alignItems: "center",
|
|
471
473
|
userSelect: "none"
|
|
472
|
-
},
|
|
474
|
+
}, we = ({
|
|
473
475
|
groupId: t,
|
|
474
476
|
tab: e,
|
|
475
477
|
active: r,
|
|
@@ -483,17 +485,17 @@ const fe = (t, e) => {
|
|
|
483
485
|
}) => {
|
|
484
486
|
const d = l.useEffectEvent(() => {
|
|
485
487
|
o(e.id);
|
|
486
|
-
}),
|
|
488
|
+
}), f = l.useEffectEvent((w) => {
|
|
487
489
|
s && w.button === 0 && s(e.id, t, w);
|
|
488
|
-
}),
|
|
490
|
+
}), g = () => {
|
|
489
491
|
const w = !!a;
|
|
490
492
|
return /* @__PURE__ */ m(l.Activity, { mode: w ? "visible" : "hidden", children: /* @__PURE__ */ m(
|
|
491
493
|
"button",
|
|
492
494
|
{
|
|
493
495
|
type: "button",
|
|
494
496
|
"aria-label": `Close tab ${e.title}`,
|
|
495
|
-
onClick: (
|
|
496
|
-
a && (
|
|
497
|
+
onClick: (I) => {
|
|
498
|
+
a && (I.stopPropagation(), a(t, e.id));
|
|
497
499
|
},
|
|
498
500
|
style: { marginLeft: 6 },
|
|
499
501
|
tabIndex: w ? void 0 : -1,
|
|
@@ -502,27 +504,27 @@ const fe = (t, e) => {
|
|
|
502
504
|
children: "×"
|
|
503
505
|
}
|
|
504
506
|
) });
|
|
505
|
-
},
|
|
507
|
+
}, y = {
|
|
506
508
|
role: "tab",
|
|
507
509
|
"aria-selected": r,
|
|
508
510
|
tabIndex: r ? 0 : -1,
|
|
509
|
-
style:
|
|
511
|
+
style: it,
|
|
510
512
|
onClick: d,
|
|
511
|
-
onPointerDown:
|
|
513
|
+
onPointerDown: f,
|
|
512
514
|
onDoubleClick: u,
|
|
513
515
|
"data-tab-id": e.id,
|
|
514
516
|
"data-active": r ? "true" : "false",
|
|
515
517
|
"data-dragging": n ? "true" : "false",
|
|
516
518
|
children: /* @__PURE__ */ H(et, { children: [
|
|
517
519
|
/* @__PURE__ */ m("span", { children: e.title }),
|
|
518
|
-
|
|
520
|
+
g()
|
|
519
521
|
] })
|
|
520
522
|
}, h = {
|
|
521
523
|
type: "button",
|
|
522
524
|
role: "tab",
|
|
523
525
|
"aria-selected": r,
|
|
524
526
|
tabIndex: r ? 0 : -1,
|
|
525
|
-
style:
|
|
527
|
+
style: it,
|
|
526
528
|
onClick: () => {
|
|
527
529
|
o(e.id);
|
|
528
530
|
},
|
|
@@ -532,14 +534,14 @@ const fe = (t, e) => {
|
|
|
532
534
|
onDoubleClick: u,
|
|
533
535
|
children: /* @__PURE__ */ m("span", { children: e.title })
|
|
534
536
|
};
|
|
535
|
-
return c ? c(h) : i ? /* @__PURE__ */ m(i, { ...h }) : /* @__PURE__ */ m("div", { ...
|
|
536
|
-
},
|
|
537
|
+
return c ? c(h) : i ? /* @__PURE__ */ m(i, { ...h }) : /* @__PURE__ */ m("div", { ...y });
|
|
538
|
+
}, ye = {
|
|
537
539
|
display: "flex",
|
|
538
540
|
alignItems: "center"
|
|
539
|
-
},
|
|
541
|
+
}, Te = {
|
|
540
542
|
flex: "1 1 auto",
|
|
541
543
|
alignSelf: "stretch"
|
|
542
|
-
},
|
|
544
|
+
}, xe = ({
|
|
543
545
|
group: t,
|
|
544
546
|
onClickTab: e,
|
|
545
547
|
onStartDrag: r,
|
|
@@ -552,9 +554,9 @@ const fe = (t, e) => {
|
|
|
552
554
|
onCloseTab: u,
|
|
553
555
|
doubleClickToAdd: d
|
|
554
556
|
}) => {
|
|
555
|
-
const { isTabDragging:
|
|
557
|
+
const { isTabDragging: f, draggingTabId: g } = W(), y = l.useRef(null), h = l.useCallback(
|
|
556
558
|
(p) => {
|
|
557
|
-
if (
|
|
559
|
+
if (y.current = p, !!n) {
|
|
558
560
|
if (typeof n == "function") {
|
|
559
561
|
n(p);
|
|
560
562
|
return;
|
|
@@ -567,26 +569,26 @@ const fe = (t, e) => {
|
|
|
567
569
|
},
|
|
568
570
|
[n]
|
|
569
571
|
), w = l.useEffectEvent((p) => {
|
|
570
|
-
const
|
|
571
|
-
if (!
|
|
572
|
+
const x = y.current ?? p.currentTarget;
|
|
573
|
+
if (!x)
|
|
572
574
|
return;
|
|
573
|
-
const E = Array.from(
|
|
575
|
+
const E = Array.from(x.querySelectorAll('[role="tab"]'));
|
|
574
576
|
if (E.length === 0)
|
|
575
577
|
return;
|
|
576
|
-
const S = (
|
|
577
|
-
const O = Math.max(0, Math.min(
|
|
578
|
+
const S = (P) => {
|
|
579
|
+
const O = Math.max(0, Math.min(P, E.length - 1)), B = E[O];
|
|
578
580
|
B && B.focus();
|
|
579
|
-
},
|
|
581
|
+
}, R = document.activeElement, G = R ? E.indexOf(R) : E.findIndex((P) => P.getAttribute("data-tab-id") === t.activeTabId);
|
|
580
582
|
if (p.key === "ArrowRight") {
|
|
581
583
|
p.preventDefault();
|
|
582
|
-
const
|
|
583
|
-
S(
|
|
584
|
+
const P = G >= 0 ? G + 1 : 0;
|
|
585
|
+
S(P >= E.length ? 0 : P);
|
|
584
586
|
return;
|
|
585
587
|
}
|
|
586
588
|
if (p.key === "ArrowLeft") {
|
|
587
589
|
p.preventDefault();
|
|
588
|
-
const
|
|
589
|
-
S(
|
|
590
|
+
const P = G >= 0 ? G - 1 : E.length - 1;
|
|
591
|
+
S(P < 0 ? E.length - 1 : P);
|
|
590
592
|
return;
|
|
591
593
|
}
|
|
592
594
|
if (p.key === "Home") {
|
|
@@ -599,44 +601,44 @@ const fe = (t, e) => {
|
|
|
599
601
|
}
|
|
600
602
|
if (p.key === "Enter" || p.key === " ") {
|
|
601
603
|
p.preventDefault();
|
|
602
|
-
const O = (
|
|
604
|
+
const O = (G >= 0 ? E[G] : null)?.getAttribute("data-tab-id") ?? null;
|
|
603
605
|
O && e(O);
|
|
604
606
|
return;
|
|
605
607
|
}
|
|
606
608
|
if (p.key === "Delete" || p.key === "Backspace") {
|
|
607
609
|
if (u) {
|
|
608
610
|
p.preventDefault();
|
|
609
|
-
const O = (
|
|
611
|
+
const O = (G >= 0 ? E[G] : null)?.getAttribute("data-tab-id") ?? null;
|
|
610
612
|
O && u(t.id, O);
|
|
611
613
|
}
|
|
612
614
|
return;
|
|
613
615
|
}
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
616
|
+
const C = (p.ctrlKey ? 1 : 0) + (p.metaKey ? 1 : 0) > 0, k = typeof p.key == "string" ? p.key.toLowerCase() : "";
|
|
617
|
+
if (C && k === "t") {
|
|
616
618
|
c && (p.preventDefault(), c(t.id));
|
|
617
619
|
return;
|
|
618
620
|
}
|
|
619
621
|
});
|
|
620
622
|
l.useEffect(() => {
|
|
621
|
-
const p =
|
|
623
|
+
const p = y.current;
|
|
622
624
|
if (!p)
|
|
623
625
|
return;
|
|
624
|
-
const
|
|
625
|
-
if (
|
|
626
|
+
const x = p.querySelector(`[role="tab"][data-tab-id="${t.activeTabId}"]`);
|
|
627
|
+
if (x === document.activeElement)
|
|
626
628
|
return;
|
|
627
|
-
!p.contains(document.activeElement) &&
|
|
629
|
+
!p.contains(document.activeElement) && x && x.focus();
|
|
628
630
|
}, [t.activeTabId]);
|
|
629
|
-
const
|
|
630
|
-
style:
|
|
631
|
+
const I = {
|
|
632
|
+
style: ye,
|
|
631
633
|
role: "tablist",
|
|
632
634
|
"data-tabbar": "true",
|
|
633
635
|
"data-group-id": t.id,
|
|
634
|
-
"data-dragging":
|
|
636
|
+
"data-dragging": f ? "true" : "false",
|
|
635
637
|
onKeyDown: w
|
|
636
|
-
},
|
|
638
|
+
}, T = Mt({
|
|
637
639
|
element: s,
|
|
638
640
|
component: o
|
|
639
|
-
}),
|
|
641
|
+
}), b = () => c ? /* @__PURE__ */ m(
|
|
640
642
|
"button",
|
|
641
643
|
{
|
|
642
644
|
type: "button",
|
|
@@ -646,17 +648,17 @@ const fe = (t, e) => {
|
|
|
646
648
|
},
|
|
647
649
|
children: "+"
|
|
648
650
|
}
|
|
649
|
-
) : null,
|
|
651
|
+
) : null, v = l.useCallback(() => {
|
|
650
652
|
d && c && c(t.id);
|
|
651
653
|
}, [d, c, t.id]);
|
|
652
|
-
return /* @__PURE__ */ H(
|
|
653
|
-
t.tabs.map((p,
|
|
654
|
-
|
|
654
|
+
return /* @__PURE__ */ H(T, { ...I, ref: h, onDoubleClick: v, children: [
|
|
655
|
+
t.tabs.map((p, x) => /* @__PURE__ */ m(
|
|
656
|
+
we,
|
|
655
657
|
{
|
|
656
658
|
groupId: t.id,
|
|
657
659
|
tab: p,
|
|
658
660
|
active: t.activeTabId === p.id,
|
|
659
|
-
dragging:
|
|
661
|
+
dragging: g === p.id,
|
|
660
662
|
onClickTab: e,
|
|
661
663
|
onStartDrag: r,
|
|
662
664
|
onCloseTab: u,
|
|
@@ -664,65 +666,64 @@ const fe = (t, e) => {
|
|
|
664
666
|
tabElement: i,
|
|
665
667
|
onDoubleClick: (E) => E.stopPropagation()
|
|
666
668
|
},
|
|
667
|
-
`${t.id}:${p.id}:${
|
|
669
|
+
`${t.id}:${p.id}:${x}`
|
|
668
670
|
)),
|
|
669
|
-
/* @__PURE__ */ m("span", { style:
|
|
670
|
-
|
|
671
|
+
/* @__PURE__ */ m("span", { style: Te }),
|
|
672
|
+
b()
|
|
671
673
|
] });
|
|
672
|
-
},
|
|
673
|
-
const { getGroup: n, getGroupContent: o, onClickTab: s, onAddTab: a, onCloseTab: i,
|
|
674
|
-
(
|
|
675
|
-
|
|
674
|
+
}, Ge = ({ id: t, TabBarComponent: e, PanelGroupComponent: r }) => {
|
|
675
|
+
const { getGroup: n, getGroupContent: o, onClickTab: s, onAddTab: a, onCloseTab: i, onStartTabDrag: c, doubleClickToAdd: u, registerContentContainer: d } = ce(), { setGroupEl: f, setTabbarEl: g, setContentEl: y } = gt(), h = l.useCallback(
|
|
676
|
+
(x) => {
|
|
677
|
+
f(t, x);
|
|
676
678
|
},
|
|
677
|
-
[t,
|
|
679
|
+
[t, f]
|
|
678
680
|
), w = l.useCallback(
|
|
679
|
-
(
|
|
680
|
-
|
|
681
|
+
(x) => {
|
|
682
|
+
y(t, x), d(t, x);
|
|
681
683
|
},
|
|
682
|
-
[t,
|
|
683
|
-
),
|
|
684
|
-
(
|
|
685
|
-
|
|
684
|
+
[t, y, d]
|
|
685
|
+
), I = l.useCallback(
|
|
686
|
+
(x) => {
|
|
687
|
+
g(t, x);
|
|
686
688
|
},
|
|
687
|
-
[t,
|
|
688
|
-
),
|
|
689
|
-
if (!
|
|
689
|
+
[t, g]
|
|
690
|
+
), T = n(t);
|
|
691
|
+
if (!T)
|
|
690
692
|
return null;
|
|
691
|
-
const
|
|
693
|
+
const b = o(t);
|
|
692
694
|
return /* @__PURE__ */ m(
|
|
693
|
-
r ?? ((
|
|
695
|
+
r ?? ((x) => /* @__PURE__ */ m(ht, { ...x })),
|
|
694
696
|
{
|
|
695
|
-
group:
|
|
697
|
+
group: T,
|
|
696
698
|
tabbar: /* @__PURE__ */ m(
|
|
697
|
-
e ??
|
|
699
|
+
e ?? xe,
|
|
698
700
|
{
|
|
699
|
-
rootRef:
|
|
700
|
-
group:
|
|
701
|
-
onClickTab: (
|
|
701
|
+
rootRef: I,
|
|
702
|
+
group: T,
|
|
703
|
+
onClickTab: (x) => s(t, x),
|
|
702
704
|
onAddTab: a,
|
|
703
705
|
onCloseTab: i,
|
|
704
|
-
onStartDrag: (
|
|
705
|
-
doubleClickToAdd:
|
|
706
|
+
onStartDrag: (x, E, S) => c(x, E, S),
|
|
707
|
+
doubleClickToAdd: u
|
|
706
708
|
}
|
|
707
709
|
),
|
|
708
|
-
content:
|
|
710
|
+
content: b,
|
|
709
711
|
groupRef: h,
|
|
710
|
-
contentRef: w
|
|
711
|
-
onContentPointerDown: (G) => c(t, G)
|
|
712
|
+
contentRef: w
|
|
712
713
|
}
|
|
713
714
|
);
|
|
714
|
-
},
|
|
715
|
+
}, Se = (t, e) => {
|
|
715
716
|
const r = new Array(16);
|
|
716
717
|
for (let n = 0; n < 4; n++)
|
|
717
718
|
for (let o = 0; o < 4; o++)
|
|
718
719
|
r[n * 4 + o] = t[0 + o] * e[n * 4 + 0] + t[4 + o] * e[n * 4 + 1] + t[8 + o] * e[n * 4 + 2] + t[12 + o] * e[n * 4 + 3];
|
|
719
720
|
return r;
|
|
720
|
-
},
|
|
721
|
+
}, V = (t) => {
|
|
721
722
|
if (t.length !== 16)
|
|
722
723
|
throw new Error("Matrix must have exactly 16 values");
|
|
723
724
|
const e = Object.freeze([...t]), r = (n) => {
|
|
724
|
-
const o =
|
|
725
|
-
return
|
|
725
|
+
const o = Se(e, n);
|
|
726
|
+
return V(o);
|
|
726
727
|
};
|
|
727
728
|
return Object.freeze({
|
|
728
729
|
translate: (n = 0, o = 0, s = 0) => r([
|
|
@@ -971,7 +972,7 @@ const fe = (t, e) => {
|
|
|
971
972
|
rotate: (n, o, s, a) => {
|
|
972
973
|
const i = Math.sqrt(o * o + s * s + a * a);
|
|
973
974
|
if (i === 0)
|
|
974
|
-
return
|
|
975
|
+
return V(e);
|
|
975
976
|
o /= i, s /= i, a /= i;
|
|
976
977
|
const c = Math.cos(n), u = Math.sin(n), d = 1 - c;
|
|
977
978
|
return r([
|
|
@@ -996,7 +997,7 @@ const fe = (t, e) => {
|
|
|
996
997
|
rotate3d: (n, o, s, a) => {
|
|
997
998
|
const i = Math.sqrt(n * n + o * o + s * s);
|
|
998
999
|
if (i === 0)
|
|
999
|
-
return
|
|
1000
|
+
return V(e);
|
|
1000
1001
|
n /= i, o /= i, s /= i;
|
|
1001
1002
|
const c = Math.cos(a), u = Math.sin(a), d = 1 - c;
|
|
1002
1003
|
return r([
|
|
@@ -1113,7 +1114,7 @@ const fe = (t, e) => {
|
|
|
1113
1114
|
].join(`
|
|
1114
1115
|
`)
|
|
1115
1116
|
});
|
|
1116
|
-
},
|
|
1117
|
+
}, Ee = () => V([
|
|
1117
1118
|
1,
|
|
1118
1119
|
0,
|
|
1119
1120
|
0,
|
|
@@ -1130,95 +1131,95 @@ const fe = (t, e) => {
|
|
|
1130
1131
|
0,
|
|
1131
1132
|
0,
|
|
1132
1133
|
1
|
|
1133
|
-
]),
|
|
1134
|
+
]), Ce = {
|
|
1134
1135
|
position: "fixed",
|
|
1135
1136
|
inset: 0,
|
|
1136
1137
|
pointerEvents: "none",
|
|
1137
|
-
zIndex:
|
|
1138
|
-
},
|
|
1138
|
+
zIndex: Nt
|
|
1139
|
+
}, Re = {
|
|
1139
1140
|
position: "absolute",
|
|
1140
|
-
border: `${
|
|
1141
|
-
background:
|
|
1141
|
+
border: `${Xt} dashed ${Yt}`,
|
|
1142
|
+
background: zt,
|
|
1142
1143
|
borderRadius: $t,
|
|
1143
1144
|
transformOrigin: "top left"
|
|
1144
|
-
}, L = (t, e) => e <= 0 ? 0 :
|
|
1145
|
+
}, L = (t, e) => e <= 0 ? 0 : M(t / e, 0), Pe = (t, e, r) => {
|
|
1145
1146
|
const { width: n, height: o } = t, s = r / 2, a = n > 0 ? n : 1, i = o > 0 ? o : 1, c = {
|
|
1146
1147
|
translateX: r,
|
|
1147
1148
|
translateY: r,
|
|
1148
|
-
scaleX: L(
|
|
1149
|
-
scaleY: L(
|
|
1149
|
+
scaleX: L(M(n - r * 2, 0), a),
|
|
1150
|
+
scaleY: L(M(o - r * 2, 0), i)
|
|
1150
1151
|
}, u = {
|
|
1151
1152
|
translateX: r,
|
|
1152
1153
|
translateY: r,
|
|
1153
|
-
scaleX: L(
|
|
1154
|
-
scaleY: L(
|
|
1154
|
+
scaleX: L(M(n / 2 - r * 1.5, 0), a),
|
|
1155
|
+
scaleY: L(M(o - r * 2, 0), i)
|
|
1155
1156
|
}, d = {
|
|
1156
1157
|
translateX: n / 2 + s,
|
|
1157
1158
|
translateY: r,
|
|
1158
|
-
scaleX: L(
|
|
1159
|
-
scaleY: L(
|
|
1160
|
-
},
|
|
1159
|
+
scaleX: L(M(n / 2 - r * 1.5, 0), a),
|
|
1160
|
+
scaleY: L(M(o - r * 2, 0), i)
|
|
1161
|
+
}, f = {
|
|
1161
1162
|
translateX: r,
|
|
1162
1163
|
translateY: r,
|
|
1163
|
-
scaleX: L(
|
|
1164
|
-
scaleY: L(
|
|
1165
|
-
},
|
|
1164
|
+
scaleX: L(M(n - r * 2, 0), a),
|
|
1165
|
+
scaleY: L(M(o / 2 - r * 1.5, 0), i)
|
|
1166
|
+
}, g = {
|
|
1166
1167
|
translateX: r,
|
|
1167
1168
|
translateY: o / 2 + s,
|
|
1168
|
-
scaleX: L(
|
|
1169
|
-
scaleY: L(
|
|
1170
|
-
},
|
|
1169
|
+
scaleX: L(M(n - r * 2, 0), a),
|
|
1170
|
+
scaleY: L(M(o / 2 - r * 1.5, 0), i)
|
|
1171
|
+
}, y = {
|
|
1171
1172
|
center: c,
|
|
1172
1173
|
left: u,
|
|
1173
1174
|
right: d,
|
|
1174
|
-
top:
|
|
1175
|
-
bottom:
|
|
1176
|
-
}, { translateX: h, translateY: w, scaleX:
|
|
1177
|
-
return
|
|
1178
|
-
},
|
|
1179
|
-
const r =
|
|
1175
|
+
top: f,
|
|
1176
|
+
bottom: g
|
|
1177
|
+
}, { translateX: h, translateY: w, scaleX: I, scaleY: T } = y[e];
|
|
1178
|
+
return Ee().translate(h, w, 0).scale(I, T, 1).toCSS();
|
|
1179
|
+
}, De = (t, e) => {
|
|
1180
|
+
const r = Ft;
|
|
1180
1181
|
return {
|
|
1181
|
-
...
|
|
1182
|
+
...Re,
|
|
1182
1183
|
left: t.left,
|
|
1183
1184
|
top: t.top,
|
|
1184
1185
|
width: t.width,
|
|
1185
1186
|
height: t.height,
|
|
1186
|
-
transform:
|
|
1187
|
+
transform: Pe(t, e, r)
|
|
1187
1188
|
};
|
|
1188
|
-
},
|
|
1189
|
+
}, Ae = ({ suggest: t }) => {
|
|
1189
1190
|
if (!t)
|
|
1190
1191
|
return null;
|
|
1191
|
-
const { rect: e, zone: r } = t, n =
|
|
1192
|
-
return /* @__PURE__ */ m("div", { style:
|
|
1193
|
-
},
|
|
1192
|
+
const { rect: e, zone: r } = t, n = De(e, r);
|
|
1193
|
+
return /* @__PURE__ */ m("div", { style: Ce, children: /* @__PURE__ */ m("div", { style: n }) });
|
|
1194
|
+
}, ke = typeof window < "u" && typeof document < "u", Me = (t) => {
|
|
1194
1195
|
const [e, r] = l.useState(null), [n, o] = l.useState(null);
|
|
1195
|
-
return
|
|
1196
|
-
if (!
|
|
1196
|
+
return rt(() => {
|
|
1197
|
+
if (!ke || !t) {
|
|
1197
1198
|
r(null), o(null);
|
|
1198
1199
|
return;
|
|
1199
1200
|
}
|
|
1200
1201
|
const s = t.getBoundingClientRect();
|
|
1201
1202
|
r({ width: s.width, height: s.height }), o(t.outerHTML);
|
|
1202
1203
|
}, [t]), { html: n, size: e };
|
|
1203
|
-
},
|
|
1204
|
+
}, _e = {
|
|
1204
1205
|
position: "fixed",
|
|
1205
1206
|
inset: 0,
|
|
1206
1207
|
pointerEvents: "none",
|
|
1207
|
-
zIndex:
|
|
1208
|
-
},
|
|
1208
|
+
zIndex: Zt
|
|
1209
|
+
}, Oe = {
|
|
1209
1210
|
position: "absolute",
|
|
1210
|
-
width:
|
|
1211
|
-
borderRadius:
|
|
1212
|
-
background:
|
|
1213
|
-
boxShadow:
|
|
1214
|
-
},
|
|
1215
|
-
const { isTabDragging: t, draggingTabId: e, dragPointer: r, tabbarHover: n, draggingTabElement: o } =
|
|
1211
|
+
width: qt,
|
|
1212
|
+
borderRadius: Wt,
|
|
1213
|
+
background: Ut,
|
|
1214
|
+
boxShadow: Vt
|
|
1215
|
+
}, Be = () => {
|
|
1216
|
+
const { isTabDragging: t, draggingTabId: e, dragPointer: r, tabbarHover: n, draggingTabElement: o } = W(), { html: s, size: a } = Me(o), i = r !== null && e !== null, c = l.useMemo(() => {
|
|
1216
1217
|
if (!(!i || !r))
|
|
1217
1218
|
return {
|
|
1218
1219
|
position: "absolute",
|
|
1219
1220
|
left: r.x,
|
|
1220
1221
|
top: r.y,
|
|
1221
|
-
transform: `translate(${
|
|
1222
|
+
transform: `translate(${jt}, ${Kt})`,
|
|
1222
1223
|
pointerEvents: "none"
|
|
1223
1224
|
};
|
|
1224
1225
|
}, [i, r]), u = l.useMemo(() => {
|
|
@@ -1227,13 +1228,13 @@ const fe = (t, e) => {
|
|
|
1227
1228
|
}, [c, o, a]), d = l.useMemo(() => {
|
|
1228
1229
|
if (n)
|
|
1229
1230
|
return {
|
|
1230
|
-
...
|
|
1231
|
+
...Oe,
|
|
1231
1232
|
left: n.insertX,
|
|
1232
1233
|
top: n.rect.top + 4,
|
|
1233
1234
|
height: Math.max(0, n.rect.height - 8)
|
|
1234
1235
|
};
|
|
1235
1236
|
}, [n]);
|
|
1236
|
-
return t ? /* @__PURE__ */ H("div", { style:
|
|
1237
|
+
return t ? /* @__PURE__ */ H("div", { style: _e, children: [
|
|
1237
1238
|
/* @__PURE__ */ m(l.Activity, { mode: u ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: u, children: /* @__PURE__ */ m(
|
|
1238
1239
|
"div",
|
|
1239
1240
|
{
|
|
@@ -1243,26 +1244,26 @@ const fe = (t, e) => {
|
|
|
1243
1244
|
) }) }),
|
|
1244
1245
|
/* @__PURE__ */ m(l.Activity, { mode: d ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: d }) })
|
|
1245
1246
|
] }) : null;
|
|
1246
|
-
},
|
|
1247
|
-
if (
|
|
1247
|
+
}, _ = (t) => t.type === "group", F = (t, e = []) => {
|
|
1248
|
+
if (_(t))
|
|
1248
1249
|
return [...e, t.groupId];
|
|
1249
|
-
const r =
|
|
1250
|
-
return
|
|
1251
|
-
},
|
|
1250
|
+
const r = F(t.a, e);
|
|
1251
|
+
return F(t.b, r);
|
|
1252
|
+
}, q = (t, e) => e.reduce((r, n) => _(r) ? r : r[n], t), j = (t, e, r) => {
|
|
1252
1253
|
if (e.length === 0)
|
|
1253
1254
|
return r;
|
|
1254
1255
|
const [n, ...o] = e;
|
|
1255
|
-
return
|
|
1256
|
+
return _(t) ? t : n === "a" ? { ...t, a: j(t.a, o, r) } : { ...t, b: j(t.b, o, r) };
|
|
1256
1257
|
}, U = (t, e, r = []) => {
|
|
1257
|
-
if (
|
|
1258
|
+
if (_(t))
|
|
1258
1259
|
return t.groupId === e ? { splitPath: null, side: null } : null;
|
|
1259
|
-
if (
|
|
1260
|
+
if (_(t.a) && t.a.groupId === e)
|
|
1260
1261
|
return { splitPath: r, side: "a" };
|
|
1261
|
-
if (
|
|
1262
|
+
if (_(t.b) && t.b.groupId === e)
|
|
1262
1263
|
return { splitPath: r, side: "b" };
|
|
1263
1264
|
const n = U(t.a, e, [...r, "a"]);
|
|
1264
1265
|
return n || U(t.b, e, [...r, "b"]);
|
|
1265
|
-
},
|
|
1266
|
+
}, wt = (t, e, r, n) => {
|
|
1266
1267
|
const o = n(), s = U(t, e), a = {
|
|
1267
1268
|
type: "split",
|
|
1268
1269
|
direction: r,
|
|
@@ -1272,26 +1273,26 @@ const fe = (t, e) => {
|
|
|
1272
1273
|
};
|
|
1273
1274
|
if (!s || s.splitPath === null)
|
|
1274
1275
|
return { tree: a, newGroupId: o };
|
|
1275
|
-
const i = s.splitPath, c =
|
|
1276
|
-
if (
|
|
1276
|
+
const i = s.splitPath, c = q(t, i);
|
|
1277
|
+
if (_(c))
|
|
1277
1278
|
return { tree: a, newGroupId: o };
|
|
1278
1279
|
const u = s.side === "a" ? { ...c, a } : { ...c, b: a };
|
|
1279
|
-
return { tree:
|
|
1280
|
-
},
|
|
1280
|
+
return { tree: j(t, i, u), newGroupId: o };
|
|
1281
|
+
}, Le = (t, e) => {
|
|
1281
1282
|
const r = U(t, e);
|
|
1282
1283
|
if (!r || r.splitPath === null)
|
|
1283
1284
|
return { tree: t, survivorGroupId: e };
|
|
1284
|
-
const n = r.splitPath, o =
|
|
1285
|
-
if (
|
|
1285
|
+
const n = r.splitPath, o = q(t, n);
|
|
1286
|
+
if (_(o))
|
|
1286
1287
|
return { tree: t, survivorGroupId: e };
|
|
1287
|
-
const s = r.side === "a" ? o.b : o.a, a =
|
|
1288
|
+
const s = r.side === "a" ? o.b : o.a, a = j(t, n, s), i = _(s) ? s.groupId : F(s)[0] ?? null;
|
|
1288
1289
|
return { tree: a, survivorGroupId: i };
|
|
1289
|
-
},
|
|
1290
|
-
const n =
|
|
1291
|
-
if (
|
|
1290
|
+
}, He = (t, e, r) => {
|
|
1291
|
+
const n = q(t, e);
|
|
1292
|
+
if (_(n))
|
|
1292
1293
|
return t;
|
|
1293
|
-
const o = { ...n, ratio:
|
|
1294
|
-
return
|
|
1294
|
+
const o = { ...n, ratio: M(r, 0.05, 0.95) };
|
|
1295
|
+
return j(t, e, o);
|
|
1295
1296
|
}, Q = (t) => {
|
|
1296
1297
|
if (Object.keys(t.groups).filter((o) => t.groups[o].tabIds.length === 0).length === 0)
|
|
1297
1298
|
return t;
|
|
@@ -1299,29 +1300,29 @@ const fe = (t, e) => {
|
|
|
1299
1300
|
const a = o.groups[s];
|
|
1300
1301
|
if (!a || a.tabs.length > 0 || Object.keys(o.groups).length <= 1)
|
|
1301
1302
|
return o;
|
|
1302
|
-
const { tree: c, survivorGroupId: u } =
|
|
1303
|
-
return { ...o, tree: c, groups:
|
|
1303
|
+
const { tree: c, survivorGroupId: u } = Le(o.tree, s), { [s]: d, ...f } = o.groups, g = F(c), y = o.focusedGroupId === s ? u ?? g[0] ?? null : o.focusedGroupId;
|
|
1304
|
+
return { ...o, tree: c, groups: f, groupOrder: g, focusedGroupId: y };
|
|
1304
1305
|
};
|
|
1305
1306
|
return t.groupOrder.reduce((o, s) => n(o, s), t);
|
|
1306
|
-
},
|
|
1307
|
+
}, Ne = (t) => ({ id: t, tabIds: [], tabs: [], activeTabId: null }), at = (t, e, r, n) => {
|
|
1307
1308
|
const o = { ...t.groups }, s = o[e];
|
|
1308
1309
|
if (!s)
|
|
1309
1310
|
throw new Error(`Group ${e} does not exist.`);
|
|
1310
|
-
const a = { ...t.panels, [r.id]: r }, i = [...s.tabIds, r.id], c = n ? r.id : s.activeTabId ?? r.id, u = i.map((
|
|
1311
|
+
const a = { ...t.panels, [r.id]: r }, i = [...s.tabIds, r.id], c = n ? r.id : s.activeTabId ?? r.id, u = i.map((f) => a[f]), d = { ...s, tabIds: i, tabs: u, activeTabId: c };
|
|
1311
1312
|
return o[e] = d, { ...t, panels: a, groups: o };
|
|
1312
|
-
},
|
|
1313
|
+
}, $e = (t, e, r) => {
|
|
1313
1314
|
const n = { ...t.groups }, o = n[e];
|
|
1314
1315
|
if (!o)
|
|
1315
1316
|
throw new Error(`Group ${e} does not exist.`);
|
|
1316
1317
|
const s = o.tabIds.filter((c) => c !== r), a = s.map((c) => t.panels[c]), i = o.activeTabId === r ? s[0] ?? null : o.activeTabId;
|
|
1317
1318
|
return n[e] = { ...o, tabIds: s, tabs: a, activeTabId: i }, { ...t, groups: n };
|
|
1318
|
-
},
|
|
1319
|
+
}, ct = (t, e, r, n, o) => {
|
|
1319
1320
|
const s = t.groups[e], a = t.groups[r];
|
|
1320
1321
|
if (!s || !a)
|
|
1321
1322
|
throw new Error("moveTab: source or target group is missing.");
|
|
1322
|
-
const i = { ...t.groups }, c = s.tabIds.filter((
|
|
1323
|
-
return i[e] = { ...s, tabIds: c, tabs: c.map((
|
|
1324
|
-
},
|
|
1323
|
+
const i = { ...t.groups }, c = s.tabIds.filter((f) => f !== n), u = [...a.tabIds.filter((f) => f !== n), n], d = s.activeTabId === n ? c[0] ?? null : s.activeTabId;
|
|
1324
|
+
return i[e] = { ...s, tabIds: c, tabs: c.map((f) => t.panels[f]), activeTabId: d }, i[r] = { ...a, tabIds: u, tabs: u.map((f) => t.panels[f]), activeTabId: n }, { ...t, groups: i };
|
|
1325
|
+
}, yt = (t, e, r) => {
|
|
1325
1326
|
const n = t.groups[e];
|
|
1326
1327
|
if (!n)
|
|
1327
1328
|
throw new Error(`setActiveTab: group ${e} not found.`);
|
|
@@ -1329,85 +1330,85 @@ const fe = (t, e) => {
|
|
|
1329
1330
|
throw new Error(`setActiveTab: tab ${r} not found in group ${e}.`);
|
|
1330
1331
|
const o = { ...t.groups, [e]: { ...n, activeTabId: r } };
|
|
1331
1332
|
return { ...t, groups: o, focusedGroupId: e };
|
|
1332
|
-
},
|
|
1333
|
+
}, ut = (t, e, r, n, o) => {
|
|
1333
1334
|
const s = t.groups[e];
|
|
1334
1335
|
if (!s)
|
|
1335
1336
|
throw new Error(`addTabToGroupAtIndex: group ${e} not found.`);
|
|
1336
1337
|
const a = { ...t.panels, [r.id]: r }, i = s.tabIds.slice(), c = Math.max(0, Math.min(n, i.length));
|
|
1337
1338
|
i.splice(c, 0, r.id);
|
|
1338
|
-
const u = i.map((
|
|
1339
|
-
return { ...t, panels: a, groups:
|
|
1340
|
-
},
|
|
1339
|
+
const u = i.map((g) => a[g]), d = o ? r.id : s.activeTabId ?? r.id, f = { ...t.groups, [e]: { ...s, tabIds: i, tabs: u, activeTabId: d } };
|
|
1340
|
+
return { ...t, panels: a, groups: f };
|
|
1341
|
+
}, N = (t, e) => {
|
|
1341
1342
|
if (!t.groups[e])
|
|
1342
1343
|
throw new Error(`setFocusedGroup: group ${e} not found.`);
|
|
1343
1344
|
return { ...t, focusedGroupId: e };
|
|
1344
|
-
},
|
|
1345
|
+
}, ze = (t, e) => {
|
|
1345
1346
|
const r = e - 1, n = t.groupOrder[r];
|
|
1346
|
-
return n ?
|
|
1347
|
-
},
|
|
1347
|
+
return n ? N(t, n) : t;
|
|
1348
|
+
}, Xe = (t) => {
|
|
1348
1349
|
const e = t.groupOrder, r = t.focusedGroupId;
|
|
1349
1350
|
if (!r) {
|
|
1350
1351
|
const s = e[0];
|
|
1351
|
-
return s ?
|
|
1352
|
+
return s ? N(t, s) : t;
|
|
1352
1353
|
}
|
|
1353
1354
|
const n = e.indexOf(r), o = e[(n + 1) % e.length];
|
|
1354
|
-
return
|
|
1355
|
-
},
|
|
1355
|
+
return N(t, o);
|
|
1356
|
+
}, Ye = (t) => {
|
|
1356
1357
|
const e = t.groupOrder, r = t.focusedGroupId;
|
|
1357
1358
|
if (!r) {
|
|
1358
1359
|
const s = e[e.length - 1];
|
|
1359
|
-
return s ?
|
|
1360
|
+
return s ? N(t, s) : t;
|
|
1360
1361
|
}
|
|
1361
1362
|
const n = e.indexOf(r), o = e[(n - 1 + e.length) % e.length];
|
|
1362
|
-
return
|
|
1363
|
-
},
|
|
1364
|
-
const { tree: o, newGroupId: s } =
|
|
1363
|
+
return N(t, o);
|
|
1364
|
+
}, Tt = (t, e, r, n) => {
|
|
1365
|
+
const { tree: o, newGroupId: s } = wt(t.tree, e, r, n), a = { ...t.groups, [s]: Ne(s) }, i = F(o);
|
|
1365
1366
|
return { ...t, tree: o, groups: a, groupOrder: i, focusedGroupId: s };
|
|
1366
|
-
},
|
|
1367
|
+
}, Gr = (t) => {
|
|
1367
1368
|
const r = { type: "group", groupId: "g_1" }, n = Object.fromEntries(t.map((i) => [i.id, i])), s = { g_1: { id: "g_1", tabIds: t.map((i) => i.id), tabs: t, activeTabId: t[0]?.id ?? null } };
|
|
1368
1369
|
return { tree: r, panels: n, groups: s, groupOrder: ["g_1"], focusedGroupId: "g_1" };
|
|
1369
|
-
},
|
|
1370
|
-
const t = l.useContext(
|
|
1370
|
+
}, Fe = l.createContext(null), je = ({ value: t, children: e }) => /* @__PURE__ */ m(Fe.Provider, { value: t, children: e }), xt = l.createContext(null), Ke = () => {
|
|
1371
|
+
const t = l.useContext(xt);
|
|
1371
1372
|
if (!t)
|
|
1372
1373
|
throw new Error("useTree must be used within TreeProvider");
|
|
1373
1374
|
return t;
|
|
1374
|
-
},
|
|
1375
|
-
const e =
|
|
1376
|
-
return
|
|
1377
|
-
},
|
|
1375
|
+
}, Ve = ({ value: t, children: e }) => /* @__PURE__ */ m(xt.Provider, { value: t, children: e }), Ue = l.createContext(null), We = ({ value: t, children: e }) => /* @__PURE__ */ m(Ue.Provider, { value: t, children: e }), X = (t) => {
|
|
1376
|
+
const e = _t(t, Number.POSITIVE_INFINITY);
|
|
1377
|
+
return M(e, 1);
|
|
1378
|
+
}, qe = (t) => typeof t == "object" && t !== null, Ze = (t) => qe(t) ? "rows" in t ? !0 : "cols" in t : !1, Gt = (t) => {
|
|
1378
1379
|
if (!t)
|
|
1379
1380
|
return {
|
|
1380
1381
|
rows: Number.POSITIVE_INFINITY,
|
|
1381
1382
|
cols: Number.POSITIVE_INFINITY
|
|
1382
1383
|
};
|
|
1383
1384
|
if (typeof t == "number") {
|
|
1384
|
-
const r =
|
|
1385
|
+
const r = X(t);
|
|
1385
1386
|
return { rows: r, cols: r };
|
|
1386
1387
|
}
|
|
1387
|
-
if (
|
|
1388
|
+
if (Ze(t))
|
|
1388
1389
|
return {
|
|
1389
|
-
rows:
|
|
1390
|
-
cols:
|
|
1390
|
+
rows: X(t.rows),
|
|
1391
|
+
cols: X(t.cols)
|
|
1391
1392
|
};
|
|
1392
1393
|
const e = t;
|
|
1393
1394
|
return {
|
|
1394
|
-
rows:
|
|
1395
|
-
cols:
|
|
1395
|
+
rows: X(e.maxHorizontal),
|
|
1396
|
+
cols: X(e.maxVertical)
|
|
1396
1397
|
};
|
|
1397
1398
|
}, tt = (t) => {
|
|
1398
|
-
if (
|
|
1399
|
+
if (_(t))
|
|
1399
1400
|
return { horizontal: 1, vertical: 1 };
|
|
1400
1401
|
const e = tt(t.a), r = tt(t.b);
|
|
1401
1402
|
return t.direction === "horizontal" ? { horizontal: e.horizontal + r.horizontal, vertical: Math.max(e.vertical, r.vertical) } : { horizontal: Math.max(e.horizontal, r.horizontal), vertical: e.vertical + r.vertical };
|
|
1402
|
-
},
|
|
1403
|
-
const { tree: n } =
|
|
1403
|
+
}, Je = (t, e, r) => {
|
|
1404
|
+
const { tree: n } = wt(t, e, r, () => "__preview__");
|
|
1404
1405
|
return n;
|
|
1405
|
-
},
|
|
1406
|
+
}, nt = (t, e, r, n) => {
|
|
1406
1407
|
if (!Number.isFinite(n.rows) && !Number.isFinite(n.cols))
|
|
1407
1408
|
return !0;
|
|
1408
|
-
const o =
|
|
1409
|
+
const o = Je(t, e, r), s = tt(o);
|
|
1409
1410
|
return !(s.horizontal > n.rows || s.vertical > n.cols);
|
|
1410
|
-
},
|
|
1411
|
+
}, St = {
|
|
1411
1412
|
splitFocused: A("panelState/splitFocused", (t) => ({ direction: t })),
|
|
1412
1413
|
focusGroupIndex: A("panelState/focusGroupIndex", (t) => ({ index1Based: t })),
|
|
1413
1414
|
focusNextGroup: A("panelState/focusNextGroup"),
|
|
@@ -1431,79 +1432,79 @@ const fe = (t, e) => {
|
|
|
1431
1432
|
(t) => t
|
|
1432
1433
|
),
|
|
1433
1434
|
adjustSplitRatio: A("panelState/adjustSplitRatio", (t) => t)
|
|
1434
|
-
},
|
|
1435
|
+
}, Qe = (t, e, r) => {
|
|
1435
1436
|
const n = t.groups[e.fromGroupId], o = t.groups[e.targetGroupId];
|
|
1436
|
-
if (!n || !o || !n.tabs.find((
|
|
1437
|
+
if (!n || !o || !n.tabs.find((f) => f.id === e.tabId))
|
|
1437
1438
|
return t;
|
|
1438
1439
|
if (e.zone === "center" && e.fromGroupId === e.targetGroupId)
|
|
1439
|
-
return
|
|
1440
|
+
return yt(t, e.fromGroupId, e.tabId);
|
|
1440
1441
|
if (e.zone === "center") {
|
|
1441
|
-
const
|
|
1442
|
-
return
|
|
1442
|
+
const f = ct(t, e.fromGroupId, e.targetGroupId, e.tabId);
|
|
1443
|
+
return N(f, e.targetGroupId);
|
|
1443
1444
|
}
|
|
1444
1445
|
const a = e.zone === "left" || e.zone === "right" ? "vertical" : "horizontal";
|
|
1445
|
-
if (!
|
|
1446
|
+
if (!nt(t.tree, e.targetGroupId, a, r.splitLimits))
|
|
1446
1447
|
return t;
|
|
1447
|
-
const i = r.createGroupId(), c =
|
|
1448
|
-
return
|
|
1449
|
-
},
|
|
1448
|
+
const i = r.createGroupId(), c = Tt(t, e.targetGroupId, a, () => i), u = e.zone === "left" || e.zone === "top" ? e.targetGroupId : i, d = ct(c, e.fromGroupId, u, e.tabId);
|
|
1449
|
+
return N(d, u);
|
|
1450
|
+
}, tr = (t, e) => {
|
|
1450
1451
|
const r = t.groups[e.fromGroupId], n = t.groups[e.targetGroupId];
|
|
1451
1452
|
if (!r || !n || !t.panels[e.tabId])
|
|
1452
1453
|
return t;
|
|
1453
1454
|
if (e.fromGroupId === e.targetGroupId) {
|
|
1454
|
-
const
|
|
1455
|
-
return { ...t, groups:
|
|
1455
|
+
const g = r.tabIds.filter((T) => T !== e.tabId), y = Math.max(0, Math.min(e.targetIndex, g.length)), h = g.slice(0, y).concat([e.tabId], g.slice(y)), w = h.map((T) => t.panels[T]).filter(Boolean), I = { ...t.groups, [e.fromGroupId]: { ...r, tabIds: h, tabs: w } };
|
|
1456
|
+
return { ...t, groups: I };
|
|
1456
1457
|
}
|
|
1457
|
-
const s = { ...t.groups }, a = r.tabIds.filter((
|
|
1458
|
+
const s = { ...t.groups }, a = r.tabIds.filter((g) => g !== e.tabId), i = a.map((g) => t.panels[g]);
|
|
1458
1459
|
s[e.fromGroupId] = {
|
|
1459
1460
|
...r,
|
|
1460
1461
|
tabIds: a,
|
|
1461
1462
|
tabs: i,
|
|
1462
1463
|
activeTabId: r.activeTabId === e.tabId ? i[0]?.id ?? null : r.activeTabId
|
|
1463
1464
|
};
|
|
1464
|
-
const c = n.tabIds.filter((
|
|
1465
|
-
return s[e.targetGroupId] = { ...n, tabIds: d, tabs:
|
|
1466
|
-
},
|
|
1465
|
+
const c = n.tabIds.filter((g) => g !== e.tabId), u = Math.max(0, Math.min(e.targetIndex, c.length)), d = c.slice(0, u).concat([e.tabId], c.slice(u)), f = d.map((g) => t.panels[g]).filter(Boolean);
|
|
1466
|
+
return s[e.targetGroupId] = { ...n, tabIds: d, tabs: f, activeTabId: e.tabId }, { ...t, groups: s, focusedGroupId: e.targetGroupId };
|
|
1467
|
+
}, er = mt(St, {
|
|
1467
1468
|
splitFocused: (t, e, r) => {
|
|
1468
1469
|
const n = t.focusedGroupId ?? t.groupOrder[0] ?? null;
|
|
1469
|
-
return !n || !
|
|
1470
|
+
return !n || !nt(t.tree, n, e.payload.direction, r.splitLimits) ? t : Tt(t, n, e.payload.direction, r.createGroupId);
|
|
1470
1471
|
},
|
|
1471
|
-
focusGroupIndex: (t, e) =>
|
|
1472
|
-
focusNextGroup: (t) =>
|
|
1473
|
-
focusPrevGroup: (t) =>
|
|
1474
|
-
setActiveTab: (t, e) =>
|
|
1472
|
+
focusGroupIndex: (t, e) => ze(t, e.payload.index1Based),
|
|
1473
|
+
focusNextGroup: (t) => Xe(t),
|
|
1474
|
+
focusPrevGroup: (t) => Ye(t),
|
|
1475
|
+
setActiveTab: (t, e) => yt(t, e.payload.groupId, e.payload.tabId),
|
|
1475
1476
|
addTab: (t, e) => {
|
|
1476
1477
|
const { groupId: r, tab: n, index: o, makeActive: s } = e.payload;
|
|
1477
|
-
return typeof o == "number" ?
|
|
1478
|
+
return typeof o == "number" ? ut(t, r, n, o, s ?? !0) : at(t, r, n, s ?? !0);
|
|
1478
1479
|
},
|
|
1479
1480
|
addNewTab: (t, e, r) => {
|
|
1480
1481
|
if (!r.createPanelId)
|
|
1481
1482
|
throw new Error("addNewTab requires PanelSystemProvider.createPanelId");
|
|
1482
1483
|
const o = { id: r.createPanelId(), title: e.payload.title, render: () => e.payload.title }, { groupId: s, index: a, makeActive: i } = e.payload;
|
|
1483
|
-
return typeof a == "number" ?
|
|
1484
|
+
return typeof a == "number" ? ut(t, s, o, a, i ?? !0) : at(t, s, o, i ?? !0);
|
|
1484
1485
|
},
|
|
1485
|
-
removeTab: (t, e) =>
|
|
1486
|
-
contentDrop: (t, e, r) =>
|
|
1487
|
-
tabDrop: (t, e) =>
|
|
1486
|
+
removeTab: (t, e) => $e(t, e.payload.groupId, e.payload.tabId),
|
|
1487
|
+
contentDrop: (t, e, r) => Qe(t, e.payload, r),
|
|
1488
|
+
tabDrop: (t, e) => tr(t, e.payload),
|
|
1488
1489
|
adjustSplitRatio: (t, e) => {
|
|
1489
|
-
const r =
|
|
1490
|
-
if (
|
|
1490
|
+
const r = q(t.tree, e.payload.path);
|
|
1491
|
+
if (_(r))
|
|
1491
1492
|
return t;
|
|
1492
|
-
const n =
|
|
1493
|
+
const n = He(t.tree, e.payload.path, r.ratio + e.payload.deltaRatio);
|
|
1493
1494
|
return { ...t, tree: n };
|
|
1494
1495
|
}
|
|
1495
|
-
}),
|
|
1496
|
-
const n =
|
|
1496
|
+
}), lt = (t, e, r) => {
|
|
1497
|
+
const n = er[e.type];
|
|
1497
1498
|
if (!n)
|
|
1498
1499
|
return t;
|
|
1499
1500
|
const o = n(t, e, r);
|
|
1500
1501
|
return Q(o);
|
|
1501
|
-
},
|
|
1502
|
-
const t = l.useContext(
|
|
1502
|
+
}, Et = l.createContext(null), z = () => {
|
|
1503
|
+
const t = l.useContext(Et);
|
|
1503
1504
|
if (!t)
|
|
1504
1505
|
throw new Error("usePanelSystem must be used within PanelSystemProvider");
|
|
1505
1506
|
return t;
|
|
1506
|
-
},
|
|
1507
|
+
}, rr = ({
|
|
1507
1508
|
initialState: t,
|
|
1508
1509
|
createGroupId: e,
|
|
1509
1510
|
createPanelId: r,
|
|
@@ -1514,53 +1515,53 @@ const fe = (t, e) => {
|
|
|
1514
1515
|
}) => {
|
|
1515
1516
|
const i = l.useMemo(() => Q(t), [t]), c = l.useMemo(() => Gt(s), [s]), u = l.useRef({ createGroupId: e, splitLimits: c, createPanelId: r });
|
|
1516
1517
|
u.current.createGroupId = e, u.current.splitLimits = c, u.current.createPanelId = r;
|
|
1517
|
-
const [d,
|
|
1518
|
-
(
|
|
1518
|
+
const [d, f] = l.useReducer(
|
|
1519
|
+
(x, E) => lt(x, E, u.current),
|
|
1519
1520
|
i
|
|
1520
|
-
),
|
|
1521
|
+
), g = l.useMemo(
|
|
1521
1522
|
() => n ? Q(n) : d,
|
|
1522
1523
|
[n, d]
|
|
1523
|
-
),
|
|
1524
|
-
|
|
1524
|
+
), y = l.useRef(g);
|
|
1525
|
+
y.current = g;
|
|
1525
1526
|
const h = n !== void 0, w = l.useCallback(
|
|
1526
|
-
(
|
|
1527
|
+
(x) => {
|
|
1527
1528
|
if (h) {
|
|
1528
|
-
const E =
|
|
1529
|
+
const E = lt(y.current, x, u.current);
|
|
1529
1530
|
o?.(E);
|
|
1530
1531
|
return;
|
|
1531
1532
|
}
|
|
1532
|
-
|
|
1533
|
+
f(x);
|
|
1533
1534
|
},
|
|
1534
|
-
[h, o,
|
|
1535
|
-
),
|
|
1535
|
+
[h, o, f]
|
|
1536
|
+
), I = l.useMemo(() => he(St, w), [w]), T = l.useMemo(
|
|
1536
1537
|
() => ({
|
|
1537
|
-
setActiveTab:
|
|
1538
|
-
tabDrop:
|
|
1538
|
+
setActiveTab: I.setActiveTab,
|
|
1539
|
+
tabDrop: I.tabDrop
|
|
1539
1540
|
}),
|
|
1540
|
-
[
|
|
1541
|
-
),
|
|
1541
|
+
[I]
|
|
1542
|
+
), b = l.useMemo(
|
|
1542
1543
|
() => ({
|
|
1543
|
-
adjustSplitRatio:
|
|
1544
|
+
adjustSplitRatio: I.adjustSplitRatio
|
|
1544
1545
|
}),
|
|
1545
|
-
[
|
|
1546
|
-
),
|
|
1546
|
+
[I]
|
|
1547
|
+
), v = l.useMemo(
|
|
1547
1548
|
() => ({
|
|
1548
|
-
focusGroupIndex:
|
|
1549
|
-
focusNextGroup:
|
|
1550
|
-
focusPrevGroup:
|
|
1549
|
+
focusGroupIndex: I.focusGroupIndex,
|
|
1550
|
+
focusNextGroup: I.focusNextGroup,
|
|
1551
|
+
focusPrevGroup: I.focusPrevGroup
|
|
1551
1552
|
}),
|
|
1552
|
-
[
|
|
1553
|
+
[I]
|
|
1553
1554
|
), p = l.useMemo(
|
|
1554
1555
|
() => ({
|
|
1555
|
-
state:
|
|
1556
|
+
state: g,
|
|
1556
1557
|
dispatch: w,
|
|
1557
|
-
actions:
|
|
1558
|
+
actions: I
|
|
1558
1559
|
}),
|
|
1559
|
-
[
|
|
1560
|
+
[g, w, I]
|
|
1560
1561
|
);
|
|
1561
|
-
return /* @__PURE__ */ m(
|
|
1562
|
-
},
|
|
1563
|
-
const { actions: t } =
|
|
1562
|
+
return /* @__PURE__ */ m(Et.Provider, { value: p, children: /* @__PURE__ */ m(je, { value: T, children: /* @__PURE__ */ m(Ve, { value: b, children: /* @__PURE__ */ m(We, { value: v, children: a }) }) }) });
|
|
1563
|
+
}, nr = () => {
|
|
1564
|
+
const { actions: t } = z();
|
|
1564
1565
|
return l.useMemo(
|
|
1565
1566
|
() => ({
|
|
1566
1567
|
splitFocused: (e) => {
|
|
@@ -1580,8 +1581,8 @@ const fe = (t, e) => {
|
|
|
1580
1581
|
}),
|
|
1581
1582
|
[t]
|
|
1582
1583
|
);
|
|
1583
|
-
},
|
|
1584
|
-
const { actions: t } =
|
|
1584
|
+
}, or = () => {
|
|
1585
|
+
const { actions: t } = z(), e = l.useCallback(
|
|
1585
1586
|
({ fromGroupId: n, tabId: o, targetGroupId: s, zone: a }) => {
|
|
1586
1587
|
t.contentDrop({ fromGroupId: n, tabId: o, targetGroupId: s, zone: a });
|
|
1587
1588
|
},
|
|
@@ -1593,87 +1594,159 @@ const fe = (t, e) => {
|
|
|
1593
1594
|
[t]
|
|
1594
1595
|
);
|
|
1595
1596
|
return { onCommitContentDrop: e, onCommitTabDrop: r };
|
|
1596
|
-
},
|
|
1597
|
-
const t =
|
|
1597
|
+
}, sr = () => {
|
|
1598
|
+
const t = ee(), e = nr();
|
|
1598
1599
|
return l.useEffect(() => {
|
|
1599
|
-
|
|
1600
|
+
oe(t, e);
|
|
1600
1601
|
}, [t, e]), null;
|
|
1601
|
-
},
|
|
1602
|
+
}, Ct = l.createContext(null), ir = () => {
|
|
1603
|
+
const t = l.useContext(Ct);
|
|
1604
|
+
if (!t)
|
|
1605
|
+
throw new Error("useContentRegistry must be used within ContentRegistryProvider");
|
|
1606
|
+
return t;
|
|
1607
|
+
}, ar = (t) => {
|
|
1608
|
+
const e = document.createElement("div");
|
|
1609
|
+
return e.setAttribute("data-panel-wrapper", t), e.style.display = "contents", e;
|
|
1610
|
+
}, cr = (t, e, r) => {
|
|
1611
|
+
const [n] = l.useState(() => ar(t));
|
|
1612
|
+
return rt(() => (n.style.display = r ? "contents" : "none", e && n.parentElement !== e && e.appendChild(n), () => {
|
|
1613
|
+
n.parentElement?.removeChild(n);
|
|
1614
|
+
}), [n, e, r]), n;
|
|
1615
|
+
}, Rt = l.memo(
|
|
1616
|
+
({ panelId: t, content: e, placement: r, containerElement: n }) => {
|
|
1617
|
+
const o = r?.isActive ?? !1, s = cr(t, n, o);
|
|
1618
|
+
return Qt(
|
|
1619
|
+
/* @__PURE__ */ m(l.Activity, { mode: o ? "visible" : "hidden", children: e }),
|
|
1620
|
+
s
|
|
1621
|
+
);
|
|
1622
|
+
}
|
|
1623
|
+
);
|
|
1624
|
+
Rt.displayName = "PanelContentHost";
|
|
1625
|
+
const ur = ({
|
|
1626
|
+
children: t,
|
|
1627
|
+
panels: e,
|
|
1628
|
+
placements: r
|
|
1629
|
+
}) => {
|
|
1630
|
+
const [n, o] = l.useState(/* @__PURE__ */ new Map()), s = l.useRef(/* @__PURE__ */ new Map()), a = l.useCallback((d, f) => {
|
|
1631
|
+
o((g) => {
|
|
1632
|
+
const y = new Map(g);
|
|
1633
|
+
return f ? y.set(d, f) : y.delete(d), y;
|
|
1634
|
+
});
|
|
1635
|
+
}, []), i = l.useMemo(
|
|
1636
|
+
() => ({ registerContentContainer: a }),
|
|
1637
|
+
[a]
|
|
1638
|
+
), c = l.useCallback((d, f) => {
|
|
1639
|
+
const g = s.current.get(d);
|
|
1640
|
+
if (g)
|
|
1641
|
+
return g;
|
|
1642
|
+
const y = f.render(f.id);
|
|
1643
|
+
return s.current.set(d, y), y;
|
|
1644
|
+
}, []), u = Object.keys(e);
|
|
1645
|
+
return /* @__PURE__ */ H(Ct.Provider, { value: i, children: [
|
|
1646
|
+
t,
|
|
1647
|
+
u.map((d) => {
|
|
1648
|
+
const f = e[d];
|
|
1649
|
+
if (!f)
|
|
1650
|
+
return null;
|
|
1651
|
+
const g = r[d] ?? null, y = g ? n.get(g.groupId) ?? null : null, h = c(d, f);
|
|
1652
|
+
return /* @__PURE__ */ m(
|
|
1653
|
+
Rt,
|
|
1654
|
+
{
|
|
1655
|
+
panelId: d,
|
|
1656
|
+
content: h,
|
|
1657
|
+
placement: g,
|
|
1658
|
+
containerElement: y
|
|
1659
|
+
},
|
|
1660
|
+
d
|
|
1661
|
+
);
|
|
1662
|
+
})
|
|
1663
|
+
] });
|
|
1664
|
+
}, lr = ({
|
|
1602
1665
|
children: t,
|
|
1603
1666
|
emptyContentComponent: e,
|
|
1604
1667
|
doubleClickToAdd: r
|
|
1605
1668
|
}) => {
|
|
1606
|
-
const n =
|
|
1607
|
-
(
|
|
1608
|
-
const
|
|
1609
|
-
if (!
|
|
1669
|
+
const n = W(), { state: o, actions: s } = z(), { registerContentContainer: a } = ir(), i = l.useCallback(() => l.createElement("div", { style: { color: "#888", fontSize: 12, padding: 12 } }, "No tabs"), []), c = e ?? i, u = l.useCallback(
|
|
1670
|
+
(T) => {
|
|
1671
|
+
const b = o.groups[T];
|
|
1672
|
+
if (!b)
|
|
1610
1673
|
return null;
|
|
1611
|
-
const
|
|
1612
|
-
return { ...
|
|
1674
|
+
const v = b.tabIds.map((p) => o.panels[p]).filter(Boolean);
|
|
1675
|
+
return { ...b, tabs: v };
|
|
1613
1676
|
},
|
|
1614
1677
|
[o.groups, o.panels]
|
|
1615
|
-
),
|
|
1616
|
-
(
|
|
1617
|
-
const
|
|
1618
|
-
|
|
1619
|
-
return /* @__PURE__ */ m(i, {});
|
|
1620
|
-
const f = y.activeTabId;
|
|
1621
|
-
if (!f)
|
|
1622
|
-
return /* @__PURE__ */ m(i, {});
|
|
1623
|
-
const I = o.panels[f];
|
|
1624
|
-
return I ? I.render() : /* @__PURE__ */ m(i, {});
|
|
1678
|
+
), d = l.useCallback(
|
|
1679
|
+
(T) => {
|
|
1680
|
+
const b = o.groups[T];
|
|
1681
|
+
return !b || b.tabIds.length === 0 ? /* @__PURE__ */ m(c, {}) : null;
|
|
1625
1682
|
},
|
|
1626
|
-
[o.groups,
|
|
1627
|
-
),
|
|
1628
|
-
s.setActiveTab(
|
|
1629
|
-
}, [s]), g = l.useCallback((
|
|
1630
|
-
s.addNewTab({ groupId:
|
|
1631
|
-
}, [s]),
|
|
1632
|
-
s.removeTab(
|
|
1633
|
-
}, [s]),
|
|
1634
|
-
s.setActiveTab(
|
|
1635
|
-
}, [s, n]),
|
|
1636
|
-
const
|
|
1637
|
-
!
|
|
1638
|
-
}, [o.groups, n]),
|
|
1639
|
-
() => ({ getGroup:
|
|
1640
|
-
[
|
|
1683
|
+
[o.groups, c]
|
|
1684
|
+
), f = l.useCallback((T, b) => {
|
|
1685
|
+
s.setActiveTab(T, b);
|
|
1686
|
+
}, [s]), g = l.useCallback((T) => {
|
|
1687
|
+
s.addNewTab({ groupId: T, title: "New Tab", makeActive: !0 });
|
|
1688
|
+
}, [s]), y = l.useCallback((T, b) => {
|
|
1689
|
+
s.removeTab(T, b);
|
|
1690
|
+
}, [s]), h = l.useCallback((T, b, v) => {
|
|
1691
|
+
s.setActiveTab(b, T), n.onStartTabDrag(T, b, v);
|
|
1692
|
+
}, [s, n]), w = l.useCallback((T, b) => {
|
|
1693
|
+
const v = o.groups[T];
|
|
1694
|
+
!v || !v.activeTabId || n.onStartContentDrag(T, v.activeTabId, b);
|
|
1695
|
+
}, [o.groups, n]), I = l.useMemo(
|
|
1696
|
+
() => ({ getGroup: u, getGroupContent: d, onClickTab: f, onAddTab: g, onCloseTab: y, onStartTabDrag: h, onStartContentDrag: w, doubleClickToAdd: r, registerContentContainer: a }),
|
|
1697
|
+
[u, d, f, g, y, h, w, r, a]
|
|
1641
1698
|
);
|
|
1642
|
-
return /* @__PURE__ */ m(
|
|
1643
|
-
},
|
|
1644
|
-
|
|
1699
|
+
return /* @__PURE__ */ m(ue, { value: I, children: t });
|
|
1700
|
+
}, dr = ({
|
|
1701
|
+
children: t,
|
|
1702
|
+
emptyContentComponent: e,
|
|
1703
|
+
doubleClickToAdd: r
|
|
1704
|
+
}) => {
|
|
1705
|
+
const { state: n } = z(), o = l.useMemo(() => {
|
|
1706
|
+
const s = {};
|
|
1707
|
+
for (const [a, i] of Object.entries(n.groups))
|
|
1708
|
+
for (const c of i.tabIds)
|
|
1709
|
+
s[c] = {
|
|
1710
|
+
groupId: a,
|
|
1711
|
+
isActive: c === i.activeTabId
|
|
1712
|
+
};
|
|
1713
|
+
return s;
|
|
1714
|
+
}, [n.groups]);
|
|
1715
|
+
return /* @__PURE__ */ m(ur, { panels: n.panels, placements: o, children: /* @__PURE__ */ m(lr, { emptyContentComponent: e, doubleClickToAdd: r, children: t }) });
|
|
1716
|
+
}, Y = (t, e, r, n) => {
|
|
1717
|
+
if (_(t))
|
|
1645
1718
|
return n;
|
|
1646
1719
|
const o = t.direction, s = o === "vertical" ? r.x + r.w * t.ratio : r.y + r.h * t.ratio;
|
|
1647
1720
|
if (n.push({ path: e, direction: o, parentRect: r, linePos: s }), o === "vertical") {
|
|
1648
1721
|
const c = r.w * t.ratio, u = r.w - c;
|
|
1649
|
-
return
|
|
1722
|
+
return Y(t.a, [...e, "a"], { x: r.x, y: r.y, w: c, h: r.h }, n), Y(t.b, [...e, "b"], { x: r.x + c, y: r.y, w: u, h: r.h }, n), n;
|
|
1650
1723
|
}
|
|
1651
1724
|
const a = r.h * t.ratio, i = r.h - a;
|
|
1652
|
-
return
|
|
1653
|
-
},
|
|
1654
|
-
const { state: e } =
|
|
1655
|
-
if (
|
|
1725
|
+
return Y(t.a, [...e, "a"], { x: r.x, y: r.y, w: r.w, h: a }, n), Y(t.b, [...e, "b"], { x: r.x, y: r.y + a, w: r.w, h: i }, n), n;
|
|
1726
|
+
}, pr = ({ containerRef: t }) => {
|
|
1727
|
+
const { state: e } = z(), { adjustSplitRatio: r } = Ke(), n = l.useMemo(() => Y(e.tree, [], { x: 0, y: 0, w: 100, h: 100 }, []), [e.tree]), [o, s] = l.useState(null);
|
|
1728
|
+
if (rt(() => {
|
|
1656
1729
|
const i = t.current;
|
|
1657
1730
|
if (!i)
|
|
1658
1731
|
return;
|
|
1659
1732
|
const c = () => {
|
|
1660
|
-
const
|
|
1661
|
-
s({ left:
|
|
1733
|
+
const y = i.getBoundingClientRect();
|
|
1734
|
+
s({ left: y.left, top: y.top, width: y.width, height: y.height });
|
|
1662
1735
|
};
|
|
1663
1736
|
c();
|
|
1664
1737
|
function u() {
|
|
1665
1738
|
try {
|
|
1666
|
-
const
|
|
1667
|
-
return typeof
|
|
1739
|
+
const y = window.ResizeObserver;
|
|
1740
|
+
return typeof y == "function" ? y : null;
|
|
1668
1741
|
} catch {
|
|
1669
1742
|
return null;
|
|
1670
1743
|
}
|
|
1671
1744
|
}
|
|
1672
|
-
const d = u(),
|
|
1673
|
-
|
|
1674
|
-
const
|
|
1675
|
-
return window.addEventListener("scroll",
|
|
1676
|
-
window.removeEventListener("scroll",
|
|
1745
|
+
const d = u(), f = d ? new d(() => c()) : null;
|
|
1746
|
+
f && f.observe(i);
|
|
1747
|
+
const g = () => c();
|
|
1748
|
+
return window.addEventListener("scroll", g, !0), () => {
|
|
1749
|
+
window.removeEventListener("scroll", g, !0), f && f.disconnect();
|
|
1677
1750
|
};
|
|
1678
1751
|
}, [t, e.tree]), !o)
|
|
1679
1752
|
return null;
|
|
@@ -1683,7 +1756,7 @@ const fe = (t, e) => {
|
|
|
1683
1756
|
top: o.top + o.height * i.parentRect.y / 100,
|
|
1684
1757
|
width: o.width * i.parentRect.w / 100,
|
|
1685
1758
|
height: o.height * i.parentRect.h / 100
|
|
1686
|
-
}, d =
|
|
1759
|
+
}, d = Jt;
|
|
1687
1760
|
if (i.direction === "vertical") {
|
|
1688
1761
|
const h = u.left + u.width * (i.linePos - i.parentRect.x) / i.parentRect.w, w = {
|
|
1689
1762
|
position: "fixed",
|
|
@@ -1694,32 +1767,32 @@ const fe = (t, e) => {
|
|
|
1694
1767
|
cursor: "col-resize",
|
|
1695
1768
|
pointerEvents: "auto"
|
|
1696
1769
|
};
|
|
1697
|
-
return /* @__PURE__ */ m("div", { style: w, children: /* @__PURE__ */ m(
|
|
1698
|
-
const
|
|
1699
|
-
r({ path: i.path, deltaRatio:
|
|
1770
|
+
return /* @__PURE__ */ m("div", { style: w, children: /* @__PURE__ */ m(ot, { direction: "vertical", onResize: (T) => {
|
|
1771
|
+
const b = o.width * i.parentRect.w / 100, v = b === 0 ? 0 : T / b;
|
|
1772
|
+
r({ path: i.path, deltaRatio: v });
|
|
1700
1773
|
} }) }, `split-${c}`);
|
|
1701
1774
|
}
|
|
1702
|
-
const
|
|
1775
|
+
const f = u.top + u.height * (i.linePos - i.parentRect.y) / i.parentRect.h, g = {
|
|
1703
1776
|
position: "fixed",
|
|
1704
1777
|
left: Math.round(u.left),
|
|
1705
|
-
top: `calc(${Math.round(
|
|
1778
|
+
top: `calc(${Math.round(f)}px - ${d} / 2)`,
|
|
1706
1779
|
width: Math.round(u.width),
|
|
1707
1780
|
height: d,
|
|
1708
1781
|
cursor: "row-resize",
|
|
1709
1782
|
pointerEvents: "auto"
|
|
1710
1783
|
};
|
|
1711
|
-
return /* @__PURE__ */ m("div", { style:
|
|
1712
|
-
const w = o.height * i.parentRect.h / 100,
|
|
1713
|
-
r({ path: i.path, deltaRatio:
|
|
1784
|
+
return /* @__PURE__ */ m("div", { style: g, children: /* @__PURE__ */ m(ot, { direction: "horizontal", onResize: (h) => {
|
|
1785
|
+
const w = o.height * i.parentRect.h / 100, I = w === 0 ? 0 : h / w;
|
|
1786
|
+
r({ path: i.path, deltaRatio: I });
|
|
1714
1787
|
} }) }, `split-${c}`);
|
|
1715
1788
|
};
|
|
1716
1789
|
return /* @__PURE__ */ m("div", { style: { position: "fixed", inset: 0, pointerEvents: "none" }, children: n.map((i, c) => a(i, c)) });
|
|
1717
|
-
},
|
|
1790
|
+
}, fr = {
|
|
1718
1791
|
position: "relative",
|
|
1719
1792
|
display: "flex",
|
|
1720
1793
|
width: "100%",
|
|
1721
1794
|
height: "100%"
|
|
1722
|
-
},
|
|
1795
|
+
}, br = ({
|
|
1723
1796
|
state: t,
|
|
1724
1797
|
layoutMode: e,
|
|
1725
1798
|
gridTracksInteractive: r,
|
|
@@ -1727,14 +1800,14 @@ const fe = (t, e) => {
|
|
|
1727
1800
|
tabBarComponent: o,
|
|
1728
1801
|
panelGroupComponent: s
|
|
1729
1802
|
}) => {
|
|
1730
|
-
const a = (c) => n ? /* @__PURE__ */ m(n, { groupId: c }) : /* @__PURE__ */ m(
|
|
1803
|
+
const a = (c) => n ? /* @__PURE__ */ m(n, { groupId: c }) : /* @__PURE__ */ m(Ge, { id: c, TabBarComponent: o, PanelGroupComponent: s });
|
|
1731
1804
|
if (e === "grid") {
|
|
1732
|
-
const c =
|
|
1733
|
-
return /* @__PURE__ */ m(
|
|
1805
|
+
const c = ae(t, a, !!r);
|
|
1806
|
+
return /* @__PURE__ */ m(st, { config: c.config, layers: c.layers });
|
|
1734
1807
|
}
|
|
1735
|
-
const i =
|
|
1736
|
-
return /* @__PURE__ */ m(
|
|
1737
|
-
},
|
|
1808
|
+
const i = ie(t, a);
|
|
1809
|
+
return /* @__PURE__ */ m(st, { config: i.config, layers: i.layers });
|
|
1810
|
+
}, gr = ({
|
|
1738
1811
|
containerRef: t,
|
|
1739
1812
|
layoutMode: e,
|
|
1740
1813
|
gridTracksInteractive: r,
|
|
@@ -1746,30 +1819,30 @@ const fe = (t, e) => {
|
|
|
1746
1819
|
panelGroupComponent: c,
|
|
1747
1820
|
splitLimits: u,
|
|
1748
1821
|
emptyContentComponent: d,
|
|
1749
|
-
doubleClickToAdd:
|
|
1822
|
+
doubleClickToAdd: f
|
|
1750
1823
|
}) => {
|
|
1751
|
-
const { state:
|
|
1752
|
-
({ targetGroupId:
|
|
1753
|
-
if (
|
|
1824
|
+
const { state: g } = z(), { onCommitContentDrop: y, onCommitTabDrop: h } = or(), w = l.useMemo(() => ({ ...fr, ...s }), [s]), I = l.useCallback(
|
|
1825
|
+
({ targetGroupId: T, zone: b }) => {
|
|
1826
|
+
if (b === "center")
|
|
1754
1827
|
return !0;
|
|
1755
|
-
const
|
|
1756
|
-
return
|
|
1828
|
+
const v = b === "left" || b === "right" ? "vertical" : "horizontal";
|
|
1829
|
+
return nt(g.tree, T, v, u);
|
|
1757
1830
|
},
|
|
1758
|
-
[
|
|
1831
|
+
[g.tree, u]
|
|
1759
1832
|
);
|
|
1760
|
-
return /* @__PURE__ */ m(
|
|
1761
|
-
|
|
1833
|
+
return /* @__PURE__ */ m(le, { children: /* @__PURE__ */ H(
|
|
1834
|
+
Ie,
|
|
1762
1835
|
{
|
|
1763
1836
|
containerRef: t,
|
|
1764
1837
|
dragThresholdPx: n,
|
|
1765
|
-
onCommitContentDrop:
|
|
1838
|
+
onCommitContentDrop: y,
|
|
1766
1839
|
onCommitTabDrop: h,
|
|
1767
|
-
isContentZoneAllowed:
|
|
1840
|
+
isContentZoneAllowed: I,
|
|
1768
1841
|
children: [
|
|
1769
|
-
/* @__PURE__ */ m(
|
|
1770
|
-
|
|
1842
|
+
/* @__PURE__ */ m(dr, { emptyContentComponent: d, doubleClickToAdd: f, children: /* @__PURE__ */ m("div", { ref: t, className: a, style: w, children: /* @__PURE__ */ m(
|
|
1843
|
+
br,
|
|
1771
1844
|
{
|
|
1772
|
-
state:
|
|
1845
|
+
state: g,
|
|
1773
1846
|
layoutMode: e,
|
|
1774
1847
|
gridTracksInteractive: r,
|
|
1775
1848
|
view: o,
|
|
@@ -1777,18 +1850,18 @@ const fe = (t, e) => {
|
|
|
1777
1850
|
panelGroupComponent: c
|
|
1778
1851
|
}
|
|
1779
1852
|
) }) }),
|
|
1780
|
-
/* @__PURE__ */ m(
|
|
1781
|
-
/* @__PURE__ */ m(
|
|
1853
|
+
/* @__PURE__ */ m(pr, { containerRef: t }),
|
|
1854
|
+
/* @__PURE__ */ m(hr, {})
|
|
1782
1855
|
]
|
|
1783
1856
|
}
|
|
1784
1857
|
) });
|
|
1785
|
-
},
|
|
1786
|
-
const t =
|
|
1858
|
+
}, hr = () => {
|
|
1859
|
+
const t = W();
|
|
1787
1860
|
return /* @__PURE__ */ H(et, { children: [
|
|
1788
|
-
/* @__PURE__ */ m(
|
|
1789
|
-
/* @__PURE__ */ m(
|
|
1861
|
+
/* @__PURE__ */ m(Ae, { suggest: t.suggest }),
|
|
1862
|
+
/* @__PURE__ */ m(Be, {})
|
|
1790
1863
|
] });
|
|
1791
|
-
},
|
|
1864
|
+
}, Sr = ({
|
|
1792
1865
|
initialState: t,
|
|
1793
1866
|
createGroupId: e,
|
|
1794
1867
|
createPanelId: r,
|
|
@@ -1800,9 +1873,9 @@ const fe = (t, e) => {
|
|
|
1800
1873
|
state: c,
|
|
1801
1874
|
onStateChange: u,
|
|
1802
1875
|
className: d,
|
|
1803
|
-
style:
|
|
1804
|
-
tabBarComponent:
|
|
1805
|
-
panelGroupComponent:
|
|
1876
|
+
style: f,
|
|
1877
|
+
tabBarComponent: g,
|
|
1878
|
+
panelGroupComponent: y,
|
|
1806
1879
|
splitLimits: h,
|
|
1807
1880
|
doubleClickToAdd: w
|
|
1808
1881
|
}) => {
|
|
@@ -1816,9 +1889,9 @@ const fe = (t, e) => {
|
|
|
1816
1889
|
throw new Error("PanelSystem(layoutMode='grid') requires explicit 'gridTracksInteractive' flag.");
|
|
1817
1890
|
if (s === void 0)
|
|
1818
1891
|
throw new Error("PanelSystem requires explicit 'dragThresholdPx' value.");
|
|
1819
|
-
const
|
|
1892
|
+
const I = l.useRef(null), T = l.useMemo(() => Gt(h), [h]);
|
|
1820
1893
|
return /* @__PURE__ */ m(
|
|
1821
|
-
|
|
1894
|
+
rr,
|
|
1822
1895
|
{
|
|
1823
1896
|
initialState: t,
|
|
1824
1897
|
createGroupId: e,
|
|
@@ -1826,21 +1899,21 @@ const fe = (t, e) => {
|
|
|
1826
1899
|
state: c,
|
|
1827
1900
|
onStateChange: u,
|
|
1828
1901
|
splitLimits: h,
|
|
1829
|
-
children: /* @__PURE__ */ H(
|
|
1830
|
-
/* @__PURE__ */ m(
|
|
1902
|
+
children: /* @__PURE__ */ H(ne, { children: [
|
|
1903
|
+
/* @__PURE__ */ m(sr, {}),
|
|
1831
1904
|
/* @__PURE__ */ m(
|
|
1832
|
-
|
|
1905
|
+
gr,
|
|
1833
1906
|
{
|
|
1834
|
-
containerRef:
|
|
1907
|
+
containerRef: I,
|
|
1835
1908
|
layoutMode: n,
|
|
1836
1909
|
gridTracksInteractive: o,
|
|
1837
1910
|
dragThresholdPx: s,
|
|
1838
1911
|
view: a,
|
|
1839
|
-
style:
|
|
1912
|
+
style: f,
|
|
1840
1913
|
className: d,
|
|
1841
|
-
tabBarComponent:
|
|
1842
|
-
panelGroupComponent:
|
|
1843
|
-
splitLimits:
|
|
1914
|
+
tabBarComponent: g,
|
|
1915
|
+
panelGroupComponent: y,
|
|
1916
|
+
splitLimits: T,
|
|
1844
1917
|
emptyContentComponent: i,
|
|
1845
1918
|
doubleClickToAdd: w
|
|
1846
1919
|
}
|
|
@@ -1850,16 +1923,16 @@ const fe = (t, e) => {
|
|
|
1850
1923
|
);
|
|
1851
1924
|
};
|
|
1852
1925
|
export {
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1926
|
+
Mr as CSS_VAR_PREFIX,
|
|
1927
|
+
Rr as Drawer,
|
|
1928
|
+
Pr as DrawerLayers,
|
|
1929
|
+
st as GridLayout,
|
|
1930
|
+
Tr as HorizontalDivider,
|
|
1931
|
+
Sr as PanelSystem,
|
|
1932
|
+
ot as ResizeHandle,
|
|
1933
|
+
Gr as buildInitialState,
|
|
1934
|
+
Dr as runTransition,
|
|
1935
|
+
xr as useLayerDragHandle,
|
|
1936
|
+
Ar as useTransitionState
|
|
1864
1937
|
};
|
|
1865
1938
|
//# sourceMappingURL=index.js.map
|