react-panel-layout 0.2.0
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 +121 -0
- package/dist/GridLayout-CmzKfbPP.js +1295 -0
- package/dist/GridLayout-CmzKfbPP.js.map +1 -0
- package/dist/GridLayout-Dx3Qofl0.cjs +2 -0
- package/dist/GridLayout-Dx3Qofl0.cjs.map +1 -0
- package/dist/PanelSystemContext.d.ts +25 -0
- package/dist/components/grid/GridLayerList.d.ts +10 -0
- package/dist/components/grid/GridLayerResizeHandles.d.ts +22 -0
- package/dist/components/grid/GridLayout.d.ts +11 -0
- package/dist/components/grid/GridTrackResizeHandle.d.ts +18 -0
- package/dist/components/paneling/FloatingPanelFrame.d.ts +32 -0
- package/dist/components/panels/DropSuggestOverlay.d.ts +13 -0
- package/dist/components/panels/PanelGroupView.d.ts +20 -0
- package/dist/components/resizer/HorizontalDivider.d.ts +14 -0
- package/dist/components/resizer/ResizeHandle.d.ts +24 -0
- package/dist/components/tabs/TabBar.d.ts +22 -0
- package/dist/components/tabs/TabBarTab.d.ts +20 -0
- package/dist/components/tabs/TabDragOverlay.d.ts +5 -0
- package/dist/components/window/DialogOverlay.d.ts +17 -0
- package/dist/components/window/Drawer.d.ts +22 -0
- package/dist/components/window/DrawerLayers.d.ts +9 -0
- package/dist/components/window/PopupLayerPortal.d.ts +10 -0
- package/dist/config/PanelContentDeclaration.d.ts +79 -0
- package/dist/config/index.d.ts +32 -0
- package/dist/config/panelRouter.d.ts +57 -0
- package/dist/config.cjs +2 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.js +210 -0
- package/dist/config.js.map +1 -0
- package/dist/constants/styles.d.ts +181 -0
- package/dist/floating/index.d.ts +8 -0
- package/dist/floating.cjs +2 -0
- package/dist/floating.cjs.map +1 -0
- package/dist/floating.js +67 -0
- package/dist/floating.js.map +1 -0
- package/dist/hooks/useCSSMatrix.d.ts +47 -0
- package/dist/hooks/useClonedElementPreview.d.ts +7 -0
- package/dist/hooks/useDocumentPointerEvents.d.ts +37 -0
- package/dist/hooks/useEffectEvent.d.ts +17 -0
- package/dist/hooks/useElementComponentWrapper.d.ts +18 -0
- package/dist/hooks/useIntersectionObserver.d.ts +20 -0
- package/dist/hooks/useIsomorphicLayoutEffect.d.ts +23 -0
- package/dist/hooks/useResizeObserver.d.ts +15 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +1863 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/grid/GridLayoutContext.d.ts +34 -0
- package/dist/modules/grid/LayerInstanceContext.d.ts +26 -0
- package/dist/modules/grid/useGridPlacements.d.ts +7 -0
- package/dist/modules/grid/useGridTracks.d.ts +26 -0
- package/dist/modules/grid/useLayerDragHandle.d.ts +2 -0
- package/dist/modules/grid/useLayerInteractions.d.ts +12 -0
- package/dist/modules/keybindings/KeybindingsProvider.d.ts +17 -0
- package/dist/modules/panels/dom/DomRegistry.d.ts +19 -0
- package/dist/modules/panels/index.d.ts +11 -0
- package/dist/modules/panels/interactions/InteractionsContext.d.ts +50 -0
- package/dist/modules/panels/interactions/InteractionsContext.test.d.ts +1 -0
- package/dist/modules/panels/interactions/dnd.d.ts +5 -0
- package/dist/modules/panels/keybindings/KeybindingsInstaller.d.ts +5 -0
- package/dist/modules/panels/layout/adapter.d.ts +21 -0
- package/dist/modules/panels/rendering/GroupContainer.d.ts +11 -0
- package/dist/modules/panels/rendering/RenderBridge.d.ts +8 -0
- package/dist/modules/panels/rendering/RenderContext.d.ts +19 -0
- package/dist/modules/panels/state/PanelSplitHandles.d.ts +8 -0
- package/dist/modules/panels/state/PanelSystemContext.d.ts +148 -0
- package/dist/modules/panels/state/StateContext.d.ts +5 -0
- package/dist/modules/panels/state/cleanup.d.ts +11 -0
- package/dist/modules/panels/state/commands.d.ts +16 -0
- package/dist/modules/panels/state/focus/Context.d.ts +14 -0
- package/dist/modules/panels/state/focus/logic.d.ts +9 -0
- package/dist/modules/panels/state/groups/Context.d.ts +19 -0
- package/dist/modules/panels/state/groups/logic.d.ts +11 -0
- package/dist/modules/panels/state/splitLimits.d.ts +15 -0
- package/dist/modules/panels/state/tree/Context.d.ts +16 -0
- package/dist/modules/panels/state/tree/logic.d.ts +42 -0
- package/dist/modules/panels/state/types.d.ts +135 -0
- package/dist/modules/panels/system/PanelSystem.d.ts +6 -0
- package/dist/modules/resizer/useResizeDrag.d.ts +26 -0
- package/dist/modules/window/useDrawerState.d.ts +6 -0
- package/dist/styles-BMEhL6I0.cjs +2 -0
- package/dist/styles-BMEhL6I0.cjs.map +1 -0
- package/dist/styles-BnvLfp6e.js +49 -0
- package/dist/styles-BnvLfp6e.js.map +1 -0
- package/dist/types.d.ts +114 -0
- package/dist/utils/CSSMatrix.d.ts +42 -0
- package/dist/utils/dialogUtils.d.ts +18 -0
- package/dist/utils/math.d.ts +5 -0
- package/dist/utils/polyfills/createDialogPolyfill.d.ts +8 -0
- package/dist/utils/typedActions.d.ts +37 -0
- package/package.json +78 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1863 @@
|
|
|
1
|
+
import { u as Rt, a as Pt, b as Ct, c as J, d as Dt, e as _, f as At, t as kt, R as nt, G as ot } from "./GridLayout-CmzKfbPP.js";
|
|
2
|
+
import { D as vr, g as Ir } from "./GridLayout-CmzKfbPP.js";
|
|
3
|
+
import { jsx as m, jsxs as H, Fragment as et } from "react/jsx-runtime";
|
|
4
|
+
import * as l from "react";
|
|
5
|
+
import { C as _t, a as Mt, b as Ot, H as Bt, D as Lt, c as $t, d as Ht, e as Nt, f as zt, g as Xt, T as Yt, h as Ft, i as jt, j as Vt, k as Kt, l as Ut, m as qt, S as Wt } from "./styles-BnvLfp6e.js";
|
|
6
|
+
import { n as yr } from "./styles-BnvLfp6e.js";
|
|
7
|
+
const Zt = (t) => ({
|
|
8
|
+
width: Bt,
|
|
9
|
+
cursor: "col-resize",
|
|
10
|
+
position: "relative",
|
|
11
|
+
userSelect: "none",
|
|
12
|
+
backgroundColor: t === "drag" ? _t : t === "hover" ? Mt : Ot
|
|
13
|
+
}), pr = ({ onResize: t, component: e, element: r }) => {
|
|
14
|
+
const { ref: n, isDragging: o, onPointerDown: s } = Rt({
|
|
15
|
+
axis: "x",
|
|
16
|
+
onResize: t
|
|
17
|
+
}), [a, i] = l.useState(!1), c = {
|
|
18
|
+
ref: n,
|
|
19
|
+
style: Zt(o ? "drag" : a ? "hover" : "idle"),
|
|
20
|
+
role: "separator",
|
|
21
|
+
"aria-orientation": "vertical",
|
|
22
|
+
"data-dragging": o ? "true" : void 0,
|
|
23
|
+
onPointerDown: s,
|
|
24
|
+
onPointerEnter: () => i(!0),
|
|
25
|
+
onPointerLeave: () => i(!1)
|
|
26
|
+
};
|
|
27
|
+
return r ? l.cloneElement(r, c) : e ? /* @__PURE__ */ m(e, { ...c }) : /* @__PURE__ */ m("div", { ...c });
|
|
28
|
+
}, fr = () => {
|
|
29
|
+
const { layerId: t } = Pt(), { getLayerHandleProps: e } = Ct();
|
|
30
|
+
return l.useMemo(() => e(t), [e, t]);
|
|
31
|
+
}, lt = l.createContext(null), Jt = () => {
|
|
32
|
+
const t = l.useContext(lt);
|
|
33
|
+
if (!t)
|
|
34
|
+
throw new Error("useKeybindings must be used within KeybindingsProvider");
|
|
35
|
+
return t;
|
|
36
|
+
}, Qt = (t) => {
|
|
37
|
+
const e = [];
|
|
38
|
+
t.metaKey && e.push("Mod"), t.ctrlKey && e.push("Ctrl"), t.altKey && e.push("Alt"), t.shiftKey && e.push("Shift");
|
|
39
|
+
const r = t.key.length === 1 ? t.key.toUpperCase() : t.key;
|
|
40
|
+
return e.push(r), e.join("-");
|
|
41
|
+
}, te = ({ children: t, configure: e }) => {
|
|
42
|
+
const r = l.useRef({}), n = l.useCallback((a, i) => {
|
|
43
|
+
r.current = { ...r.current, [a]: i };
|
|
44
|
+
}, []), o = l.useCallback((a) => {
|
|
45
|
+
const i = { ...r.current };
|
|
46
|
+
delete i[a], r.current = i;
|
|
47
|
+
}, []);
|
|
48
|
+
l.useEffect(() => {
|
|
49
|
+
const a = (i) => {
|
|
50
|
+
const c = Qt(i), u = r.current[c];
|
|
51
|
+
u && u(i);
|
|
52
|
+
};
|
|
53
|
+
return window.addEventListener("keydown", a), () => {
|
|
54
|
+
window.removeEventListener("keydown", a);
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
const s = l.useMemo(() => ({ register: n, unregister: o }), [n, o]);
|
|
58
|
+
return l.useEffect(() => {
|
|
59
|
+
e && e(s);
|
|
60
|
+
}, [s, e]), /* @__PURE__ */ m(lt.Provider, { value: s, children: t });
|
|
61
|
+
}, ee = (t, e) => {
|
|
62
|
+
t.register("Mod-\\", (r) => {
|
|
63
|
+
r.preventDefault(), e.splitFocused("vertical");
|
|
64
|
+
}), t.register("Mod-Shift-\\", (r) => {
|
|
65
|
+
r.preventDefault(), e.splitFocused("horizontal");
|
|
66
|
+
});
|
|
67
|
+
for (const r of [1, 2, 3, 4, 5, 6, 7, 8, 9])
|
|
68
|
+
t.register(`Mod-${String(r)}`, (n) => {
|
|
69
|
+
n.preventDefault(), e.focusGroupIndex(r);
|
|
70
|
+
});
|
|
71
|
+
t.register("Alt-ArrowRight", (r) => {
|
|
72
|
+
r.preventDefault(), e.focusNextGroup();
|
|
73
|
+
}), t.register("Alt-ArrowLeft", (r) => {
|
|
74
|
+
r.preventDefault(), e.focusPrevGroup();
|
|
75
|
+
});
|
|
76
|
+
}, re = (t) => t.type === "group", dt = (t, e = { x: 0, y: 0, w: 100, h: 100 }) => {
|
|
77
|
+
const r = /* @__PURE__ */ new Map(), n = (o, s) => {
|
|
78
|
+
if (re(o)) {
|
|
79
|
+
r.set(o.groupId, s);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (o.direction === "vertical") {
|
|
83
|
+
const c = s.w * o.ratio, u = s.w - c;
|
|
84
|
+
n(o.a, { x: s.x, y: s.y, w: c, h: s.h }), n(o.b, { x: s.x + c, y: s.y, w: u, h: s.h });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const a = s.h * o.ratio, i = s.h - a;
|
|
88
|
+
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
|
+
};
|
|
90
|
+
return n(t, e), r;
|
|
91
|
+
}, ne = (t, e) => {
|
|
92
|
+
const r = dt(t.tree), n = {
|
|
93
|
+
areas: [["root"]],
|
|
94
|
+
rows: [{ size: "1fr" }],
|
|
95
|
+
columns: [{ size: "1fr" }],
|
|
96
|
+
gap: "0px",
|
|
97
|
+
style: { position: "relative" }
|
|
98
|
+
}, o = Array.from(r.entries()).map(([s, a]) => {
|
|
99
|
+
const i = {
|
|
100
|
+
position: "absolute",
|
|
101
|
+
left: `${a.x}%`,
|
|
102
|
+
top: `${a.y}%`,
|
|
103
|
+
width: `${a.w}%`,
|
|
104
|
+
height: `${a.h}%`,
|
|
105
|
+
overflow: "hidden",
|
|
106
|
+
display: "flex",
|
|
107
|
+
flexDirection: "column"
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
id: s,
|
|
111
|
+
positionMode: "absolute",
|
|
112
|
+
style: i,
|
|
113
|
+
component: e(s)
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
return { config: n, layers: o };
|
|
117
|
+
}, oe = (t, e, r) => {
|
|
118
|
+
const n = dt(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, b, y) => {
|
|
119
|
+
for (const [f, I] of n.entries())
|
|
120
|
+
if (h >= I.x && w <= I.x + I.w && b >= I.y && y <= I.y + I.h)
|
|
121
|
+
return f;
|
|
122
|
+
return ".";
|
|
123
|
+
}, g = [];
|
|
124
|
+
for (let h = 0; h < s.length - 1; h += 1) {
|
|
125
|
+
const w = [];
|
|
126
|
+
for (let b = 0; b < o.length - 1; b += 1)
|
|
127
|
+
w.push(d(o[b], o[b + 1], s[h], s[h + 1]));
|
|
128
|
+
g.push(w);
|
|
129
|
+
}
|
|
130
|
+
const v = {
|
|
131
|
+
areas: g,
|
|
132
|
+
rows: u,
|
|
133
|
+
columns: c,
|
|
134
|
+
gap: "0px"
|
|
135
|
+
}, T = Array.from(n.keys()).map((h) => ({
|
|
136
|
+
id: h,
|
|
137
|
+
gridArea: h,
|
|
138
|
+
component: e(h)
|
|
139
|
+
}));
|
|
140
|
+
return { config: v, layers: T };
|
|
141
|
+
}, pt = l.createContext(null), se = () => {
|
|
142
|
+
const t = l.useContext(pt);
|
|
143
|
+
if (!t)
|
|
144
|
+
throw new Error("usePanelRenderContext must be used within PanelRenderProvider");
|
|
145
|
+
return t;
|
|
146
|
+
}, ie = ({ value: t, children: e }) => /* @__PURE__ */ m(pt.Provider, { value: t, children: e }), ft = l.createContext(null), bt = () => {
|
|
147
|
+
const t = l.useContext(ft);
|
|
148
|
+
if (!t)
|
|
149
|
+
throw new Error("useDomRegistry must be used within DomRegistryProvider");
|
|
150
|
+
return t;
|
|
151
|
+
}, ae = ({ children: t }) => {
|
|
152
|
+
const e = l.useRef(/* @__PURE__ */ new Map()), r = l.useCallback((c) => {
|
|
153
|
+
const u = e.current.get(c);
|
|
154
|
+
if (u)
|
|
155
|
+
return u;
|
|
156
|
+
const d = { group: null, tabbar: null, content: null };
|
|
157
|
+
return e.current.set(c, d), d;
|
|
158
|
+
}, []), n = l.useCallback(
|
|
159
|
+
(c, u) => {
|
|
160
|
+
const d = r(c);
|
|
161
|
+
if (d.group = u, u === null) {
|
|
162
|
+
const g = e.current.get(c);
|
|
163
|
+
(g ? g.tabbar === null && g.content === null : !1) && e.current.delete(c);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
[r]
|
|
167
|
+
), o = l.useCallback(
|
|
168
|
+
(c, u) => {
|
|
169
|
+
const d = r(c);
|
|
170
|
+
if (d.tabbar = u, u === null) {
|
|
171
|
+
const g = e.current.get(c);
|
|
172
|
+
(g ? g.group === null && g.content === null : !1) && e.current.delete(c);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
[r]
|
|
176
|
+
), s = l.useCallback(
|
|
177
|
+
(c, u) => {
|
|
178
|
+
const d = r(c);
|
|
179
|
+
if (d.content = u, u === null) {
|
|
180
|
+
const g = e.current.get(c);
|
|
181
|
+
(g ? g.group === null && g.tabbar === null : !1) && e.current.delete(c);
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
[r]
|
|
185
|
+
), a = l.useCallback(() => e.current, []), i = l.useMemo(() => ({ setGroupEl: n, setTabbarEl: o, setContentEl: s, getAll: a }), [n, o, s, a]);
|
|
186
|
+
return /* @__PURE__ */ m(ft.Provider, { value: i, children: t });
|
|
187
|
+
}, ce = {
|
|
188
|
+
display: "flex",
|
|
189
|
+
flexDirection: "column",
|
|
190
|
+
width: "100%",
|
|
191
|
+
height: "100%"
|
|
192
|
+
}, ue = {
|
|
193
|
+
flex: "1 1 auto",
|
|
194
|
+
minWidth: 0,
|
|
195
|
+
minHeight: 0,
|
|
196
|
+
position: "relative",
|
|
197
|
+
overflow: "hidden"
|
|
198
|
+
};
|
|
199
|
+
function le(t, e, r, n) {
|
|
200
|
+
return t ? l.cloneElement(t, r, n) : e ? /* @__PURE__ */ m(e, { ...r, children: n }) : /* @__PURE__ */ m("div", { ...r, children: n });
|
|
201
|
+
}
|
|
202
|
+
function de(t, e, r, n) {
|
|
203
|
+
return t ? l.cloneElement(t, r, n) : e ? /* @__PURE__ */ m(e, { ...r, children: n }) : /* @__PURE__ */ m("div", { ...r, children: n });
|
|
204
|
+
}
|
|
205
|
+
const pe = ({
|
|
206
|
+
group: t,
|
|
207
|
+
tabbar: e,
|
|
208
|
+
content: r,
|
|
209
|
+
onContentPointerDown: n,
|
|
210
|
+
groupRef: o,
|
|
211
|
+
contentRef: s,
|
|
212
|
+
component: a,
|
|
213
|
+
element: i,
|
|
214
|
+
contentComponent: c,
|
|
215
|
+
contentElement: u
|
|
216
|
+
}) => {
|
|
217
|
+
const d = {
|
|
218
|
+
ref: o,
|
|
219
|
+
style: ce,
|
|
220
|
+
"data-group-id": t.id
|
|
221
|
+
}, v = le(u, c, {
|
|
222
|
+
ref: s,
|
|
223
|
+
style: ue,
|
|
224
|
+
"data-dnd-zone": "content",
|
|
225
|
+
onPointerDown: n
|
|
226
|
+
}, r);
|
|
227
|
+
return de(i, a, d, /* @__PURE__ */ H(et, { children: [
|
|
228
|
+
e,
|
|
229
|
+
v
|
|
230
|
+
] }));
|
|
231
|
+
}, gt = l.memo(pe, (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);
|
|
232
|
+
gt.displayName = "PanelGroupView";
|
|
233
|
+
const V = (t, e, r) => {
|
|
234
|
+
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
|
+
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
|
+
};
|
|
237
|
+
function A(t, e) {
|
|
238
|
+
if (!e) {
|
|
239
|
+
const n = (() => ({ type: t }));
|
|
240
|
+
return Object.defineProperty(n, "type", {
|
|
241
|
+
value: t,
|
|
242
|
+
writable: !1,
|
|
243
|
+
enumerable: !0
|
|
244
|
+
}), n;
|
|
245
|
+
}
|
|
246
|
+
const r = ((...n) => {
|
|
247
|
+
const o = e(...n);
|
|
248
|
+
return typeof o > "u" ? { type: t } : { type: t, payload: o };
|
|
249
|
+
});
|
|
250
|
+
return Object.defineProperty(r, "type", {
|
|
251
|
+
value: t,
|
|
252
|
+
writable: !1,
|
|
253
|
+
enumerable: !0
|
|
254
|
+
}), r;
|
|
255
|
+
}
|
|
256
|
+
const fe = (t, e) => {
|
|
257
|
+
const r = {};
|
|
258
|
+
return Object.keys(t).forEach((n) => {
|
|
259
|
+
const o = t[n];
|
|
260
|
+
r[n] = ((...s) => {
|
|
261
|
+
const a = o(...s);
|
|
262
|
+
return e(a), a;
|
|
263
|
+
});
|
|
264
|
+
}), r;
|
|
265
|
+
}, ht = (t, e) => {
|
|
266
|
+
const r = {};
|
|
267
|
+
return Object.keys(e).forEach((n) => {
|
|
268
|
+
const o = e[n];
|
|
269
|
+
if (!o)
|
|
270
|
+
return;
|
|
271
|
+
const s = t[n];
|
|
272
|
+
if (!s)
|
|
273
|
+
throw new Error(`Missing action creator for key "${String(n)}"`);
|
|
274
|
+
r[s.type] = o;
|
|
275
|
+
}), r;
|
|
276
|
+
}, mt = { phase: { kind: "idle" }, suggest: null, pointer: null, tabbarHover: null, draggingTabElement: null }, D = {
|
|
277
|
+
startContent: A(
|
|
278
|
+
"START_CONTENT",
|
|
279
|
+
(t) => t
|
|
280
|
+
),
|
|
281
|
+
startTab: A(
|
|
282
|
+
"START_TAB",
|
|
283
|
+
(t) => t
|
|
284
|
+
),
|
|
285
|
+
setSuggest: A("SET_SUGGEST", (t) => t),
|
|
286
|
+
setPointer: A("SET_POINTER", (t) => t),
|
|
287
|
+
setTabbarHover: A(
|
|
288
|
+
"SET_TABBAR_HOVER",
|
|
289
|
+
(t) => t
|
|
290
|
+
),
|
|
291
|
+
reset: A("RESET")
|
|
292
|
+
}, be = ht(D, {
|
|
293
|
+
startContent: (t, e) => ({
|
|
294
|
+
phase: {
|
|
295
|
+
kind: "content",
|
|
296
|
+
startX: e.payload.x,
|
|
297
|
+
startY: e.payload.y,
|
|
298
|
+
fromGroupId: e.payload.groupId,
|
|
299
|
+
tabId: e.payload.tabId,
|
|
300
|
+
cache: e.payload.cache
|
|
301
|
+
},
|
|
302
|
+
suggest: null,
|
|
303
|
+
pointer: null,
|
|
304
|
+
tabbarHover: null,
|
|
305
|
+
draggingTabElement: null
|
|
306
|
+
}),
|
|
307
|
+
startTab: (t, e) => ({
|
|
308
|
+
phase: {
|
|
309
|
+
kind: "tab",
|
|
310
|
+
startX: e.payload.x,
|
|
311
|
+
startY: e.payload.y,
|
|
312
|
+
fromGroupId: e.payload.groupId,
|
|
313
|
+
tabId: e.payload.tabId,
|
|
314
|
+
cache: e.payload.cache
|
|
315
|
+
},
|
|
316
|
+
suggest: null,
|
|
317
|
+
pointer: null,
|
|
318
|
+
tabbarHover: null,
|
|
319
|
+
draggingTabElement: e.payload.element
|
|
320
|
+
}),
|
|
321
|
+
setSuggest: (t, e) => ({ ...t, suggest: e.payload }),
|
|
322
|
+
setPointer: (t, e) => ({ ...t, pointer: e.payload }),
|
|
323
|
+
setTabbarHover: (t, e) => ({ ...t, tabbarHover: e.payload }),
|
|
324
|
+
reset: () => mt
|
|
325
|
+
}), ge = (t, e) => {
|
|
326
|
+
const r = be[e.type];
|
|
327
|
+
return r ? r(t, e, void 0) : t;
|
|
328
|
+
}, vt = l.createContext(null), q = () => {
|
|
329
|
+
const t = l.useContext(vt);
|
|
330
|
+
if (!t)
|
|
331
|
+
throw new Error("usePanelInteractions must be used within InteractionsProvider");
|
|
332
|
+
return t;
|
|
333
|
+
}, he = ({
|
|
334
|
+
containerRef: t,
|
|
335
|
+
dragThresholdPx: e,
|
|
336
|
+
onCommitContentDrop: r,
|
|
337
|
+
onCommitTabDrop: n,
|
|
338
|
+
isContentZoneAllowed: o,
|
|
339
|
+
children: s
|
|
340
|
+
}) => {
|
|
341
|
+
const [a, i] = l.useReducer(ge, mt), c = bt(), u = l.useCallback(() => {
|
|
342
|
+
const b = Array.from(c.getAll().entries()), y = b.map(([p, G]) => ({ gid: p, el: G.content ?? G.group })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() })), f = b.map(([p, G]) => ({ gid: p, el: G.tabbar })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() })), I = b.map(([p, G]) => ({ gid: p, el: G.content ?? G.group })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() }));
|
|
343
|
+
return { groups: y, tabbars: f, contents: I };
|
|
344
|
+
}, [c]), d = J((b) => {
|
|
345
|
+
if (!t.current)
|
|
346
|
+
return;
|
|
347
|
+
const f = b.clientX, I = b.clientY, p = a.phase;
|
|
348
|
+
if (p.kind === "idle")
|
|
349
|
+
return;
|
|
350
|
+
const G = Math.abs(f - p.startX), E = Math.abs(I - p.startY);
|
|
351
|
+
if (G < e && E < e) {
|
|
352
|
+
a.phase.kind === "content" && i(D.setSuggest(null)), i(D.setPointer(null)), i(D.setTabbarHover(null));
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (i(D.setPointer({ x: f, y: I })), p.kind === "content") {
|
|
356
|
+
const S = p.cache.groups.find(({ rect: x }) => f >= x.left && f <= x.right && I >= x.top && I <= x.bottom);
|
|
357
|
+
if (!S) {
|
|
358
|
+
i(D.setSuggest(null));
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const P = V(S.rect, f, I);
|
|
362
|
+
if (o && !o({ targetGroupId: S.gid, zone: P })) {
|
|
363
|
+
i(D.setSuggest(null));
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
i(D.setSuggest({ rect: S.rect, zone: P }));
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (p.kind === "tab") {
|
|
370
|
+
const S = p.cache.tabbars.find(({ rect: R }) => f >= R.left && f <= R.right && I >= R.top && I <= R.bottom);
|
|
371
|
+
if (S) {
|
|
372
|
+
const k = Array.from(S.el.querySelectorAll("[role='tab']")).map((N) => N.getBoundingClientRect()), C = k.map((N) => N.left + N.width / 2), O = C.findIndex((N) => f < N), B = O === -1 ? C.length : O, Et = 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;
|
|
373
|
+
i(D.setTabbarHover({ groupId: S.gid, index: B, rect: S.rect, insertX: Et }));
|
|
374
|
+
} else
|
|
375
|
+
i(D.setTabbarHover(null));
|
|
376
|
+
const P = p.cache.contents.find(({ rect: R }) => f >= R.left && f <= R.right && I >= R.top && I <= R.bottom);
|
|
377
|
+
if (!P) {
|
|
378
|
+
i(D.setSuggest(null));
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
const x = V(P.rect, f, I);
|
|
382
|
+
if (o && !o({ targetGroupId: P.gid, zone: x })) {
|
|
383
|
+
i(D.setSuggest(null));
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
i(D.setSuggest({ rect: P.rect, zone: x }));
|
|
387
|
+
}
|
|
388
|
+
}), g = J((b) => {
|
|
389
|
+
const y = t.current, f = a;
|
|
390
|
+
if (i(D.reset()), !y)
|
|
391
|
+
return;
|
|
392
|
+
const I = b.clientX, p = b.clientY;
|
|
393
|
+
if (f.phase.kind === "idle")
|
|
394
|
+
return;
|
|
395
|
+
const G = Math.abs(I - f.phase.startX), E = Math.abs(p - f.phase.startY);
|
|
396
|
+
if (!(G < e && E < e)) {
|
|
397
|
+
if (f.phase.kind === "content") {
|
|
398
|
+
const S = f.phase.cache.groups.find(({ rect: R }) => I >= R.left && I <= R.right && p >= R.top && p <= R.bottom);
|
|
399
|
+
if (!S)
|
|
400
|
+
return;
|
|
401
|
+
const P = S.gid ?? null;
|
|
402
|
+
if (!P)
|
|
403
|
+
return;
|
|
404
|
+
const x = V(S.rect, I, p);
|
|
405
|
+
if (o && !o({ targetGroupId: P, zone: x }))
|
|
406
|
+
return;
|
|
407
|
+
r({ fromGroupId: f.phase.fromGroupId, tabId: f.phase.tabId, targetGroupId: P, zone: x });
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
if (f.phase.kind === "tab") {
|
|
411
|
+
const S = f.phase.cache.tabbars.find(({ rect: x }) => I >= x.left && I <= x.right && p >= x.top && p <= x.bottom);
|
|
412
|
+
if (S) {
|
|
413
|
+
const x = S.gid;
|
|
414
|
+
if (!x)
|
|
415
|
+
return;
|
|
416
|
+
const k = Array.from(S.el.querySelectorAll("[role='tab']")).map((B) => {
|
|
417
|
+
const Z = B.getBoundingClientRect();
|
|
418
|
+
return Z.left + Z.width / 2;
|
|
419
|
+
}), C = k.findIndex((B) => I < B), O = C === -1 ? k.length : C;
|
|
420
|
+
n({ fromGroupId: f.phase.fromGroupId, tabId: f.phase.tabId, targetGroupId: x, targetIndex: O });
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
const P = f.phase.cache.contents.find(({ rect: x }) => I >= x.left && I <= x.right && p >= x.top && p <= x.bottom);
|
|
424
|
+
if (P) {
|
|
425
|
+
const x = P.gid ?? null;
|
|
426
|
+
if (!x)
|
|
427
|
+
return;
|
|
428
|
+
const R = V(P.rect, I, p);
|
|
429
|
+
if (o && !o({ targetGroupId: x, zone: R }))
|
|
430
|
+
return;
|
|
431
|
+
r({ fromGroupId: f.phase.fromGroupId, tabId: f.phase.tabId, targetGroupId: x, zone: R });
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}), v = J(() => {
|
|
436
|
+
i(D.reset());
|
|
437
|
+
});
|
|
438
|
+
l.useEffect(() => {
|
|
439
|
+
if (a.phase.kind !== "idle")
|
|
440
|
+
return window.addEventListener("pointermove", d), window.addEventListener("pointerup", g, { once: !0 }), window.addEventListener("pointercancel", v, { once: !0 }), () => {
|
|
441
|
+
window.removeEventListener("pointermove", d), window.removeEventListener("pointerup", g), window.removeEventListener("pointercancel", v);
|
|
442
|
+
};
|
|
443
|
+
}, [a.phase.kind]);
|
|
444
|
+
const T = l.useCallback((b, y, f) => {
|
|
445
|
+
if (f.button !== 0)
|
|
446
|
+
return;
|
|
447
|
+
f.currentTarget.setPointerCapture(f.pointerId);
|
|
448
|
+
const I = u();
|
|
449
|
+
i(D.startContent({ x: f.clientX, y: f.clientY, groupId: b, tabId: y, cache: I }));
|
|
450
|
+
}, [u]), h = l.useCallback((b, y, f) => {
|
|
451
|
+
if (f.button !== 0)
|
|
452
|
+
return;
|
|
453
|
+
const I = f.currentTarget;
|
|
454
|
+
I && I.setPointerCapture(f.pointerId);
|
|
455
|
+
const p = u();
|
|
456
|
+
i(D.startTab({ x: f.clientX, y: f.clientY, groupId: y, tabId: b, cache: p, element: I }));
|
|
457
|
+
}, [u]), w = l.useMemo(() => ({
|
|
458
|
+
suggest: a.suggest,
|
|
459
|
+
isTabDragging: a.phase.kind === "tab",
|
|
460
|
+
draggingTabId: a.phase.kind === "tab" ? a.phase.tabId : null,
|
|
461
|
+
dragPointer: a.pointer,
|
|
462
|
+
tabbarHover: a.tabbarHover,
|
|
463
|
+
draggingTabElement: a.draggingTabElement,
|
|
464
|
+
onStartContentDrag: T,
|
|
465
|
+
onStartTabDrag: h
|
|
466
|
+
}), [a.suggest, a.pointer, a.tabbarHover, a.phase, a.draggingTabElement, T, h]);
|
|
467
|
+
return /* @__PURE__ */ m(vt.Provider, { value: w, children: s });
|
|
468
|
+
}, st = {
|
|
469
|
+
display: "inline-flex",
|
|
470
|
+
alignItems: "center",
|
|
471
|
+
userSelect: "none"
|
|
472
|
+
}, me = ({
|
|
473
|
+
groupId: t,
|
|
474
|
+
tab: e,
|
|
475
|
+
active: r,
|
|
476
|
+
dragging: n,
|
|
477
|
+
onClickTab: o,
|
|
478
|
+
onStartDrag: s,
|
|
479
|
+
onCloseTab: a,
|
|
480
|
+
tabComponent: i,
|
|
481
|
+
tabElement: c,
|
|
482
|
+
onDoubleClick: u
|
|
483
|
+
}) => {
|
|
484
|
+
const d = l.useEffectEvent(() => {
|
|
485
|
+
o(e.id);
|
|
486
|
+
}), g = l.useEffectEvent((w) => {
|
|
487
|
+
s && w.button === 0 && s(e.id, t, w);
|
|
488
|
+
}), v = () => {
|
|
489
|
+
const w = !!a;
|
|
490
|
+
return /* @__PURE__ */ m(l.Activity, { mode: w ? "visible" : "hidden", children: /* @__PURE__ */ m(
|
|
491
|
+
"button",
|
|
492
|
+
{
|
|
493
|
+
type: "button",
|
|
494
|
+
"aria-label": `Close tab ${e.title}`,
|
|
495
|
+
onClick: (b) => {
|
|
496
|
+
a && (b.stopPropagation(), a(t, e.id));
|
|
497
|
+
},
|
|
498
|
+
style: { marginLeft: 6 },
|
|
499
|
+
tabIndex: w ? void 0 : -1,
|
|
500
|
+
disabled: !w,
|
|
501
|
+
"aria-hidden": w ? void 0 : !0,
|
|
502
|
+
children: "×"
|
|
503
|
+
}
|
|
504
|
+
) });
|
|
505
|
+
}, T = {
|
|
506
|
+
role: "tab",
|
|
507
|
+
"aria-selected": r,
|
|
508
|
+
tabIndex: r ? 0 : -1,
|
|
509
|
+
style: st,
|
|
510
|
+
onClick: d,
|
|
511
|
+
onPointerDown: g,
|
|
512
|
+
onDoubleClick: u,
|
|
513
|
+
"data-tab-id": e.id,
|
|
514
|
+
"data-active": r ? "true" : "false",
|
|
515
|
+
"data-dragging": n ? "true" : "false",
|
|
516
|
+
children: /* @__PURE__ */ H(et, { children: [
|
|
517
|
+
/* @__PURE__ */ m("span", { children: e.title }),
|
|
518
|
+
v()
|
|
519
|
+
] })
|
|
520
|
+
}, h = {
|
|
521
|
+
type: "button",
|
|
522
|
+
role: "tab",
|
|
523
|
+
"aria-selected": r,
|
|
524
|
+
tabIndex: r ? 0 : -1,
|
|
525
|
+
style: st,
|
|
526
|
+
onClick: () => {
|
|
527
|
+
o(e.id);
|
|
528
|
+
},
|
|
529
|
+
onPointerDown: (w) => {
|
|
530
|
+
s && w.button === 0 && s(e.id, t, w);
|
|
531
|
+
},
|
|
532
|
+
onDoubleClick: u,
|
|
533
|
+
children: /* @__PURE__ */ m("span", { children: e.title })
|
|
534
|
+
};
|
|
535
|
+
return c ? c(h) : i ? /* @__PURE__ */ m(i, { ...h }) : /* @__PURE__ */ m("div", { ...T });
|
|
536
|
+
}, ve = {
|
|
537
|
+
display: "flex",
|
|
538
|
+
alignItems: "center"
|
|
539
|
+
}, Ie = {
|
|
540
|
+
flex: "1 1 auto",
|
|
541
|
+
alignSelf: "stretch"
|
|
542
|
+
}, we = ({
|
|
543
|
+
group: t,
|
|
544
|
+
onClickTab: e,
|
|
545
|
+
onStartDrag: r,
|
|
546
|
+
rootRef: n,
|
|
547
|
+
component: o,
|
|
548
|
+
element: s,
|
|
549
|
+
tabComponent: a,
|
|
550
|
+
tabElement: i,
|
|
551
|
+
onAddTab: c,
|
|
552
|
+
onCloseTab: u,
|
|
553
|
+
doubleClickToAdd: d
|
|
554
|
+
}) => {
|
|
555
|
+
const { isTabDragging: g, draggingTabId: v } = q(), T = l.useRef(null), h = l.useCallback(
|
|
556
|
+
(p) => {
|
|
557
|
+
if (T.current = p, !!n) {
|
|
558
|
+
if (typeof n == "function") {
|
|
559
|
+
n(p);
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
try {
|
|
563
|
+
n.current = p;
|
|
564
|
+
} catch {
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
[n]
|
|
569
|
+
), w = l.useEffectEvent((p) => {
|
|
570
|
+
const G = T.current ?? p.currentTarget;
|
|
571
|
+
if (!G)
|
|
572
|
+
return;
|
|
573
|
+
const E = Array.from(G.querySelectorAll('[role="tab"]'));
|
|
574
|
+
if (E.length === 0)
|
|
575
|
+
return;
|
|
576
|
+
const S = (C) => {
|
|
577
|
+
const O = Math.max(0, Math.min(C, E.length - 1)), B = E[O];
|
|
578
|
+
B && B.focus();
|
|
579
|
+
}, P = document.activeElement, x = P ? E.indexOf(P) : E.findIndex((C) => C.getAttribute("data-tab-id") === t.activeTabId);
|
|
580
|
+
if (p.key === "ArrowRight") {
|
|
581
|
+
p.preventDefault();
|
|
582
|
+
const C = x >= 0 ? x + 1 : 0;
|
|
583
|
+
S(C >= E.length ? 0 : C);
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
if (p.key === "ArrowLeft") {
|
|
587
|
+
p.preventDefault();
|
|
588
|
+
const C = x >= 0 ? x - 1 : E.length - 1;
|
|
589
|
+
S(C < 0 ? E.length - 1 : C);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (p.key === "Home") {
|
|
593
|
+
p.preventDefault(), S(0);
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
if (p.key === "End") {
|
|
597
|
+
p.preventDefault(), S(E.length - 1);
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
if (p.key === "Enter" || p.key === " ") {
|
|
601
|
+
p.preventDefault();
|
|
602
|
+
const O = (x >= 0 ? E[x] : null)?.getAttribute("data-tab-id") ?? null;
|
|
603
|
+
O && e(O);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (p.key === "Delete" || p.key === "Backspace") {
|
|
607
|
+
if (u) {
|
|
608
|
+
p.preventDefault();
|
|
609
|
+
const O = (x >= 0 ? E[x] : null)?.getAttribute("data-tab-id") ?? null;
|
|
610
|
+
O && u(t.id, O);
|
|
611
|
+
}
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
const R = (p.ctrlKey ? 1 : 0) + (p.metaKey ? 1 : 0) > 0, k = typeof p.key == "string" ? p.key.toLowerCase() : "";
|
|
615
|
+
if (R && k === "t") {
|
|
616
|
+
c && (p.preventDefault(), c(t.id));
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
l.useEffect(() => {
|
|
621
|
+
const p = T.current;
|
|
622
|
+
if (!p)
|
|
623
|
+
return;
|
|
624
|
+
const G = p.querySelector(`[role="tab"][data-tab-id="${t.activeTabId}"]`);
|
|
625
|
+
if (G === document.activeElement)
|
|
626
|
+
return;
|
|
627
|
+
!p.contains(document.activeElement) && G && G.focus();
|
|
628
|
+
}, [t.activeTabId]);
|
|
629
|
+
const b = {
|
|
630
|
+
style: ve,
|
|
631
|
+
role: "tablist",
|
|
632
|
+
"data-tabbar": "true",
|
|
633
|
+
"data-group-id": t.id,
|
|
634
|
+
"data-dragging": g ? "true" : "false",
|
|
635
|
+
onKeyDown: w
|
|
636
|
+
}, y = Dt({
|
|
637
|
+
element: s,
|
|
638
|
+
component: o
|
|
639
|
+
}), f = () => c ? /* @__PURE__ */ m(
|
|
640
|
+
"button",
|
|
641
|
+
{
|
|
642
|
+
type: "button",
|
|
643
|
+
"aria-label": "Add tab",
|
|
644
|
+
onClick: () => {
|
|
645
|
+
c(t.id);
|
|
646
|
+
},
|
|
647
|
+
children: "+"
|
|
648
|
+
}
|
|
649
|
+
) : null, I = l.useCallback(() => {
|
|
650
|
+
d && c && c(t.id);
|
|
651
|
+
}, [d, c, t.id]);
|
|
652
|
+
return /* @__PURE__ */ H(y, { ...b, ref: h, onDoubleClick: I, children: [
|
|
653
|
+
t.tabs.map((p, G) => /* @__PURE__ */ m(
|
|
654
|
+
me,
|
|
655
|
+
{
|
|
656
|
+
groupId: t.id,
|
|
657
|
+
tab: p,
|
|
658
|
+
active: t.activeTabId === p.id,
|
|
659
|
+
dragging: v === p.id,
|
|
660
|
+
onClickTab: e,
|
|
661
|
+
onStartDrag: r,
|
|
662
|
+
onCloseTab: u,
|
|
663
|
+
tabComponent: a,
|
|
664
|
+
tabElement: i,
|
|
665
|
+
onDoubleClick: (E) => E.stopPropagation()
|
|
666
|
+
},
|
|
667
|
+
`${t.id}:${p.id}:${G}`
|
|
668
|
+
)),
|
|
669
|
+
/* @__PURE__ */ m("span", { style: Ie }),
|
|
670
|
+
f()
|
|
671
|
+
] });
|
|
672
|
+
}, ye = ({ id: t, TabBarComponent: e, PanelGroupComponent: r }) => {
|
|
673
|
+
const { getGroup: n, getGroupContent: o, onClickTab: s, onAddTab: a, onCloseTab: i, onStartContentDrag: c, onStartTabDrag: u, doubleClickToAdd: d } = se(), { setGroupEl: g, setTabbarEl: v, setContentEl: T } = bt(), h = l.useCallback(
|
|
674
|
+
(G) => {
|
|
675
|
+
g(t, G);
|
|
676
|
+
},
|
|
677
|
+
[t, g]
|
|
678
|
+
), w = l.useCallback(
|
|
679
|
+
(G) => {
|
|
680
|
+
T(t, G);
|
|
681
|
+
},
|
|
682
|
+
[t, T]
|
|
683
|
+
), b = l.useCallback(
|
|
684
|
+
(G) => {
|
|
685
|
+
v(t, G);
|
|
686
|
+
},
|
|
687
|
+
[t, v]
|
|
688
|
+
), y = n(t);
|
|
689
|
+
if (!y)
|
|
690
|
+
return null;
|
|
691
|
+
const f = o(t);
|
|
692
|
+
return /* @__PURE__ */ m(
|
|
693
|
+
r ?? ((G) => /* @__PURE__ */ m(gt, { ...G })),
|
|
694
|
+
{
|
|
695
|
+
group: y,
|
|
696
|
+
tabbar: /* @__PURE__ */ m(
|
|
697
|
+
e ?? we,
|
|
698
|
+
{
|
|
699
|
+
rootRef: b,
|
|
700
|
+
group: y,
|
|
701
|
+
onClickTab: (G) => s(t, G),
|
|
702
|
+
onAddTab: a,
|
|
703
|
+
onCloseTab: i,
|
|
704
|
+
onStartDrag: (G, E, S) => u(G, E, S),
|
|
705
|
+
doubleClickToAdd: d
|
|
706
|
+
}
|
|
707
|
+
),
|
|
708
|
+
content: f,
|
|
709
|
+
groupRef: h,
|
|
710
|
+
contentRef: w,
|
|
711
|
+
onContentPointerDown: (G) => c(t, G)
|
|
712
|
+
}
|
|
713
|
+
);
|
|
714
|
+
}, Te = (t, e) => {
|
|
715
|
+
const r = new Array(16);
|
|
716
|
+
for (let n = 0; n < 4; n++)
|
|
717
|
+
for (let o = 0; o < 4; o++)
|
|
718
|
+
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
|
+
return r;
|
|
720
|
+
}, K = (t) => {
|
|
721
|
+
if (t.length !== 16)
|
|
722
|
+
throw new Error("Matrix must have exactly 16 values");
|
|
723
|
+
const e = Object.freeze([...t]), r = (n) => {
|
|
724
|
+
const o = Te(e, n);
|
|
725
|
+
return K(o);
|
|
726
|
+
};
|
|
727
|
+
return Object.freeze({
|
|
728
|
+
translate: (n = 0, o = 0, s = 0) => r([
|
|
729
|
+
1,
|
|
730
|
+
0,
|
|
731
|
+
0,
|
|
732
|
+
0,
|
|
733
|
+
0,
|
|
734
|
+
1,
|
|
735
|
+
0,
|
|
736
|
+
0,
|
|
737
|
+
0,
|
|
738
|
+
0,
|
|
739
|
+
1,
|
|
740
|
+
0,
|
|
741
|
+
n,
|
|
742
|
+
o,
|
|
743
|
+
s,
|
|
744
|
+
1
|
|
745
|
+
]),
|
|
746
|
+
translate3d: (n, o, s) => r([
|
|
747
|
+
1,
|
|
748
|
+
0,
|
|
749
|
+
0,
|
|
750
|
+
0,
|
|
751
|
+
0,
|
|
752
|
+
1,
|
|
753
|
+
0,
|
|
754
|
+
0,
|
|
755
|
+
0,
|
|
756
|
+
0,
|
|
757
|
+
1,
|
|
758
|
+
0,
|
|
759
|
+
n,
|
|
760
|
+
o,
|
|
761
|
+
s,
|
|
762
|
+
1
|
|
763
|
+
]),
|
|
764
|
+
translateX: (n) => r([
|
|
765
|
+
1,
|
|
766
|
+
0,
|
|
767
|
+
0,
|
|
768
|
+
0,
|
|
769
|
+
0,
|
|
770
|
+
1,
|
|
771
|
+
0,
|
|
772
|
+
0,
|
|
773
|
+
0,
|
|
774
|
+
0,
|
|
775
|
+
1,
|
|
776
|
+
0,
|
|
777
|
+
n,
|
|
778
|
+
0,
|
|
779
|
+
0,
|
|
780
|
+
1
|
|
781
|
+
]),
|
|
782
|
+
translateY: (n) => r([
|
|
783
|
+
1,
|
|
784
|
+
0,
|
|
785
|
+
0,
|
|
786
|
+
0,
|
|
787
|
+
0,
|
|
788
|
+
1,
|
|
789
|
+
0,
|
|
790
|
+
0,
|
|
791
|
+
0,
|
|
792
|
+
0,
|
|
793
|
+
1,
|
|
794
|
+
0,
|
|
795
|
+
0,
|
|
796
|
+
n,
|
|
797
|
+
0,
|
|
798
|
+
1
|
|
799
|
+
]),
|
|
800
|
+
translateZ: (n) => r([
|
|
801
|
+
1,
|
|
802
|
+
0,
|
|
803
|
+
0,
|
|
804
|
+
0,
|
|
805
|
+
0,
|
|
806
|
+
1,
|
|
807
|
+
0,
|
|
808
|
+
0,
|
|
809
|
+
0,
|
|
810
|
+
0,
|
|
811
|
+
1,
|
|
812
|
+
0,
|
|
813
|
+
0,
|
|
814
|
+
0,
|
|
815
|
+
n,
|
|
816
|
+
1
|
|
817
|
+
]),
|
|
818
|
+
scale: (n = 1, o = 1, s = 1) => r([
|
|
819
|
+
n,
|
|
820
|
+
0,
|
|
821
|
+
0,
|
|
822
|
+
0,
|
|
823
|
+
0,
|
|
824
|
+
o,
|
|
825
|
+
0,
|
|
826
|
+
0,
|
|
827
|
+
0,
|
|
828
|
+
0,
|
|
829
|
+
s,
|
|
830
|
+
0,
|
|
831
|
+
0,
|
|
832
|
+
0,
|
|
833
|
+
0,
|
|
834
|
+
1
|
|
835
|
+
]),
|
|
836
|
+
scale3d: (n, o, s) => r([
|
|
837
|
+
n,
|
|
838
|
+
0,
|
|
839
|
+
0,
|
|
840
|
+
0,
|
|
841
|
+
0,
|
|
842
|
+
o,
|
|
843
|
+
0,
|
|
844
|
+
0,
|
|
845
|
+
0,
|
|
846
|
+
0,
|
|
847
|
+
s,
|
|
848
|
+
0,
|
|
849
|
+
0,
|
|
850
|
+
0,
|
|
851
|
+
0,
|
|
852
|
+
1
|
|
853
|
+
]),
|
|
854
|
+
scaleX: (n) => r([
|
|
855
|
+
n,
|
|
856
|
+
0,
|
|
857
|
+
0,
|
|
858
|
+
0,
|
|
859
|
+
0,
|
|
860
|
+
1,
|
|
861
|
+
0,
|
|
862
|
+
0,
|
|
863
|
+
0,
|
|
864
|
+
0,
|
|
865
|
+
1,
|
|
866
|
+
0,
|
|
867
|
+
0,
|
|
868
|
+
0,
|
|
869
|
+
0,
|
|
870
|
+
1
|
|
871
|
+
]),
|
|
872
|
+
scaleY: (n) => r([
|
|
873
|
+
1,
|
|
874
|
+
0,
|
|
875
|
+
0,
|
|
876
|
+
0,
|
|
877
|
+
0,
|
|
878
|
+
n,
|
|
879
|
+
0,
|
|
880
|
+
0,
|
|
881
|
+
0,
|
|
882
|
+
0,
|
|
883
|
+
1,
|
|
884
|
+
0,
|
|
885
|
+
0,
|
|
886
|
+
0,
|
|
887
|
+
0,
|
|
888
|
+
1
|
|
889
|
+
]),
|
|
890
|
+
scaleZ: (n) => r([
|
|
891
|
+
1,
|
|
892
|
+
0,
|
|
893
|
+
0,
|
|
894
|
+
0,
|
|
895
|
+
0,
|
|
896
|
+
1,
|
|
897
|
+
0,
|
|
898
|
+
0,
|
|
899
|
+
0,
|
|
900
|
+
0,
|
|
901
|
+
n,
|
|
902
|
+
0,
|
|
903
|
+
0,
|
|
904
|
+
0,
|
|
905
|
+
0,
|
|
906
|
+
1
|
|
907
|
+
]),
|
|
908
|
+
rotateX: (n) => {
|
|
909
|
+
const o = Math.cos(n), s = Math.sin(n);
|
|
910
|
+
return r([
|
|
911
|
+
1,
|
|
912
|
+
0,
|
|
913
|
+
0,
|
|
914
|
+
0,
|
|
915
|
+
0,
|
|
916
|
+
o,
|
|
917
|
+
s,
|
|
918
|
+
0,
|
|
919
|
+
0,
|
|
920
|
+
-s,
|
|
921
|
+
o,
|
|
922
|
+
0,
|
|
923
|
+
0,
|
|
924
|
+
0,
|
|
925
|
+
0,
|
|
926
|
+
1
|
|
927
|
+
]);
|
|
928
|
+
},
|
|
929
|
+
rotateY: (n) => {
|
|
930
|
+
const o = Math.cos(n), s = Math.sin(n);
|
|
931
|
+
return r([
|
|
932
|
+
o,
|
|
933
|
+
0,
|
|
934
|
+
-s,
|
|
935
|
+
0,
|
|
936
|
+
0,
|
|
937
|
+
1,
|
|
938
|
+
0,
|
|
939
|
+
0,
|
|
940
|
+
s,
|
|
941
|
+
0,
|
|
942
|
+
o,
|
|
943
|
+
0,
|
|
944
|
+
0,
|
|
945
|
+
0,
|
|
946
|
+
0,
|
|
947
|
+
1
|
|
948
|
+
]);
|
|
949
|
+
},
|
|
950
|
+
rotateZ: (n) => {
|
|
951
|
+
const o = Math.cos(n), s = Math.sin(n);
|
|
952
|
+
return r([
|
|
953
|
+
o,
|
|
954
|
+
s,
|
|
955
|
+
0,
|
|
956
|
+
0,
|
|
957
|
+
-s,
|
|
958
|
+
o,
|
|
959
|
+
0,
|
|
960
|
+
0,
|
|
961
|
+
0,
|
|
962
|
+
0,
|
|
963
|
+
1,
|
|
964
|
+
0,
|
|
965
|
+
0,
|
|
966
|
+
0,
|
|
967
|
+
0,
|
|
968
|
+
1
|
|
969
|
+
]);
|
|
970
|
+
},
|
|
971
|
+
rotate: (n, o, s, a) => {
|
|
972
|
+
const i = Math.sqrt(o * o + s * s + a * a);
|
|
973
|
+
if (i === 0)
|
|
974
|
+
return K(e);
|
|
975
|
+
o /= i, s /= i, a /= i;
|
|
976
|
+
const c = Math.cos(n), u = Math.sin(n), d = 1 - c;
|
|
977
|
+
return r([
|
|
978
|
+
d * o * o + c,
|
|
979
|
+
d * o * s + u * a,
|
|
980
|
+
d * o * a - u * s,
|
|
981
|
+
0,
|
|
982
|
+
d * o * s - u * a,
|
|
983
|
+
d * s * s + c,
|
|
984
|
+
d * s * a + u * o,
|
|
985
|
+
0,
|
|
986
|
+
d * o * a + u * s,
|
|
987
|
+
d * s * a - u * o,
|
|
988
|
+
d * a * a + c,
|
|
989
|
+
0,
|
|
990
|
+
0,
|
|
991
|
+
0,
|
|
992
|
+
0,
|
|
993
|
+
1
|
|
994
|
+
]);
|
|
995
|
+
},
|
|
996
|
+
rotate3d: (n, o, s, a) => {
|
|
997
|
+
const i = Math.sqrt(n * n + o * o + s * s);
|
|
998
|
+
if (i === 0)
|
|
999
|
+
return K(e);
|
|
1000
|
+
n /= i, o /= i, s /= i;
|
|
1001
|
+
const c = Math.cos(a), u = Math.sin(a), d = 1 - c;
|
|
1002
|
+
return r([
|
|
1003
|
+
d * n * n + c,
|
|
1004
|
+
d * n * o + u * s,
|
|
1005
|
+
d * n * s - u * o,
|
|
1006
|
+
0,
|
|
1007
|
+
d * n * o - u * s,
|
|
1008
|
+
d * o * o + c,
|
|
1009
|
+
d * o * s + u * n,
|
|
1010
|
+
0,
|
|
1011
|
+
d * n * s + u * o,
|
|
1012
|
+
d * o * s - u * n,
|
|
1013
|
+
d * s * s + c,
|
|
1014
|
+
0,
|
|
1015
|
+
0,
|
|
1016
|
+
0,
|
|
1017
|
+
0,
|
|
1018
|
+
1
|
|
1019
|
+
]);
|
|
1020
|
+
},
|
|
1021
|
+
skew: (n = 0, o = 0) => {
|
|
1022
|
+
const s = Math.tan(n), a = Math.tan(o);
|
|
1023
|
+
return r([
|
|
1024
|
+
1,
|
|
1025
|
+
a,
|
|
1026
|
+
0,
|
|
1027
|
+
0,
|
|
1028
|
+
s,
|
|
1029
|
+
1,
|
|
1030
|
+
0,
|
|
1031
|
+
0,
|
|
1032
|
+
0,
|
|
1033
|
+
0,
|
|
1034
|
+
1,
|
|
1035
|
+
0,
|
|
1036
|
+
0,
|
|
1037
|
+
0,
|
|
1038
|
+
0,
|
|
1039
|
+
1
|
|
1040
|
+
]);
|
|
1041
|
+
},
|
|
1042
|
+
skewX: (n) => {
|
|
1043
|
+
const o = Math.tan(n);
|
|
1044
|
+
return r([
|
|
1045
|
+
1,
|
|
1046
|
+
0,
|
|
1047
|
+
0,
|
|
1048
|
+
0,
|
|
1049
|
+
o,
|
|
1050
|
+
1,
|
|
1051
|
+
0,
|
|
1052
|
+
0,
|
|
1053
|
+
0,
|
|
1054
|
+
0,
|
|
1055
|
+
1,
|
|
1056
|
+
0,
|
|
1057
|
+
0,
|
|
1058
|
+
0,
|
|
1059
|
+
0,
|
|
1060
|
+
1
|
|
1061
|
+
]);
|
|
1062
|
+
},
|
|
1063
|
+
skewY: (n) => {
|
|
1064
|
+
const o = Math.tan(n);
|
|
1065
|
+
return r([
|
|
1066
|
+
1,
|
|
1067
|
+
o,
|
|
1068
|
+
0,
|
|
1069
|
+
0,
|
|
1070
|
+
0,
|
|
1071
|
+
1,
|
|
1072
|
+
0,
|
|
1073
|
+
0,
|
|
1074
|
+
0,
|
|
1075
|
+
0,
|
|
1076
|
+
1,
|
|
1077
|
+
0,
|
|
1078
|
+
0,
|
|
1079
|
+
0,
|
|
1080
|
+
0,
|
|
1081
|
+
1
|
|
1082
|
+
]);
|
|
1083
|
+
},
|
|
1084
|
+
perspective: (n) => {
|
|
1085
|
+
if (n === 0)
|
|
1086
|
+
throw new Error("Perspective distance cannot be zero");
|
|
1087
|
+
return r([
|
|
1088
|
+
1,
|
|
1089
|
+
0,
|
|
1090
|
+
0,
|
|
1091
|
+
0,
|
|
1092
|
+
0,
|
|
1093
|
+
1,
|
|
1094
|
+
0,
|
|
1095
|
+
0,
|
|
1096
|
+
0,
|
|
1097
|
+
0,
|
|
1098
|
+
1,
|
|
1099
|
+
-1 / n,
|
|
1100
|
+
0,
|
|
1101
|
+
0,
|
|
1102
|
+
0,
|
|
1103
|
+
1
|
|
1104
|
+
]);
|
|
1105
|
+
},
|
|
1106
|
+
toCSS: () => `matrix3d(${e.join(", ")})`,
|
|
1107
|
+
toArray: () => e,
|
|
1108
|
+
toString: () => [
|
|
1109
|
+
`[${e[0]}, ${e[4]}, ${e[8]}, ${e[12]}]`,
|
|
1110
|
+
`[${e[1]}, ${e[5]}, ${e[9]}, ${e[13]}]`,
|
|
1111
|
+
`[${e[2]}, ${e[6]}, ${e[10]}, ${e[14]}]`,
|
|
1112
|
+
`[${e[3]}, ${e[7]}, ${e[11]}, ${e[15]}]`
|
|
1113
|
+
].join(`
|
|
1114
|
+
`)
|
|
1115
|
+
});
|
|
1116
|
+
}, Ge = () => K([
|
|
1117
|
+
1,
|
|
1118
|
+
0,
|
|
1119
|
+
0,
|
|
1120
|
+
0,
|
|
1121
|
+
0,
|
|
1122
|
+
1,
|
|
1123
|
+
0,
|
|
1124
|
+
0,
|
|
1125
|
+
0,
|
|
1126
|
+
0,
|
|
1127
|
+
1,
|
|
1128
|
+
0,
|
|
1129
|
+
0,
|
|
1130
|
+
0,
|
|
1131
|
+
0,
|
|
1132
|
+
1
|
|
1133
|
+
]), xe = {
|
|
1134
|
+
position: "fixed",
|
|
1135
|
+
inset: 0,
|
|
1136
|
+
pointerEvents: "none",
|
|
1137
|
+
zIndex: Lt
|
|
1138
|
+
}, Se = {
|
|
1139
|
+
position: "absolute",
|
|
1140
|
+
border: `${Nt} dashed ${zt}`,
|
|
1141
|
+
background: Ht,
|
|
1142
|
+
borderRadius: $t,
|
|
1143
|
+
transformOrigin: "top left"
|
|
1144
|
+
}, L = (t, e) => e <= 0 ? 0 : _(t / e, 0), Ee = (t, e, r) => {
|
|
1145
|
+
const { width: n, height: o } = t, s = r / 2, a = n > 0 ? n : 1, i = o > 0 ? o : 1, c = {
|
|
1146
|
+
translateX: r,
|
|
1147
|
+
translateY: r,
|
|
1148
|
+
scaleX: L(_(n - r * 2, 0), a),
|
|
1149
|
+
scaleY: L(_(o - r * 2, 0), i)
|
|
1150
|
+
}, u = {
|
|
1151
|
+
translateX: r,
|
|
1152
|
+
translateY: r,
|
|
1153
|
+
scaleX: L(_(n / 2 - r * 1.5, 0), a),
|
|
1154
|
+
scaleY: L(_(o - r * 2, 0), i)
|
|
1155
|
+
}, d = {
|
|
1156
|
+
translateX: n / 2 + s,
|
|
1157
|
+
translateY: r,
|
|
1158
|
+
scaleX: L(_(n / 2 - r * 1.5, 0), a),
|
|
1159
|
+
scaleY: L(_(o - r * 2, 0), i)
|
|
1160
|
+
}, g = {
|
|
1161
|
+
translateX: r,
|
|
1162
|
+
translateY: r,
|
|
1163
|
+
scaleX: L(_(n - r * 2, 0), a),
|
|
1164
|
+
scaleY: L(_(o / 2 - r * 1.5, 0), i)
|
|
1165
|
+
}, v = {
|
|
1166
|
+
translateX: r,
|
|
1167
|
+
translateY: o / 2 + s,
|
|
1168
|
+
scaleX: L(_(n - r * 2, 0), a),
|
|
1169
|
+
scaleY: L(_(o / 2 - r * 1.5, 0), i)
|
|
1170
|
+
}, T = {
|
|
1171
|
+
center: c,
|
|
1172
|
+
left: u,
|
|
1173
|
+
right: d,
|
|
1174
|
+
top: g,
|
|
1175
|
+
bottom: v
|
|
1176
|
+
}, { translateX: h, translateY: w, scaleX: b, scaleY: y } = T[e];
|
|
1177
|
+
return Ge().translate(h, w, 0).scale(b, y, 1).toCSS();
|
|
1178
|
+
}, Re = (t, e) => {
|
|
1179
|
+
const r = Xt;
|
|
1180
|
+
return {
|
|
1181
|
+
...Se,
|
|
1182
|
+
left: t.left,
|
|
1183
|
+
top: t.top,
|
|
1184
|
+
width: t.width,
|
|
1185
|
+
height: t.height,
|
|
1186
|
+
transform: Ee(t, e, r)
|
|
1187
|
+
};
|
|
1188
|
+
}, Pe = ({ suggest: t }) => {
|
|
1189
|
+
if (!t)
|
|
1190
|
+
return null;
|
|
1191
|
+
const { rect: e, zone: r } = t, n = Re(e, r);
|
|
1192
|
+
return /* @__PURE__ */ m("div", { style: xe, children: /* @__PURE__ */ m("div", { style: n }) });
|
|
1193
|
+
}, Ce = typeof window < "u" && typeof document < "u", De = (t) => {
|
|
1194
|
+
const [e, r] = l.useState(null), [n, o] = l.useState(null);
|
|
1195
|
+
return At(() => {
|
|
1196
|
+
if (!Ce || !t) {
|
|
1197
|
+
r(null), o(null);
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
const s = t.getBoundingClientRect();
|
|
1201
|
+
r({ width: s.width, height: s.height }), o(t.outerHTML);
|
|
1202
|
+
}, [t]), { html: n, size: e };
|
|
1203
|
+
}, Ae = {
|
|
1204
|
+
position: "fixed",
|
|
1205
|
+
inset: 0,
|
|
1206
|
+
pointerEvents: "none",
|
|
1207
|
+
zIndex: qt
|
|
1208
|
+
}, ke = {
|
|
1209
|
+
position: "absolute",
|
|
1210
|
+
width: Ut,
|
|
1211
|
+
borderRadius: Kt,
|
|
1212
|
+
background: Vt,
|
|
1213
|
+
boxShadow: jt
|
|
1214
|
+
}, _e = () => {
|
|
1215
|
+
const { isTabDragging: t, draggingTabId: e, dragPointer: r, tabbarHover: n, draggingTabElement: o } = q(), { html: s, size: a } = De(o), i = r !== null && e !== null, c = l.useMemo(() => {
|
|
1216
|
+
if (!(!i || !r))
|
|
1217
|
+
return {
|
|
1218
|
+
position: "absolute",
|
|
1219
|
+
left: r.x,
|
|
1220
|
+
top: r.y,
|
|
1221
|
+
transform: `translate(${Yt}, ${Ft})`,
|
|
1222
|
+
pointerEvents: "none"
|
|
1223
|
+
};
|
|
1224
|
+
}, [i, r]), u = l.useMemo(() => {
|
|
1225
|
+
if (!(!c || !o))
|
|
1226
|
+
return a ? { ...c, width: a.width, height: a.height } : c;
|
|
1227
|
+
}, [c, o, a]), d = l.useMemo(() => {
|
|
1228
|
+
if (n)
|
|
1229
|
+
return {
|
|
1230
|
+
...ke,
|
|
1231
|
+
left: n.insertX,
|
|
1232
|
+
top: n.rect.top + 4,
|
|
1233
|
+
height: Math.max(0, n.rect.height - 8)
|
|
1234
|
+
};
|
|
1235
|
+
}, [n]);
|
|
1236
|
+
return t ? /* @__PURE__ */ H("div", { style: Ae, children: [
|
|
1237
|
+
/* @__PURE__ */ m(l.Activity, { mode: u ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: u, children: /* @__PURE__ */ m(
|
|
1238
|
+
"div",
|
|
1239
|
+
{
|
|
1240
|
+
style: { width: "100%", height: "100%", pointerEvents: "none" },
|
|
1241
|
+
dangerouslySetInnerHTML: { __html: s ?? "" }
|
|
1242
|
+
}
|
|
1243
|
+
) }) }),
|
|
1244
|
+
/* @__PURE__ */ m(l.Activity, { mode: d ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: d }) })
|
|
1245
|
+
] }) : null;
|
|
1246
|
+
}, M = (t) => t.type === "group", Y = (t, e = []) => {
|
|
1247
|
+
if (M(t))
|
|
1248
|
+
return [...e, t.groupId];
|
|
1249
|
+
const r = Y(t.a, e);
|
|
1250
|
+
return Y(t.b, r);
|
|
1251
|
+
}, W = (t, e) => e.reduce((r, n) => M(r) ? r : r[n], t), F = (t, e, r) => {
|
|
1252
|
+
if (e.length === 0)
|
|
1253
|
+
return r;
|
|
1254
|
+
const [n, ...o] = e;
|
|
1255
|
+
return M(t) ? t : n === "a" ? { ...t, a: F(t.a, o, r) } : { ...t, b: F(t.b, o, r) };
|
|
1256
|
+
}, U = (t, e, r = []) => {
|
|
1257
|
+
if (M(t))
|
|
1258
|
+
return t.groupId === e ? { splitPath: null, side: null } : null;
|
|
1259
|
+
if (M(t.a) && t.a.groupId === e)
|
|
1260
|
+
return { splitPath: r, side: "a" };
|
|
1261
|
+
if (M(t.b) && t.b.groupId === e)
|
|
1262
|
+
return { splitPath: r, side: "b" };
|
|
1263
|
+
const n = U(t.a, e, [...r, "a"]);
|
|
1264
|
+
return n || U(t.b, e, [...r, "b"]);
|
|
1265
|
+
}, It = (t, e, r, n) => {
|
|
1266
|
+
const o = n(), s = U(t, e), a = {
|
|
1267
|
+
type: "split",
|
|
1268
|
+
direction: r,
|
|
1269
|
+
ratio: 0.5,
|
|
1270
|
+
a: { type: "group", groupId: e },
|
|
1271
|
+
b: { type: "group", groupId: o }
|
|
1272
|
+
};
|
|
1273
|
+
if (!s || s.splitPath === null)
|
|
1274
|
+
return { tree: a, newGroupId: o };
|
|
1275
|
+
const i = s.splitPath, c = W(t, i);
|
|
1276
|
+
if (M(c))
|
|
1277
|
+
return { tree: a, newGroupId: o };
|
|
1278
|
+
const u = s.side === "a" ? { ...c, a } : { ...c, b: a };
|
|
1279
|
+
return { tree: F(t, i, u), newGroupId: o };
|
|
1280
|
+
}, Me = (t, e) => {
|
|
1281
|
+
const r = U(t, e);
|
|
1282
|
+
if (!r || r.splitPath === null)
|
|
1283
|
+
return { tree: t, survivorGroupId: e };
|
|
1284
|
+
const n = r.splitPath, o = W(t, n);
|
|
1285
|
+
if (M(o))
|
|
1286
|
+
return { tree: t, survivorGroupId: e };
|
|
1287
|
+
const s = r.side === "a" ? o.b : o.a, a = F(t, n, s), i = M(s) ? s.groupId : Y(s)[0] ?? null;
|
|
1288
|
+
return { tree: a, survivorGroupId: i };
|
|
1289
|
+
}, Oe = (t, e, r) => {
|
|
1290
|
+
const n = W(t, e);
|
|
1291
|
+
if (M(n))
|
|
1292
|
+
return t;
|
|
1293
|
+
const o = { ...n, ratio: _(r, 0.05, 0.95) };
|
|
1294
|
+
return F(t, e, o);
|
|
1295
|
+
}, Q = (t) => {
|
|
1296
|
+
if (Object.keys(t.groups).filter((o) => t.groups[o].tabIds.length === 0).length === 0)
|
|
1297
|
+
return t;
|
|
1298
|
+
const n = (o, s) => {
|
|
1299
|
+
const a = o.groups[s];
|
|
1300
|
+
if (!a || a.tabs.length > 0 || Object.keys(o.groups).length <= 1)
|
|
1301
|
+
return o;
|
|
1302
|
+
const { tree: c, survivorGroupId: u } = Me(o.tree, s), { [s]: d, ...g } = o.groups, v = Y(c), T = o.focusedGroupId === s ? u ?? v[0] ?? null : o.focusedGroupId;
|
|
1303
|
+
return { ...o, tree: c, groups: g, groupOrder: v, focusedGroupId: T };
|
|
1304
|
+
};
|
|
1305
|
+
return t.groupOrder.reduce((o, s) => n(o, s), t);
|
|
1306
|
+
}, Be = (t) => ({ id: t, tabIds: [], tabs: [], activeTabId: null }), it = (t, e, r, n) => {
|
|
1307
|
+
const o = { ...t.groups }, s = o[e];
|
|
1308
|
+
if (!s)
|
|
1309
|
+
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((g) => a[g]), d = { ...s, tabIds: i, tabs: u, activeTabId: c };
|
|
1311
|
+
return o[e] = d, { ...t, panels: a, groups: o };
|
|
1312
|
+
}, Le = (t, e, r) => {
|
|
1313
|
+
const n = { ...t.groups }, o = n[e];
|
|
1314
|
+
if (!o)
|
|
1315
|
+
throw new Error(`Group ${e} does not exist.`);
|
|
1316
|
+
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
|
+
return n[e] = { ...o, tabIds: s, tabs: a, activeTabId: i }, { ...t, groups: n };
|
|
1318
|
+
}, at = (t, e, r, n, o) => {
|
|
1319
|
+
const s = t.groups[e], a = t.groups[r];
|
|
1320
|
+
if (!s || !a)
|
|
1321
|
+
throw new Error("moveTab: source or target group is missing.");
|
|
1322
|
+
const i = { ...t.groups }, c = s.tabIds.filter((g) => g !== n), u = [...a.tabIds.filter((g) => g !== n), n], d = s.activeTabId === n ? c[0] ?? null : s.activeTabId;
|
|
1323
|
+
return i[e] = { ...s, tabIds: c, tabs: c.map((g) => t.panels[g]), activeTabId: d }, i[r] = { ...a, tabIds: u, tabs: u.map((g) => t.panels[g]), activeTabId: n }, { ...t, groups: i };
|
|
1324
|
+
}, wt = (t, e, r) => {
|
|
1325
|
+
const n = t.groups[e];
|
|
1326
|
+
if (!n)
|
|
1327
|
+
throw new Error(`setActiveTab: group ${e} not found.`);
|
|
1328
|
+
if (!n.tabIds.some((s) => s === r))
|
|
1329
|
+
throw new Error(`setActiveTab: tab ${r} not found in group ${e}.`);
|
|
1330
|
+
const o = { ...t.groups, [e]: { ...n, activeTabId: r } };
|
|
1331
|
+
return { ...t, groups: o, focusedGroupId: e };
|
|
1332
|
+
}, ct = (t, e, r, n, o) => {
|
|
1333
|
+
const s = t.groups[e];
|
|
1334
|
+
if (!s)
|
|
1335
|
+
throw new Error(`addTabToGroupAtIndex: group ${e} not found.`);
|
|
1336
|
+
const a = { ...t.panels, [r.id]: r }, i = s.tabIds.slice(), c = Math.max(0, Math.min(n, i.length));
|
|
1337
|
+
i.splice(c, 0, r.id);
|
|
1338
|
+
const u = i.map((v) => a[v]), d = o ? r.id : s.activeTabId ?? r.id, g = { ...t.groups, [e]: { ...s, tabIds: i, tabs: u, activeTabId: d } };
|
|
1339
|
+
return { ...t, panels: a, groups: g };
|
|
1340
|
+
}, $ = (t, e) => {
|
|
1341
|
+
if (!t.groups[e])
|
|
1342
|
+
throw new Error(`setFocusedGroup: group ${e} not found.`);
|
|
1343
|
+
return { ...t, focusedGroupId: e };
|
|
1344
|
+
}, $e = (t, e) => {
|
|
1345
|
+
const r = e - 1, n = t.groupOrder[r];
|
|
1346
|
+
return n ? $(t, n) : t;
|
|
1347
|
+
}, He = (t) => {
|
|
1348
|
+
const e = t.groupOrder, r = t.focusedGroupId;
|
|
1349
|
+
if (!r) {
|
|
1350
|
+
const s = e[0];
|
|
1351
|
+
return s ? $(t, s) : t;
|
|
1352
|
+
}
|
|
1353
|
+
const n = e.indexOf(r), o = e[(n + 1) % e.length];
|
|
1354
|
+
return $(t, o);
|
|
1355
|
+
}, Ne = (t) => {
|
|
1356
|
+
const e = t.groupOrder, r = t.focusedGroupId;
|
|
1357
|
+
if (!r) {
|
|
1358
|
+
const s = e[e.length - 1];
|
|
1359
|
+
return s ? $(t, s) : t;
|
|
1360
|
+
}
|
|
1361
|
+
const n = e.indexOf(r), o = e[(n - 1 + e.length) % e.length];
|
|
1362
|
+
return $(t, o);
|
|
1363
|
+
}, yt = (t, e, r, n) => {
|
|
1364
|
+
const { tree: o, newGroupId: s } = It(t.tree, e, r, n), a = { ...t.groups, [s]: Be(s) }, i = Y(o);
|
|
1365
|
+
return { ...t, tree: o, groups: a, groupOrder: i, focusedGroupId: s };
|
|
1366
|
+
}, br = (t) => {
|
|
1367
|
+
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
|
+
return { tree: r, panels: n, groups: s, groupOrder: ["g_1"], focusedGroupId: "g_1" };
|
|
1369
|
+
}, ze = l.createContext(null), Xe = ({ value: t, children: e }) => /* @__PURE__ */ m(ze.Provider, { value: t, children: e }), Tt = l.createContext(null), Ye = () => {
|
|
1370
|
+
const t = l.useContext(Tt);
|
|
1371
|
+
if (!t)
|
|
1372
|
+
throw new Error("useTree must be used within TreeProvider");
|
|
1373
|
+
return t;
|
|
1374
|
+
}, Fe = ({ value: t, children: e }) => /* @__PURE__ */ m(Tt.Provider, { value: t, children: e }), je = l.createContext(null), Ve = ({ value: t, children: e }) => /* @__PURE__ */ m(je.Provider, { value: t, children: e }), z = (t) => {
|
|
1375
|
+
const e = kt(t, Number.POSITIVE_INFINITY);
|
|
1376
|
+
return _(e, 1);
|
|
1377
|
+
}, Ke = (t) => typeof t == "object" && t !== null, Ue = (t) => Ke(t) ? "rows" in t ? !0 : "cols" in t : !1, Gt = (t) => {
|
|
1378
|
+
if (!t)
|
|
1379
|
+
return {
|
|
1380
|
+
rows: Number.POSITIVE_INFINITY,
|
|
1381
|
+
cols: Number.POSITIVE_INFINITY
|
|
1382
|
+
};
|
|
1383
|
+
if (typeof t == "number") {
|
|
1384
|
+
const r = z(t);
|
|
1385
|
+
return { rows: r, cols: r };
|
|
1386
|
+
}
|
|
1387
|
+
if (Ue(t))
|
|
1388
|
+
return {
|
|
1389
|
+
rows: z(t.rows),
|
|
1390
|
+
cols: z(t.cols)
|
|
1391
|
+
};
|
|
1392
|
+
const e = t;
|
|
1393
|
+
return {
|
|
1394
|
+
rows: z(e.maxHorizontal),
|
|
1395
|
+
cols: z(e.maxVertical)
|
|
1396
|
+
};
|
|
1397
|
+
}, tt = (t) => {
|
|
1398
|
+
if (M(t))
|
|
1399
|
+
return { horizontal: 1, vertical: 1 };
|
|
1400
|
+
const e = tt(t.a), r = tt(t.b);
|
|
1401
|
+
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
|
+
}, qe = (t, e, r) => {
|
|
1403
|
+
const { tree: n } = It(t, e, r, () => "__preview__");
|
|
1404
|
+
return n;
|
|
1405
|
+
}, rt = (t, e, r, n) => {
|
|
1406
|
+
if (!Number.isFinite(n.rows) && !Number.isFinite(n.cols))
|
|
1407
|
+
return !0;
|
|
1408
|
+
const o = qe(t, e, r), s = tt(o);
|
|
1409
|
+
return !(s.horizontal > n.rows || s.vertical > n.cols);
|
|
1410
|
+
}, xt = {
|
|
1411
|
+
splitFocused: A("panelState/splitFocused", (t) => ({ direction: t })),
|
|
1412
|
+
focusGroupIndex: A("panelState/focusGroupIndex", (t) => ({ index1Based: t })),
|
|
1413
|
+
focusNextGroup: A("panelState/focusNextGroup"),
|
|
1414
|
+
focusPrevGroup: A("panelState/focusPrevGroup"),
|
|
1415
|
+
setActiveTab: A("panelState/setActiveTab", (t, e) => ({ groupId: t, tabId: e })),
|
|
1416
|
+
addTab: A(
|
|
1417
|
+
"panelState/addTab",
|
|
1418
|
+
(t) => t
|
|
1419
|
+
),
|
|
1420
|
+
addNewTab: A(
|
|
1421
|
+
"panelState/addNewTab",
|
|
1422
|
+
(t) => t
|
|
1423
|
+
),
|
|
1424
|
+
removeTab: A("panelState/removeTab", (t, e) => ({ groupId: t, tabId: e })),
|
|
1425
|
+
contentDrop: A(
|
|
1426
|
+
"panelState/contentDrop",
|
|
1427
|
+
(t) => t
|
|
1428
|
+
),
|
|
1429
|
+
tabDrop: A(
|
|
1430
|
+
"panelState/tabDrop",
|
|
1431
|
+
(t) => t
|
|
1432
|
+
),
|
|
1433
|
+
adjustSplitRatio: A("panelState/adjustSplitRatio", (t) => t)
|
|
1434
|
+
}, We = (t, e, r) => {
|
|
1435
|
+
const n = t.groups[e.fromGroupId], o = t.groups[e.targetGroupId];
|
|
1436
|
+
if (!n || !o || !n.tabs.find((g) => g.id === e.tabId))
|
|
1437
|
+
return t;
|
|
1438
|
+
if (e.zone === "center" && e.fromGroupId === e.targetGroupId)
|
|
1439
|
+
return wt(t, e.fromGroupId, e.tabId);
|
|
1440
|
+
if (e.zone === "center") {
|
|
1441
|
+
const g = at(t, e.fromGroupId, e.targetGroupId, e.tabId);
|
|
1442
|
+
return $(g, e.targetGroupId);
|
|
1443
|
+
}
|
|
1444
|
+
const a = e.zone === "left" || e.zone === "right" ? "vertical" : "horizontal";
|
|
1445
|
+
if (!rt(t.tree, e.targetGroupId, a, r.splitLimits))
|
|
1446
|
+
return t;
|
|
1447
|
+
const i = r.createGroupId(), c = yt(t, e.targetGroupId, a, () => i), u = e.zone === "left" || e.zone === "top" ? e.targetGroupId : i, d = at(c, e.fromGroupId, u, e.tabId);
|
|
1448
|
+
return $(d, u);
|
|
1449
|
+
}, Ze = (t, e) => {
|
|
1450
|
+
const r = t.groups[e.fromGroupId], n = t.groups[e.targetGroupId];
|
|
1451
|
+
if (!r || !n || !t.panels[e.tabId])
|
|
1452
|
+
return t;
|
|
1453
|
+
if (e.fromGroupId === e.targetGroupId) {
|
|
1454
|
+
const v = r.tabIds.filter((y) => y !== e.tabId), T = Math.max(0, Math.min(e.targetIndex, v.length)), h = v.slice(0, T).concat([e.tabId], v.slice(T)), w = h.map((y) => t.panels[y]).filter(Boolean), b = { ...t.groups, [e.fromGroupId]: { ...r, tabIds: h, tabs: w } };
|
|
1455
|
+
return { ...t, groups: b };
|
|
1456
|
+
}
|
|
1457
|
+
const s = { ...t.groups }, a = r.tabIds.filter((v) => v !== e.tabId), i = a.map((v) => t.panels[v]);
|
|
1458
|
+
s[e.fromGroupId] = {
|
|
1459
|
+
...r,
|
|
1460
|
+
tabIds: a,
|
|
1461
|
+
tabs: i,
|
|
1462
|
+
activeTabId: r.activeTabId === e.tabId ? i[0]?.id ?? null : r.activeTabId
|
|
1463
|
+
};
|
|
1464
|
+
const c = n.tabIds.filter((v) => v !== e.tabId), u = Math.max(0, Math.min(e.targetIndex, c.length)), d = c.slice(0, u).concat([e.tabId], c.slice(u)), g = d.map((v) => t.panels[v]).filter(Boolean);
|
|
1465
|
+
return s[e.targetGroupId] = { ...n, tabIds: d, tabs: g, activeTabId: e.tabId }, { ...t, groups: s, focusedGroupId: e.targetGroupId };
|
|
1466
|
+
}, Je = ht(xt, {
|
|
1467
|
+
splitFocused: (t, e, r) => {
|
|
1468
|
+
const n = t.focusedGroupId ?? t.groupOrder[0] ?? null;
|
|
1469
|
+
return !n || !rt(t.tree, n, e.payload.direction, r.splitLimits) ? t : yt(t, n, e.payload.direction, r.createGroupId);
|
|
1470
|
+
},
|
|
1471
|
+
focusGroupIndex: (t, e) => $e(t, e.payload.index1Based),
|
|
1472
|
+
focusNextGroup: (t) => He(t),
|
|
1473
|
+
focusPrevGroup: (t) => Ne(t),
|
|
1474
|
+
setActiveTab: (t, e) => wt(t, e.payload.groupId, e.payload.tabId),
|
|
1475
|
+
addTab: (t, e) => {
|
|
1476
|
+
const { groupId: r, tab: n, index: o, makeActive: s } = e.payload;
|
|
1477
|
+
return typeof o == "number" ? ct(t, r, n, o, s ?? !0) : it(t, r, n, s ?? !0);
|
|
1478
|
+
},
|
|
1479
|
+
addNewTab: (t, e, r) => {
|
|
1480
|
+
if (!r.createPanelId)
|
|
1481
|
+
throw new Error("addNewTab requires PanelSystemProvider.createPanelId");
|
|
1482
|
+
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" ? ct(t, s, o, a, i ?? !0) : it(t, s, o, i ?? !0);
|
|
1484
|
+
},
|
|
1485
|
+
removeTab: (t, e) => Le(t, e.payload.groupId, e.payload.tabId),
|
|
1486
|
+
contentDrop: (t, e, r) => We(t, e.payload, r),
|
|
1487
|
+
tabDrop: (t, e) => Ze(t, e.payload),
|
|
1488
|
+
adjustSplitRatio: (t, e) => {
|
|
1489
|
+
const r = W(t.tree, e.payload.path);
|
|
1490
|
+
if (M(r))
|
|
1491
|
+
return t;
|
|
1492
|
+
const n = Oe(t.tree, e.payload.path, r.ratio + e.payload.deltaRatio);
|
|
1493
|
+
return { ...t, tree: n };
|
|
1494
|
+
}
|
|
1495
|
+
}), ut = (t, e, r) => {
|
|
1496
|
+
const n = Je[e.type];
|
|
1497
|
+
if (!n)
|
|
1498
|
+
return t;
|
|
1499
|
+
const o = n(t, e, r);
|
|
1500
|
+
return Q(o);
|
|
1501
|
+
}, St = l.createContext(null), j = () => {
|
|
1502
|
+
const t = l.useContext(St);
|
|
1503
|
+
if (!t)
|
|
1504
|
+
throw new Error("usePanelSystem must be used within PanelSystemProvider");
|
|
1505
|
+
return t;
|
|
1506
|
+
}, Qe = ({
|
|
1507
|
+
initialState: t,
|
|
1508
|
+
createGroupId: e,
|
|
1509
|
+
createPanelId: r,
|
|
1510
|
+
state: n,
|
|
1511
|
+
onStateChange: o,
|
|
1512
|
+
splitLimits: s,
|
|
1513
|
+
children: a
|
|
1514
|
+
}) => {
|
|
1515
|
+
const i = l.useMemo(() => Q(t), [t]), c = l.useMemo(() => Gt(s), [s]), u = l.useRef({ createGroupId: e, splitLimits: c, createPanelId: r });
|
|
1516
|
+
u.current.createGroupId = e, u.current.splitLimits = c, u.current.createPanelId = r;
|
|
1517
|
+
const [d, g] = l.useReducer(
|
|
1518
|
+
(G, E) => ut(G, E, u.current),
|
|
1519
|
+
i
|
|
1520
|
+
), v = l.useMemo(
|
|
1521
|
+
() => n ? Q(n) : d,
|
|
1522
|
+
[n, d]
|
|
1523
|
+
), T = l.useRef(v);
|
|
1524
|
+
T.current = v;
|
|
1525
|
+
const h = n !== void 0, w = l.useCallback(
|
|
1526
|
+
(G) => {
|
|
1527
|
+
if (h) {
|
|
1528
|
+
const E = ut(T.current, G, u.current);
|
|
1529
|
+
o?.(E);
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
g(G);
|
|
1533
|
+
},
|
|
1534
|
+
[h, o, g]
|
|
1535
|
+
), b = l.useMemo(() => fe(xt, w), [w]), y = l.useMemo(
|
|
1536
|
+
() => ({
|
|
1537
|
+
setActiveTab: b.setActiveTab,
|
|
1538
|
+
tabDrop: b.tabDrop
|
|
1539
|
+
}),
|
|
1540
|
+
[b]
|
|
1541
|
+
), f = l.useMemo(
|
|
1542
|
+
() => ({
|
|
1543
|
+
adjustSplitRatio: b.adjustSplitRatio
|
|
1544
|
+
}),
|
|
1545
|
+
[b]
|
|
1546
|
+
), I = l.useMemo(
|
|
1547
|
+
() => ({
|
|
1548
|
+
focusGroupIndex: b.focusGroupIndex,
|
|
1549
|
+
focusNextGroup: b.focusNextGroup,
|
|
1550
|
+
focusPrevGroup: b.focusPrevGroup
|
|
1551
|
+
}),
|
|
1552
|
+
[b]
|
|
1553
|
+
), p = l.useMemo(
|
|
1554
|
+
() => ({
|
|
1555
|
+
state: v,
|
|
1556
|
+
dispatch: w,
|
|
1557
|
+
actions: b
|
|
1558
|
+
}),
|
|
1559
|
+
[v, w, b]
|
|
1560
|
+
);
|
|
1561
|
+
return /* @__PURE__ */ m(St.Provider, { value: p, children: /* @__PURE__ */ m(Xe, { value: y, children: /* @__PURE__ */ m(Fe, { value: f, children: /* @__PURE__ */ m(Ve, { value: I, children: a }) }) }) });
|
|
1562
|
+
}, tr = () => {
|
|
1563
|
+
const { actions: t } = j();
|
|
1564
|
+
return l.useMemo(
|
|
1565
|
+
() => ({
|
|
1566
|
+
splitFocused: (e) => {
|
|
1567
|
+
t.splitFocused(e);
|
|
1568
|
+
},
|
|
1569
|
+
focusGroupIndex: (e) => {
|
|
1570
|
+
t.focusGroupIndex(e);
|
|
1571
|
+
},
|
|
1572
|
+
focusNextGroup: () => {
|
|
1573
|
+
t.focusNextGroup();
|
|
1574
|
+
},
|
|
1575
|
+
focusPrevGroup: () => {
|
|
1576
|
+
t.focusPrevGroup();
|
|
1577
|
+
},
|
|
1578
|
+
closeFocusedGroup: () => {
|
|
1579
|
+
}
|
|
1580
|
+
}),
|
|
1581
|
+
[t]
|
|
1582
|
+
);
|
|
1583
|
+
}, er = () => {
|
|
1584
|
+
const { actions: t } = j(), e = l.useCallback(
|
|
1585
|
+
({ fromGroupId: n, tabId: o, targetGroupId: s, zone: a }) => {
|
|
1586
|
+
t.contentDrop({ fromGroupId: n, tabId: o, targetGroupId: s, zone: a });
|
|
1587
|
+
},
|
|
1588
|
+
[t]
|
|
1589
|
+
), r = l.useCallback(
|
|
1590
|
+
({ fromGroupId: n, tabId: o, targetGroupId: s, targetIndex: a }) => {
|
|
1591
|
+
t.tabDrop({ fromGroupId: n, tabId: o, targetGroupId: s, targetIndex: a });
|
|
1592
|
+
},
|
|
1593
|
+
[t]
|
|
1594
|
+
);
|
|
1595
|
+
return { onCommitContentDrop: e, onCommitTabDrop: r };
|
|
1596
|
+
}, rr = () => {
|
|
1597
|
+
const t = Jt(), e = tr();
|
|
1598
|
+
return l.useEffect(() => {
|
|
1599
|
+
ee(t, e);
|
|
1600
|
+
}, [t, e]), null;
|
|
1601
|
+
}, nr = ({
|
|
1602
|
+
children: t,
|
|
1603
|
+
emptyContentComponent: e,
|
|
1604
|
+
doubleClickToAdd: r
|
|
1605
|
+
}) => {
|
|
1606
|
+
const n = q(), { state: o, actions: s } = j(), a = l.useCallback(() => l.createElement("div", { style: { color: "#888", fontSize: 12, padding: 12 } }, "No tabs"), []), i = e ?? a, c = l.useCallback(
|
|
1607
|
+
(b) => {
|
|
1608
|
+
const y = o.groups[b];
|
|
1609
|
+
if (!y)
|
|
1610
|
+
return null;
|
|
1611
|
+
const f = y.tabIds.map((I) => o.panels[I]).filter(Boolean);
|
|
1612
|
+
return { ...y, tabs: f };
|
|
1613
|
+
},
|
|
1614
|
+
[o.groups, o.panels]
|
|
1615
|
+
), u = l.useCallback(
|
|
1616
|
+
(b) => {
|
|
1617
|
+
const y = o.groups[b];
|
|
1618
|
+
if (!y)
|
|
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, {});
|
|
1625
|
+
},
|
|
1626
|
+
[o.groups, o.panels, i]
|
|
1627
|
+
), d = l.useCallback((b, y) => {
|
|
1628
|
+
s.setActiveTab(b, y);
|
|
1629
|
+
}, [s]), g = l.useCallback((b) => {
|
|
1630
|
+
s.addNewTab({ groupId: b, title: "New Tab", makeActive: !0 });
|
|
1631
|
+
}, [s]), v = l.useCallback((b, y) => {
|
|
1632
|
+
s.removeTab(b, y);
|
|
1633
|
+
}, [s]), T = l.useCallback((b, y, f) => {
|
|
1634
|
+
s.setActiveTab(y, b), n.onStartTabDrag(b, y, f);
|
|
1635
|
+
}, [s, n]), h = l.useCallback((b, y) => {
|
|
1636
|
+
const f = o.groups[b];
|
|
1637
|
+
!f || !f.activeTabId || n.onStartContentDrag(b, f.activeTabId, y);
|
|
1638
|
+
}, [o.groups, n]), w = l.useMemo(
|
|
1639
|
+
() => ({ getGroup: c, getGroupContent: u, onClickTab: d, onAddTab: g, onCloseTab: v, onStartTabDrag: T, onStartContentDrag: h, doubleClickToAdd: r }),
|
|
1640
|
+
[c, u, d, g, v, T, h, r]
|
|
1641
|
+
);
|
|
1642
|
+
return /* @__PURE__ */ m(ie, { value: w, children: t });
|
|
1643
|
+
}, X = (t, e, r, n) => {
|
|
1644
|
+
if (M(t))
|
|
1645
|
+
return n;
|
|
1646
|
+
const o = t.direction, s = o === "vertical" ? r.x + r.w * t.ratio : r.y + r.h * t.ratio;
|
|
1647
|
+
if (n.push({ path: e, direction: o, parentRect: r, linePos: s }), o === "vertical") {
|
|
1648
|
+
const c = r.w * t.ratio, u = r.w - c;
|
|
1649
|
+
return X(t.a, [...e, "a"], { x: r.x, y: r.y, w: c, h: r.h }, n), X(t.b, [...e, "b"], { x: r.x + c, y: r.y, w: u, h: r.h }, n), n;
|
|
1650
|
+
}
|
|
1651
|
+
const a = r.h * t.ratio, i = r.h - a;
|
|
1652
|
+
return X(t.a, [...e, "a"], { x: r.x, y: r.y, w: r.w, h: a }, n), X(t.b, [...e, "b"], { x: r.x, y: r.y + a, w: r.w, h: i }, n), n;
|
|
1653
|
+
}, or = ({ containerRef: t }) => {
|
|
1654
|
+
const { state: e } = j(), { adjustSplitRatio: r } = Ye(), n = l.useMemo(() => X(e.tree, [], { x: 0, y: 0, w: 100, h: 100 }, []), [e.tree]), [o, s] = l.useState(null);
|
|
1655
|
+
if (l.useLayoutEffect(() => {
|
|
1656
|
+
const i = t.current;
|
|
1657
|
+
if (!i)
|
|
1658
|
+
return;
|
|
1659
|
+
const c = () => {
|
|
1660
|
+
const T = i.getBoundingClientRect();
|
|
1661
|
+
s({ left: T.left, top: T.top, width: T.width, height: T.height });
|
|
1662
|
+
};
|
|
1663
|
+
c();
|
|
1664
|
+
function u() {
|
|
1665
|
+
try {
|
|
1666
|
+
const T = window.ResizeObserver;
|
|
1667
|
+
return typeof T == "function" ? T : null;
|
|
1668
|
+
} catch {
|
|
1669
|
+
return null;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
const d = u(), g = d ? new d(() => c()) : null;
|
|
1673
|
+
g && g.observe(i);
|
|
1674
|
+
const v = () => c();
|
|
1675
|
+
return window.addEventListener("scroll", v, !0), () => {
|
|
1676
|
+
window.removeEventListener("scroll", v, !0), g && g.disconnect();
|
|
1677
|
+
};
|
|
1678
|
+
}, [t, e.tree]), !o)
|
|
1679
|
+
return null;
|
|
1680
|
+
const a = (i, c) => {
|
|
1681
|
+
const u = {
|
|
1682
|
+
left: o.left + o.width * i.parentRect.x / 100,
|
|
1683
|
+
top: o.top + o.height * i.parentRect.y / 100,
|
|
1684
|
+
width: o.width * i.parentRect.w / 100,
|
|
1685
|
+
height: o.height * i.parentRect.h / 100
|
|
1686
|
+
}, d = Wt;
|
|
1687
|
+
if (i.direction === "vertical") {
|
|
1688
|
+
const h = u.left + u.width * (i.linePos - i.parentRect.x) / i.parentRect.w, w = {
|
|
1689
|
+
position: "fixed",
|
|
1690
|
+
left: `calc(${Math.round(h)}px - ${d} / 2)`,
|
|
1691
|
+
top: Math.round(u.top),
|
|
1692
|
+
width: d,
|
|
1693
|
+
height: Math.round(u.height),
|
|
1694
|
+
cursor: "col-resize",
|
|
1695
|
+
pointerEvents: "auto"
|
|
1696
|
+
};
|
|
1697
|
+
return /* @__PURE__ */ m("div", { style: w, children: /* @__PURE__ */ m(nt, { direction: "vertical", onResize: (y) => {
|
|
1698
|
+
const f = o.width * i.parentRect.w / 100, I = f === 0 ? 0 : y / f;
|
|
1699
|
+
r({ path: i.path, deltaRatio: I });
|
|
1700
|
+
} }) }, `split-${c}`);
|
|
1701
|
+
}
|
|
1702
|
+
const g = u.top + u.height * (i.linePos - i.parentRect.y) / i.parentRect.h, v = {
|
|
1703
|
+
position: "fixed",
|
|
1704
|
+
left: Math.round(u.left),
|
|
1705
|
+
top: `calc(${Math.round(g)}px - ${d} / 2)`,
|
|
1706
|
+
width: Math.round(u.width),
|
|
1707
|
+
height: d,
|
|
1708
|
+
cursor: "row-resize",
|
|
1709
|
+
pointerEvents: "auto"
|
|
1710
|
+
};
|
|
1711
|
+
return /* @__PURE__ */ m("div", { style: v, children: /* @__PURE__ */ m(nt, { direction: "horizontal", onResize: (h) => {
|
|
1712
|
+
const w = o.height * i.parentRect.h / 100, b = w === 0 ? 0 : h / w;
|
|
1713
|
+
r({ path: i.path, deltaRatio: b });
|
|
1714
|
+
} }) }, `split-${c}`);
|
|
1715
|
+
};
|
|
1716
|
+
return /* @__PURE__ */ m("div", { style: { position: "fixed", inset: 0, pointerEvents: "none" }, children: n.map((i, c) => a(i, c)) });
|
|
1717
|
+
}, sr = {
|
|
1718
|
+
position: "relative",
|
|
1719
|
+
display: "flex",
|
|
1720
|
+
width: "100%",
|
|
1721
|
+
height: "100%"
|
|
1722
|
+
}, ir = ({
|
|
1723
|
+
state: t,
|
|
1724
|
+
layoutMode: e,
|
|
1725
|
+
gridTracksInteractive: r,
|
|
1726
|
+
view: n,
|
|
1727
|
+
tabBarComponent: o,
|
|
1728
|
+
panelGroupComponent: s
|
|
1729
|
+
}) => {
|
|
1730
|
+
const a = (c) => n ? /* @__PURE__ */ m(n, { groupId: c }) : /* @__PURE__ */ m(ye, { id: c, TabBarComponent: o, PanelGroupComponent: s });
|
|
1731
|
+
if (e === "grid") {
|
|
1732
|
+
const c = oe(t, a, !!r);
|
|
1733
|
+
return /* @__PURE__ */ m(ot, { config: c.config, layers: c.layers });
|
|
1734
|
+
}
|
|
1735
|
+
const i = ne(t, a);
|
|
1736
|
+
return /* @__PURE__ */ m(ot, { config: i.config, layers: i.layers });
|
|
1737
|
+
}, ar = ({
|
|
1738
|
+
containerRef: t,
|
|
1739
|
+
layoutMode: e,
|
|
1740
|
+
gridTracksInteractive: r,
|
|
1741
|
+
dragThresholdPx: n,
|
|
1742
|
+
view: o,
|
|
1743
|
+
style: s,
|
|
1744
|
+
className: a,
|
|
1745
|
+
tabBarComponent: i,
|
|
1746
|
+
panelGroupComponent: c,
|
|
1747
|
+
splitLimits: u,
|
|
1748
|
+
emptyContentComponent: d,
|
|
1749
|
+
doubleClickToAdd: g
|
|
1750
|
+
}) => {
|
|
1751
|
+
const { state: v } = j(), { onCommitContentDrop: T, onCommitTabDrop: h } = er(), w = l.useMemo(() => ({ ...sr, ...s }), [s]), b = l.useCallback(
|
|
1752
|
+
({ targetGroupId: y, zone: f }) => {
|
|
1753
|
+
if (f === "center")
|
|
1754
|
+
return !0;
|
|
1755
|
+
const I = f === "left" || f === "right" ? "vertical" : "horizontal";
|
|
1756
|
+
return rt(v.tree, y, I, u);
|
|
1757
|
+
},
|
|
1758
|
+
[v.tree, u]
|
|
1759
|
+
);
|
|
1760
|
+
return /* @__PURE__ */ m(ae, { children: /* @__PURE__ */ H(
|
|
1761
|
+
he,
|
|
1762
|
+
{
|
|
1763
|
+
containerRef: t,
|
|
1764
|
+
dragThresholdPx: n,
|
|
1765
|
+
onCommitContentDrop: T,
|
|
1766
|
+
onCommitTabDrop: h,
|
|
1767
|
+
isContentZoneAllowed: b,
|
|
1768
|
+
children: [
|
|
1769
|
+
/* @__PURE__ */ m(nr, { emptyContentComponent: d, doubleClickToAdd: g, children: /* @__PURE__ */ m("div", { ref: t, className: a, style: w, children: /* @__PURE__ */ m(
|
|
1770
|
+
ir,
|
|
1771
|
+
{
|
|
1772
|
+
state: v,
|
|
1773
|
+
layoutMode: e,
|
|
1774
|
+
gridTracksInteractive: r,
|
|
1775
|
+
view: o,
|
|
1776
|
+
tabBarComponent: i,
|
|
1777
|
+
panelGroupComponent: c
|
|
1778
|
+
}
|
|
1779
|
+
) }) }),
|
|
1780
|
+
/* @__PURE__ */ m(or, { containerRef: t }),
|
|
1781
|
+
/* @__PURE__ */ m(cr, {})
|
|
1782
|
+
]
|
|
1783
|
+
}
|
|
1784
|
+
) });
|
|
1785
|
+
}, cr = () => {
|
|
1786
|
+
const t = q();
|
|
1787
|
+
return /* @__PURE__ */ H(et, { children: [
|
|
1788
|
+
/* @__PURE__ */ m(Pe, { suggest: t.suggest }),
|
|
1789
|
+
/* @__PURE__ */ m(_e, {})
|
|
1790
|
+
] });
|
|
1791
|
+
}, gr = ({
|
|
1792
|
+
initialState: t,
|
|
1793
|
+
createGroupId: e,
|
|
1794
|
+
createPanelId: r,
|
|
1795
|
+
layoutMode: n,
|
|
1796
|
+
gridTracksInteractive: o,
|
|
1797
|
+
dragThresholdPx: s,
|
|
1798
|
+
view: a,
|
|
1799
|
+
emptyContentComponent: i,
|
|
1800
|
+
state: c,
|
|
1801
|
+
onStateChange: u,
|
|
1802
|
+
className: d,
|
|
1803
|
+
style: g,
|
|
1804
|
+
tabBarComponent: v,
|
|
1805
|
+
panelGroupComponent: T,
|
|
1806
|
+
splitLimits: h,
|
|
1807
|
+
doubleClickToAdd: w
|
|
1808
|
+
}) => {
|
|
1809
|
+
if (!t)
|
|
1810
|
+
throw new Error("PanelSystem requires initialState.");
|
|
1811
|
+
if (!e)
|
|
1812
|
+
throw new Error("PanelSystem requires explicit createGroupId function.");
|
|
1813
|
+
if (!n)
|
|
1814
|
+
throw new Error("PanelSystem requires explicit layoutMode ('absolute' | 'grid').");
|
|
1815
|
+
if (n === "grid" && o === void 0)
|
|
1816
|
+
throw new Error("PanelSystem(layoutMode='grid') requires explicit 'gridTracksInteractive' flag.");
|
|
1817
|
+
if (s === void 0)
|
|
1818
|
+
throw new Error("PanelSystem requires explicit 'dragThresholdPx' value.");
|
|
1819
|
+
const b = l.useRef(null), y = l.useMemo(() => Gt(h), [h]);
|
|
1820
|
+
return /* @__PURE__ */ m(
|
|
1821
|
+
Qe,
|
|
1822
|
+
{
|
|
1823
|
+
initialState: t,
|
|
1824
|
+
createGroupId: e,
|
|
1825
|
+
createPanelId: r,
|
|
1826
|
+
state: c,
|
|
1827
|
+
onStateChange: u,
|
|
1828
|
+
splitLimits: h,
|
|
1829
|
+
children: /* @__PURE__ */ H(te, { children: [
|
|
1830
|
+
/* @__PURE__ */ m(rr, {}),
|
|
1831
|
+
/* @__PURE__ */ m(
|
|
1832
|
+
ar,
|
|
1833
|
+
{
|
|
1834
|
+
containerRef: b,
|
|
1835
|
+
layoutMode: n,
|
|
1836
|
+
gridTracksInteractive: o,
|
|
1837
|
+
dragThresholdPx: s,
|
|
1838
|
+
view: a,
|
|
1839
|
+
style: g,
|
|
1840
|
+
className: d,
|
|
1841
|
+
tabBarComponent: v,
|
|
1842
|
+
panelGroupComponent: T,
|
|
1843
|
+
splitLimits: y,
|
|
1844
|
+
emptyContentComponent: i,
|
|
1845
|
+
doubleClickToAdd: w
|
|
1846
|
+
}
|
|
1847
|
+
)
|
|
1848
|
+
] })
|
|
1849
|
+
}
|
|
1850
|
+
);
|
|
1851
|
+
};
|
|
1852
|
+
export {
|
|
1853
|
+
yr as CSS_VAR_PREFIX,
|
|
1854
|
+
vr as Drawer,
|
|
1855
|
+
Ir as DrawerLayers,
|
|
1856
|
+
ot as GridLayout,
|
|
1857
|
+
pr as HorizontalDivider,
|
|
1858
|
+
gr as PanelSystem,
|
|
1859
|
+
nt as ResizeHandle,
|
|
1860
|
+
br as buildInitialState,
|
|
1861
|
+
fr as useLayerDragHandle
|
|
1862
|
+
};
|
|
1863
|
+
//# sourceMappingURL=index.js.map
|