@liuman/react-workspace 1.4.0 → 1.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/dist/Workspace-BVDjjAYv.js +1321 -0
- package/dist/Workspace-DsDjnfmH.cjs +1 -0
- package/dist/antd.d.ts +5 -0
- package/dist/components/Workspace.d.ts.map +1 -1
- package/dist/hooks/useKeyboardShortcuts.d.ts +14 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts.map +1 -0
- package/dist/hooks/useWorkspace.d.ts.map +1 -1
- package/dist/react-workspace-antd.cjs +1 -1
- package/dist/react-workspace-antd.js +2 -2
- package/dist/react-workspace.cjs +1 -1
- package/dist/react-workspace.css +1 -1
- package/dist/react-workspace.js +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/Workspace-CHrdtgn1.js +0 -1314
- package/dist/Workspace-Ctu43vw4.cjs +0 -1
|
@@ -0,0 +1,1321 @@
|
|
|
1
|
+
import { jsxs as _, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as Y, useState as te, useCallback as R, useEffect as ne, createContext as Te, useContext as ve, useMemo as le, createElement as Pe, forwardRef as De, useImperativeHandle as Ee } from "react";
|
|
3
|
+
import { createPortal as Re } from "react-dom";
|
|
4
|
+
const $e = ({
|
|
5
|
+
tip: e = "加载中...",
|
|
6
|
+
spinning: t = !1,
|
|
7
|
+
children: n
|
|
8
|
+
}) => /* @__PURE__ */ _("div", { className: "rw-spinner-wrap", children: [
|
|
9
|
+
n,
|
|
10
|
+
t && /* @__PURE__ */ _("div", { className: "rw-spinner-overlay", children: [
|
|
11
|
+
/* @__PURE__ */ s("div", { className: "rw-spinner" }),
|
|
12
|
+
e && /* @__PURE__ */ s("span", { className: "rw-spinner-tip", children: e })
|
|
13
|
+
] })
|
|
14
|
+
] }), pe = 100;
|
|
15
|
+
function re(e, t) {
|
|
16
|
+
const n = globalThis.window.innerWidth, i = globalThis.window.innerHeight, f = Math.min(t?.minWidth ?? pe, n), h = Math.min(t?.minHeight ?? pe, i);
|
|
17
|
+
let { x: w, y: u, width: g, height: v } = e;
|
|
18
|
+
return g = Math.min(g, n), v = Math.min(v, i), g = Math.max(g, f), v = Math.max(v, h), w + g > n && (w = Math.max(0, n - g)), u + v > i && (u = Math.max(0, i - v)), w < 0 && (w = 0), u < 0 && (u = 0), { x: w, y: u, width: g, height: v };
|
|
19
|
+
}
|
|
20
|
+
function de(e, t) {
|
|
21
|
+
return `${e}${t}`;
|
|
22
|
+
}
|
|
23
|
+
function ae(e, t) {
|
|
24
|
+
if (!t) return {};
|
|
25
|
+
try {
|
|
26
|
+
const n = de(e, t), i = localStorage.getItem(n);
|
|
27
|
+
if (i) {
|
|
28
|
+
const f = JSON.parse(i);
|
|
29
|
+
if (f && typeof f == "object") {
|
|
30
|
+
const h = {};
|
|
31
|
+
return Object.entries(f).forEach(([w, u]) => {
|
|
32
|
+
if (u && typeof u == "object") {
|
|
33
|
+
const g = u, v = {};
|
|
34
|
+
g.position && typeof g.position.x == "number" && typeof g.position.y == "number" && typeof g.position.width == "number" && typeof g.position.height == "number" && (v.position = re(g.position)), typeof g.minimized == "boolean" && (v.minimized = g.minimized), typeof g.floating == "boolean" && (v.floating = g.floating), typeof g.floatingZIndex == "number" && (v.floatingZIndex = g.floatingZIndex), h[w] = v;
|
|
35
|
+
}
|
|
36
|
+
}), h;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} catch (n) {
|
|
40
|
+
console.warn("[react-workspace] 从 localStorage 读取窗口状态失败:", n);
|
|
41
|
+
}
|
|
42
|
+
return {};
|
|
43
|
+
}
|
|
44
|
+
function ce(e, t, n, i) {
|
|
45
|
+
if (t)
|
|
46
|
+
try {
|
|
47
|
+
const f = ae(e, t);
|
|
48
|
+
f[n] = { ...f[n], ...i }, localStorage.setItem(de(e, t), JSON.stringify(f));
|
|
49
|
+
} catch (f) {
|
|
50
|
+
console.warn("[react-workspace] 保存窗口状态到 localStorage 失败:", f);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function ue(e, t, n) {
|
|
54
|
+
if (t)
|
|
55
|
+
try {
|
|
56
|
+
const i = de(e, t), f = localStorage.getItem(i);
|
|
57
|
+
let h = f ? JSON.parse(f) : {};
|
|
58
|
+
const w = Object.values(h).map((M) => M?.floatingZIndex || 0).filter((M) => M >= 1e3), u = w.length > 0 ? Math.max(...w) : 999, g = h[n] || {}, v = g.floatingZIndex || 0, j = Math.max(1e3, u + 1);
|
|
59
|
+
v >= 1e3 ? (h[n] = { ...g, floatingZIndex: j }, Object.keys(h).forEach((M) => {
|
|
60
|
+
if (M !== n && h[M]) {
|
|
61
|
+
const O = h[M];
|
|
62
|
+
O.floatingZIndex !== void 0 && O.floatingZIndex >= 1e3 && (h[M] = {
|
|
63
|
+
...O,
|
|
64
|
+
floatingZIndex: Math.max(1e3, O.floatingZIndex - 1)
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
})) : h[n] = { ...g, floatingZIndex: j }, localStorage.setItem(i, JSON.stringify(h));
|
|
68
|
+
} catch (i) {
|
|
69
|
+
console.error("[react-workspace] 保存标签点击顺序失败:", i);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function we(e, t, n) {
|
|
73
|
+
if (e.length === 0) return null;
|
|
74
|
+
try {
|
|
75
|
+
const i = localStorage.getItem(de(t, n));
|
|
76
|
+
if (i) {
|
|
77
|
+
const f = JSON.parse(i);
|
|
78
|
+
return [...e].sort((w, u) => {
|
|
79
|
+
const g = f[w.type]?.floatingZIndex || 0, v = f[u.type]?.floatingZIndex || 0;
|
|
80
|
+
return g >= 1e3 && v >= 1e3 ? v - g : g >= 1e3 ? -1 : v >= 1e3 ? 1 : 0;
|
|
81
|
+
})[0]?.id ?? e[e.length - 1].id;
|
|
82
|
+
}
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
return e[e.length - 1].id;
|
|
86
|
+
}
|
|
87
|
+
const Oe = "react_workspace_windows_", Ze = {
|
|
88
|
+
x: 100,
|
|
89
|
+
y: 100,
|
|
90
|
+
width: 800,
|
|
91
|
+
height: 600,
|
|
92
|
+
minWidth: 400,
|
|
93
|
+
minHeight: 300
|
|
94
|
+
};
|
|
95
|
+
function ye(e) {
|
|
96
|
+
return { ...Ze, ...e };
|
|
97
|
+
}
|
|
98
|
+
function Be(e, t) {
|
|
99
|
+
let n = e;
|
|
100
|
+
if (n.trim().startsWith("%"))
|
|
101
|
+
try {
|
|
102
|
+
n = decodeURIComponent(n);
|
|
103
|
+
} catch {
|
|
104
|
+
}
|
|
105
|
+
const i = JSON.parse(n);
|
|
106
|
+
if (!Array.isArray(i)) throw new Error("窗口列表不是数组");
|
|
107
|
+
return i.map((f) => {
|
|
108
|
+
const h = String(f.t ?? f.type ?? "");
|
|
109
|
+
if (!h) throw new Error("窗口缺少类型");
|
|
110
|
+
const w = f.p ?? f.props, u = t?.(h, w) ?? f.n ?? f.title ?? h, g = {
|
|
111
|
+
id: typeof f.id == "string" && f.id ? f.id : ge(),
|
|
112
|
+
type: h,
|
|
113
|
+
title: String(u),
|
|
114
|
+
minimized: !1
|
|
115
|
+
};
|
|
116
|
+
return w && typeof w == "object" && (g.props = w), g;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function ge() {
|
|
120
|
+
return `window-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
|
|
121
|
+
}
|
|
122
|
+
function He(e) {
|
|
123
|
+
const {
|
|
124
|
+
workspaceId: t,
|
|
125
|
+
defaultWindow: n,
|
|
126
|
+
syncToUrl: i = !1,
|
|
127
|
+
preserveUrlParams: f = !0,
|
|
128
|
+
searchParams: h,
|
|
129
|
+
setSearchParams: w,
|
|
130
|
+
storageKeyPrefix: u = Oe,
|
|
131
|
+
floatingDefaults: g,
|
|
132
|
+
onWindowsChange: v,
|
|
133
|
+
resolveTitle: j
|
|
134
|
+
} = e, M = Y(j);
|
|
135
|
+
M.current = j;
|
|
136
|
+
const O = Y(
|
|
137
|
+
n ?? { type: "home", title: "首页", minimized: !1 }
|
|
138
|
+
);
|
|
139
|
+
O.current = n ?? O.current;
|
|
140
|
+
const B = Y(ye(g));
|
|
141
|
+
B.current = ye(g);
|
|
142
|
+
const L = Y(v);
|
|
143
|
+
L.current = v;
|
|
144
|
+
const [x, E] = te([]), [z, H] = te(null), y = Y({}), b = R((r, o) => {
|
|
145
|
+
L.current?.(r, o);
|
|
146
|
+
}, []), A = R(
|
|
147
|
+
(r) => ae(u, t)[r] || null,
|
|
148
|
+
[u, t]
|
|
149
|
+
), X = R(
|
|
150
|
+
(r) => A(r)?.position || null,
|
|
151
|
+
[A]
|
|
152
|
+
), T = R(
|
|
153
|
+
(r, o) => {
|
|
154
|
+
if (!i || !w) return;
|
|
155
|
+
const a = f && h ? new URLSearchParams(h) : new URLSearchParams();
|
|
156
|
+
if (r.length > 0) {
|
|
157
|
+
a.set("windows", JSON.stringify(r.map((c) => {
|
|
158
|
+
const N = { t: c.type };
|
|
159
|
+
return c.props && Object.keys(c.props).length > 0 && (N.p = c.props), N;
|
|
160
|
+
})));
|
|
161
|
+
const d = r.findIndex((c) => c.id === o);
|
|
162
|
+
d >= 0 ? a.set("active", String(d)) : a.delete("active");
|
|
163
|
+
} else
|
|
164
|
+
a.delete("windows"), a.delete("active");
|
|
165
|
+
w(a, { replace: !0 });
|
|
166
|
+
},
|
|
167
|
+
[i, w, f, h]
|
|
168
|
+
), m = R(
|
|
169
|
+
(r, o) => {
|
|
170
|
+
E(r), H(o), T(r, o), b(r, o);
|
|
171
|
+
},
|
|
172
|
+
[T, b]
|
|
173
|
+
), U = R(
|
|
174
|
+
(r) => {
|
|
175
|
+
const o = A(r.type), a = {
|
|
176
|
+
...r,
|
|
177
|
+
minimized: o?.minimized ?? r.minimized ?? !1,
|
|
178
|
+
floating: o?.floating ?? r.floating ?? !1
|
|
179
|
+
};
|
|
180
|
+
if (a.floating) {
|
|
181
|
+
let d = r.floatingPosition || o?.position;
|
|
182
|
+
d || (d = X(r.type) ?? void 0), d && (a.floatingPosition = re(d)), a.floatingZIndex = o?.floatingZIndex ?? r.floatingZIndex ?? 1e3;
|
|
183
|
+
}
|
|
184
|
+
return a;
|
|
185
|
+
},
|
|
186
|
+
[A, X]
|
|
187
|
+
), K = R(() => {
|
|
188
|
+
const r = O.current, o = {
|
|
189
|
+
id: ge(),
|
|
190
|
+
type: r.type,
|
|
191
|
+
title: r.title,
|
|
192
|
+
minimized: r.minimized ?? !1
|
|
193
|
+
};
|
|
194
|
+
m([o], o.id);
|
|
195
|
+
}, [m]), l = R(() => {
|
|
196
|
+
if (t)
|
|
197
|
+
try {
|
|
198
|
+
localStorage.removeItem(`${u}${t}`);
|
|
199
|
+
} catch {
|
|
200
|
+
}
|
|
201
|
+
delete y.current[t], K();
|
|
202
|
+
}, [t, u, K]);
|
|
203
|
+
ne(() => {
|
|
204
|
+
if (!t || y.current[t]) return;
|
|
205
|
+
y.current[t] = !0;
|
|
206
|
+
const r = i ? h?.get("windows") : null, o = i ? h?.get("active") : null;
|
|
207
|
+
if (r)
|
|
208
|
+
try {
|
|
209
|
+
const a = Be(r, M.current);
|
|
210
|
+
if (a.length === 0) throw new Error("窗口列表是空的");
|
|
211
|
+
const d = a.map(U), c = Number(o), N = Number.isInteger(c) && c >= 0 && c < d.length ? d[c].id : d.find((Z) => Z.id === o)?.id ?? d[0]?.id ?? null;
|
|
212
|
+
E(d), H(N), b(d, N);
|
|
213
|
+
} catch (a) {
|
|
214
|
+
console.error("[react-workspace] 解析窗口配置失败:", a), K();
|
|
215
|
+
}
|
|
216
|
+
else
|
|
217
|
+
K();
|
|
218
|
+
}, [t, h, i, U, K, b]);
|
|
219
|
+
const p = R(
|
|
220
|
+
(r, o) => {
|
|
221
|
+
const a = o !== void 0 ? { ...r.props, ...o } : r.props, d = { ...r, props: a }, c = x.find((N) => N.type === d.type);
|
|
222
|
+
if (c) {
|
|
223
|
+
const N = o && Object.keys(o).length === 0 ? void 0 : a, Z = U({ ...c, ...d, props: N }), q = x.map((J) => J.id === c.id ? Z : J);
|
|
224
|
+
m(q, c.id);
|
|
225
|
+
} else {
|
|
226
|
+
const N = U({
|
|
227
|
+
...d,
|
|
228
|
+
id: ge(),
|
|
229
|
+
minimized: d.minimized ?? !1
|
|
230
|
+
});
|
|
231
|
+
m([...x, N], N.id);
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
[x, m, U]
|
|
235
|
+
), W = R(
|
|
236
|
+
(r) => {
|
|
237
|
+
const o = x.find((a) => a.id === r);
|
|
238
|
+
if (o) {
|
|
239
|
+
if (ue(u, t, o.type), o.floating) {
|
|
240
|
+
const a = ae(u, t)[o.type];
|
|
241
|
+
if (a?.floatingZIndex) {
|
|
242
|
+
const d = x.map(
|
|
243
|
+
(c) => c.id === r ? { ...c, minimized: !1, floatingZIndex: a.floatingZIndex } : c
|
|
244
|
+
);
|
|
245
|
+
m(d, r);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
m(
|
|
250
|
+
x.map((a) => a.id === r ? { ...a, minimized: !1 } : a),
|
|
251
|
+
r
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
[x, m, u, t]
|
|
256
|
+
), S = R(
|
|
257
|
+
(r) => {
|
|
258
|
+
const o = x.filter((d) => d.id !== r), a = z === r ? we(o, u, t) : z;
|
|
259
|
+
m(o, a);
|
|
260
|
+
},
|
|
261
|
+
[x, z, m, u, t]
|
|
262
|
+
), I = R(
|
|
263
|
+
(r) => {
|
|
264
|
+
const o = x.map((d) => {
|
|
265
|
+
if (d.id === r) {
|
|
266
|
+
const c = { ...d, minimized: !d.minimized };
|
|
267
|
+
return ce(u, t, d.type, {
|
|
268
|
+
minimized: c.minimized,
|
|
269
|
+
floating: c.floating
|
|
270
|
+
}), c;
|
|
271
|
+
}
|
|
272
|
+
return d;
|
|
273
|
+
}), a = o.find((d) => d.id === r);
|
|
274
|
+
if (a?.minimized && z === r && !a.floating) {
|
|
275
|
+
const d = o.find((c) => !c.minimized && !c.floating);
|
|
276
|
+
m(o, d?.id ?? null);
|
|
277
|
+
} else a && !a.minimized && !a.floating ? m(o, r) : m(o, z);
|
|
278
|
+
},
|
|
279
|
+
[x, z, t, u, m]
|
|
280
|
+
), D = R(
|
|
281
|
+
(r, o) => {
|
|
282
|
+
const a = x.find(($) => $.id === r);
|
|
283
|
+
if (!a || !t || a.floating) return;
|
|
284
|
+
const d = x.filter(($) => !$.floating && !$.minimized);
|
|
285
|
+
if (d.length === 1 && d[0].id === r) return;
|
|
286
|
+
const c = B.current, N = { minWidth: c.minWidth, minHeight: c.minHeight };
|
|
287
|
+
let Z = re(
|
|
288
|
+
{ x: c.x, y: c.y, width: c.width, height: c.height },
|
|
289
|
+
N
|
|
290
|
+
);
|
|
291
|
+
if (o)
|
|
292
|
+
Z = re({
|
|
293
|
+
x: o.x,
|
|
294
|
+
y: o.y,
|
|
295
|
+
width: c.width,
|
|
296
|
+
height: c.height
|
|
297
|
+
}, N);
|
|
298
|
+
else if (a.floatingPosition)
|
|
299
|
+
Z = re(a.floatingPosition, N);
|
|
300
|
+
else {
|
|
301
|
+
const $ = X(a.type);
|
|
302
|
+
$ && (Z = re($, N));
|
|
303
|
+
}
|
|
304
|
+
ue(u, t, a.type);
|
|
305
|
+
const q = ae(u, t)[a.type]?.floatingZIndex ?? 1e3, J = x.map(($) => $.id === r ? (ce(u, t, $.type, {
|
|
306
|
+
floating: !0,
|
|
307
|
+
minimized: !1,
|
|
308
|
+
position: Z,
|
|
309
|
+
floatingZIndex: q
|
|
310
|
+
}), {
|
|
311
|
+
...$,
|
|
312
|
+
floating: !0,
|
|
313
|
+
minimized: !1,
|
|
314
|
+
floatingPosition: Z,
|
|
315
|
+
floatingZIndex: q,
|
|
316
|
+
pendingDragStart: o
|
|
317
|
+
}) : $);
|
|
318
|
+
if (z === r) {
|
|
319
|
+
const $ = J.filter((ee) => !ee.floating && !ee.minimized);
|
|
320
|
+
m(J, $.length > 0 ? we($, u, t) : null);
|
|
321
|
+
} else
|
|
322
|
+
m(J, z);
|
|
323
|
+
},
|
|
324
|
+
[x, z, t, u, m, X]
|
|
325
|
+
), k = R(
|
|
326
|
+
(r, o) => {
|
|
327
|
+
const a = x.find((ee) => ee.id === r);
|
|
328
|
+
if (!a?.floating) return;
|
|
329
|
+
const { floating: d, floatingPosition: c, floatingZIndex: N, pendingDragStart: Z, ...q } = a;
|
|
330
|
+
ce(u, t, a.type, {
|
|
331
|
+
floating: !1,
|
|
332
|
+
minimized: q.minimized
|
|
333
|
+
});
|
|
334
|
+
const J = x.filter((ee) => !ee.floating);
|
|
335
|
+
let $;
|
|
336
|
+
o !== void 0 && o >= 0 && o <= J.length ? $ = [...J.slice(0, o), q, ...J.slice(o)] : $ = [...J, q], $ = [...$, ...x.filter((ee) => ee.floating && ee.id !== r)], m($, r), setTimeout(() => {
|
|
337
|
+
document.querySelector(".rw-window-tabs")?.dispatchEvent(new CustomEvent("clearFloatingWindowPreview"));
|
|
338
|
+
}, 0);
|
|
339
|
+
},
|
|
340
|
+
[x, m, u, t]
|
|
341
|
+
), C = R(
|
|
342
|
+
(r, o) => {
|
|
343
|
+
const a = x.find((c) => c.id === r);
|
|
344
|
+
if (!a) return;
|
|
345
|
+
const d = x.map((c) => {
|
|
346
|
+
if (c.id === r) {
|
|
347
|
+
const { pendingDragStart: N, ...Z } = c;
|
|
348
|
+
return { ...Z, floatingPosition: o };
|
|
349
|
+
}
|
|
350
|
+
return c;
|
|
351
|
+
});
|
|
352
|
+
E(d), a.floating && ce(u, t, a.type, {
|
|
353
|
+
position: o,
|
|
354
|
+
floating: !0,
|
|
355
|
+
minimized: a.minimized,
|
|
356
|
+
floatingZIndex: a.floatingZIndex
|
|
357
|
+
});
|
|
358
|
+
},
|
|
359
|
+
[x, t, u]
|
|
360
|
+
), P = R(
|
|
361
|
+
(r) => {
|
|
362
|
+
const o = x.find((d) => d.id === r);
|
|
363
|
+
if (!o?.floating || !t) return;
|
|
364
|
+
ue(u, t, o.type);
|
|
365
|
+
const a = ae(u, t)[o.type];
|
|
366
|
+
a?.floatingZIndex && E(
|
|
367
|
+
(d) => d.map(
|
|
368
|
+
(c) => c.id === r && c.floating ? { ...c, floatingZIndex: a.floatingZIndex } : c
|
|
369
|
+
)
|
|
370
|
+
);
|
|
371
|
+
},
|
|
372
|
+
[x, t, u]
|
|
373
|
+
), F = R(
|
|
374
|
+
(r, o) => {
|
|
375
|
+
E((a) => {
|
|
376
|
+
const d = a.map(
|
|
377
|
+
(c) => c.id === r ? { ...c, props: { ...c.props, ...o } } : c
|
|
378
|
+
);
|
|
379
|
+
return b(d, z), d;
|
|
380
|
+
});
|
|
381
|
+
},
|
|
382
|
+
[z, b]
|
|
383
|
+
), G = R(
|
|
384
|
+
(r, o) => {
|
|
385
|
+
E((a) => {
|
|
386
|
+
const d = a.map((c) => c.id === r ? { ...c, title: o } : c);
|
|
387
|
+
return T(d, z), b(d, z), d;
|
|
388
|
+
});
|
|
389
|
+
},
|
|
390
|
+
[z, T, b]
|
|
391
|
+
), Q = R(
|
|
392
|
+
(r) => {
|
|
393
|
+
E(
|
|
394
|
+
(o) => o.map((a) => {
|
|
395
|
+
if (a.id !== r) return a;
|
|
396
|
+
const { pendingAction: d, ...c } = a;
|
|
397
|
+
return c;
|
|
398
|
+
})
|
|
399
|
+
);
|
|
400
|
+
},
|
|
401
|
+
[]
|
|
402
|
+
), ie = R(
|
|
403
|
+
(r) => {
|
|
404
|
+
if (r === "reset-windows") {
|
|
405
|
+
l();
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (!z && !["close-all", "minimize-all", "restore-all"].includes(r)) return;
|
|
409
|
+
const o = x.filter((N) => !N.floating), a = x.filter((N) => N.floating);
|
|
410
|
+
let d = [], c = z;
|
|
411
|
+
switch (r) {
|
|
412
|
+
case "close-left": {
|
|
413
|
+
const N = o.findIndex((Z) => Z.id === z);
|
|
414
|
+
d = o.slice(N);
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
case "close-right": {
|
|
418
|
+
const N = o.findIndex((Z) => Z.id === z);
|
|
419
|
+
d = o.slice(0, N + 1);
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
case "close-others":
|
|
423
|
+
d = o.filter((N) => N.id === z);
|
|
424
|
+
break;
|
|
425
|
+
case "close-all":
|
|
426
|
+
d = [], c = null;
|
|
427
|
+
break;
|
|
428
|
+
case "minimize-all":
|
|
429
|
+
d = o.map((N) => ({ ...N, minimized: !0 })), c = null;
|
|
430
|
+
break;
|
|
431
|
+
case "restore-all":
|
|
432
|
+
d = o.map((N) => ({ ...N, minimized: !1 })), c = z ?? d[0]?.id ?? null;
|
|
433
|
+
break;
|
|
434
|
+
default:
|
|
435
|
+
d = o;
|
|
436
|
+
}
|
|
437
|
+
m([...d, ...a], c);
|
|
438
|
+
},
|
|
439
|
+
[x, z, m, l]
|
|
440
|
+
), fe = R(
|
|
441
|
+
(r, o) => {
|
|
442
|
+
const a = x.filter((q) => !q.minimized && !q.floating);
|
|
443
|
+
if (r < 0 || r >= a.length || o < 0 || o >= a.length || r === o) return;
|
|
444
|
+
const d = [...a], [c] = d.splice(r, 1);
|
|
445
|
+
d.splice(o, 0, c);
|
|
446
|
+
let N = 0;
|
|
447
|
+
const Z = x.map((q) => q.minimized || q.floating ? q : d[N++]);
|
|
448
|
+
m(Z, z);
|
|
449
|
+
},
|
|
450
|
+
[x, z, m]
|
|
451
|
+
);
|
|
452
|
+
return {
|
|
453
|
+
windows: x,
|
|
454
|
+
activeWindowId: z,
|
|
455
|
+
openWindow: p,
|
|
456
|
+
switchWindow: W,
|
|
457
|
+
closeWindow: S,
|
|
458
|
+
toggleMinimize: I,
|
|
459
|
+
floatWindow: D,
|
|
460
|
+
restoreWindow: k,
|
|
461
|
+
updateFloatingPosition: C,
|
|
462
|
+
focusWindow: P,
|
|
463
|
+
batchManage: ie,
|
|
464
|
+
updateWindowProps: F,
|
|
465
|
+
updateWindowTitle: G,
|
|
466
|
+
clearPendingAction: Q,
|
|
467
|
+
setWindows: E,
|
|
468
|
+
setActiveWindowId: H,
|
|
469
|
+
resetWorkspace: l,
|
|
470
|
+
reorderWindows: fe
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
const me = Te(null), Ae = me.Provider;
|
|
474
|
+
function ht() {
|
|
475
|
+
const e = ve(me);
|
|
476
|
+
if (!e)
|
|
477
|
+
throw new Error("[react-workspace] useWorkspaceContext 必须在 Workspace 或 WorkspaceProvider 内使用");
|
|
478
|
+
return e;
|
|
479
|
+
}
|
|
480
|
+
function pt() {
|
|
481
|
+
return ve(me);
|
|
482
|
+
}
|
|
483
|
+
const oe = (e) => ({ width: e, height: e, viewBox: "0 0 24 24", fill: "currentColor" }), xe = ({ size: e = 14, className: t }) => /* @__PURE__ */ s("svg", { ...oe(e), className: t, children: /* @__PURE__ */ s("path", { d: "M6 6l12 12M18 6L6 18", stroke: "currentColor", strokeWidth: "2", fill: "none" }) }), Xe = ({ size: e = 14, className: t }) => /* @__PURE__ */ s("svg", { ...oe(e), className: t, children: /* @__PURE__ */ s("path", { d: "M5 12h14", stroke: "currentColor", strokeWidth: "2", fill: "none" }) }), Le = ({ size: e = 14, className: t }) => /* @__PURE__ */ s("svg", { ...oe(e), className: t, children: /* @__PURE__ */ s("rect", { x: "5", y: "5", width: "14", height: "14", rx: "1", stroke: "currentColor", strokeWidth: "2", fill: "none" }) }), Fe = ({ size: e = 16, className: t }) => /* @__PURE__ */ _("svg", { ...oe(e), className: t, children: [
|
|
484
|
+
/* @__PURE__ */ s("circle", { cx: "6", cy: "12", r: "1.5" }),
|
|
485
|
+
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "1.5" }),
|
|
486
|
+
/* @__PURE__ */ s("circle", { cx: "18", cy: "12", r: "1.5" })
|
|
487
|
+
] }), Ye = ({ size: e = 12, className: t }) => /* @__PURE__ */ s("svg", { ...oe(e), className: t, children: /* @__PURE__ */ s("path", { d: "M9 6l6 6-6 6", stroke: "currentColor", strokeWidth: "2", fill: "none" }) }), _e = ({ size: e = 12, className: t }) => /* @__PURE__ */ s("svg", { ...oe(e), className: t, children: /* @__PURE__ */ s("path", { d: "M15 6l-6 6 6 6", stroke: "currentColor", strokeWidth: "2", fill: "none" }) }), qe = ({ size: e = 64, className: t }) => /* @__PURE__ */ s("svg", { ...oe(e), className: t, fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ s("path", { d: "M3 7a2 2 0 012-2h5l2 2h9a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V7z" }) }), je = ({ size: e = 12, className: t }) => /* @__PURE__ */ s("svg", { ...oe(e), className: t, children: /* @__PURE__ */ s("path", { d: "M6 9l6 6 6-6", stroke: "currentColor", strokeWidth: "2", fill: "none" }) });
|
|
488
|
+
function Ue(e, t) {
|
|
489
|
+
for (const n of e) {
|
|
490
|
+
if ("type" in n && n.type === "divider") continue;
|
|
491
|
+
const i = n;
|
|
492
|
+
if (i.key === t) return i;
|
|
493
|
+
if (i.children) {
|
|
494
|
+
const f = Ue(i.children, t);
|
|
495
|
+
if (f) return f;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
function be(e, t, n) {
|
|
501
|
+
const i = (f) => {
|
|
502
|
+
for (const h of f) {
|
|
503
|
+
if ("type" in h && h.type === "divider") continue;
|
|
504
|
+
const w = h;
|
|
505
|
+
if (w.windowType === t)
|
|
506
|
+
return typeof w.label == "string" ? w.label : w.key;
|
|
507
|
+
if (w.children) {
|
|
508
|
+
const u = i(w.children);
|
|
509
|
+
if (u) return u;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return null;
|
|
513
|
+
};
|
|
514
|
+
return i(e) ?? n ?? t;
|
|
515
|
+
}
|
|
516
|
+
function We(e, t) {
|
|
517
|
+
for (const n of e) {
|
|
518
|
+
if ("type" in n && n.type === "divider") continue;
|
|
519
|
+
const i = n;
|
|
520
|
+
if (i.windowType === t) return i.key;
|
|
521
|
+
if (i.children) {
|
|
522
|
+
const f = We(i.children, t);
|
|
523
|
+
if (f) return f;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
function Ke(e) {
|
|
529
|
+
const t = [];
|
|
530
|
+
for (const n of e) {
|
|
531
|
+
if ("type" in n && n.type === "divider") continue;
|
|
532
|
+
const i = n;
|
|
533
|
+
i.children?.length && t.push(i.key);
|
|
534
|
+
}
|
|
535
|
+
return t;
|
|
536
|
+
}
|
|
537
|
+
function Se(e) {
|
|
538
|
+
return typeof e == "string" || typeof e == "number" ? String(e) : "";
|
|
539
|
+
}
|
|
540
|
+
function Je(e) {
|
|
541
|
+
return "type" in e && e.type === "divider";
|
|
542
|
+
}
|
|
543
|
+
const Ve = ({
|
|
544
|
+
menuItems: e,
|
|
545
|
+
onMenuClick: t,
|
|
546
|
+
onAction: n,
|
|
547
|
+
activeWindowType: i,
|
|
548
|
+
header: f,
|
|
549
|
+
footer: h,
|
|
550
|
+
defaultOpenKeys: w = [],
|
|
551
|
+
siderWidth: u = 240,
|
|
552
|
+
onCollapsedChange: g
|
|
553
|
+
}) => {
|
|
554
|
+
const [v, j] = te(!1), [M, O] = te(new Set(w)), B = le(() => i ? We(e, i) : null, [i, e]), L = () => {
|
|
555
|
+
j((y) => (g?.(!y), !y));
|
|
556
|
+
}, x = (y, b) => {
|
|
557
|
+
b?.stopPropagation(), O((A) => {
|
|
558
|
+
const X = new Set(A);
|
|
559
|
+
return X.has(y) ? X.delete(y) : X.add(y), X;
|
|
560
|
+
});
|
|
561
|
+
}, E = (y) => {
|
|
562
|
+
if (!y.disabled) {
|
|
563
|
+
if (y.windowType) {
|
|
564
|
+
t(y.windowType, y.props);
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
if (y.action && n) {
|
|
568
|
+
n(y.action);
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
y.children?.length && x(y.key);
|
|
572
|
+
}
|
|
573
|
+
}, z = (y, b = 0) => y.map((A, X) => {
|
|
574
|
+
if (Je(A))
|
|
575
|
+
return /* @__PURE__ */ s("div", { className: "rw-menu-divider" }, A.key ?? `div-${X}`);
|
|
576
|
+
const T = A, m = !!T.children?.length, U = M.has(T.key), K = T.key === B;
|
|
577
|
+
return /* @__PURE__ */ _("div", { className: "rw-menu-group", children: [
|
|
578
|
+
/* @__PURE__ */ _(
|
|
579
|
+
"button",
|
|
580
|
+
{
|
|
581
|
+
type: "button",
|
|
582
|
+
className: `rw-menu-item ${K ? "selected" : ""} ${T.disabled ? "disabled" : ""}`,
|
|
583
|
+
style: { paddingLeft: v ? 12 : 12 + b * 16 },
|
|
584
|
+
onClick: () => E(T),
|
|
585
|
+
disabled: T.disabled,
|
|
586
|
+
title: v ? Se(T.label) : void 0,
|
|
587
|
+
children: [
|
|
588
|
+
T.icon && /* @__PURE__ */ s("span", { className: "rw-menu-icon", children: T.icon }),
|
|
589
|
+
!v && /* @__PURE__ */ s("span", { className: "rw-menu-label", children: T.label }),
|
|
590
|
+
!v && m && /* @__PURE__ */ s(
|
|
591
|
+
"span",
|
|
592
|
+
{
|
|
593
|
+
className: `rw-menu-arrow ${U ? "open" : ""}`,
|
|
594
|
+
onClick: (l) => x(T.key, l),
|
|
595
|
+
role: "presentation",
|
|
596
|
+
children: /* @__PURE__ */ s(je, { size: 10 })
|
|
597
|
+
}
|
|
598
|
+
)
|
|
599
|
+
]
|
|
600
|
+
}
|
|
601
|
+
),
|
|
602
|
+
!v && m && U && /* @__PURE__ */ s("div", { className: "rw-menu-children", children: z(T.children, b + 1) })
|
|
603
|
+
] }, T.key);
|
|
604
|
+
}), H = v ? 64 : u;
|
|
605
|
+
return /* @__PURE__ */ _("div", { className: "rw-workspace-sidebar-wrapper", children: [
|
|
606
|
+
/* @__PURE__ */ _("aside", { className: "rw-workspace-sider", style: { width: H }, children: [
|
|
607
|
+
f && /* @__PURE__ */ s("div", { className: `rw-workspace-sidebar-header ${v ? "collapsed" : ""}`, children: f }),
|
|
608
|
+
/* @__PURE__ */ s("nav", { className: "rw-workspace-sidebar-menu", children: z(e) }),
|
|
609
|
+
h && /* @__PURE__ */ s("div", { className: `rw-workspace-sidebar-footer ${v ? "collapsed" : ""}`, children: h })
|
|
610
|
+
] }),
|
|
611
|
+
/* @__PURE__ */ s(
|
|
612
|
+
"button",
|
|
613
|
+
{
|
|
614
|
+
type: "button",
|
|
615
|
+
className: "rw-workspace-collapse-button",
|
|
616
|
+
style: { left: H },
|
|
617
|
+
onClick: L,
|
|
618
|
+
title: v ? "展开导航" : "折叠导航",
|
|
619
|
+
children: v ? /* @__PURE__ */ s(_e, {}) : /* @__PURE__ */ s(Ye, {})
|
|
620
|
+
}
|
|
621
|
+
)
|
|
622
|
+
] });
|
|
623
|
+
}, Ge = ({
|
|
624
|
+
description: e = "暂无内容",
|
|
625
|
+
icon: t
|
|
626
|
+
}) => /* @__PURE__ */ _("div", { className: "rw-empty", children: [
|
|
627
|
+
/* @__PURE__ */ s("div", { className: "rw-empty-icon", children: t ?? /* @__PURE__ */ s(qe, { size: 64 }) }),
|
|
628
|
+
/* @__PURE__ */ s("div", { className: "rw-empty-desc", children: e })
|
|
629
|
+
] }), Qe = ({ window: e, active: t, children: n }) => /* @__PURE__ */ s(
|
|
630
|
+
"div",
|
|
631
|
+
{
|
|
632
|
+
className: `rw-window-container ${t ? "active" : ""}`,
|
|
633
|
+
style: { display: t ? "flex" : "none", height: "100%", overflow: "auto", flexDirection: "column" },
|
|
634
|
+
"data-window-type": e.type,
|
|
635
|
+
children: n
|
|
636
|
+
}
|
|
637
|
+
), et = ({ items: e, trigger: t, className: n }) => {
|
|
638
|
+
const [i, f] = te(!1), h = Y(null);
|
|
639
|
+
return ne(() => {
|
|
640
|
+
if (!i) return;
|
|
641
|
+
const w = (u) => {
|
|
642
|
+
h.current?.contains(u.target) || f(!1);
|
|
643
|
+
};
|
|
644
|
+
return document.addEventListener("mousedown", w), () => document.removeEventListener("mousedown", w);
|
|
645
|
+
}, [i]), /* @__PURE__ */ _("div", { className: `rw-dropdown ${n || ""}`, ref: h, children: [
|
|
646
|
+
/* @__PURE__ */ s("div", { className: "rw-dropdown-trigger", onClick: () => f((w) => !w), role: "button", tabIndex: 0, children: t }),
|
|
647
|
+
i && /* @__PURE__ */ s("div", { className: "rw-dropdown-menu", children: e.map(
|
|
648
|
+
(w) => w.divider ? /* @__PURE__ */ s("div", { className: "rw-dropdown-divider" }, w.key) : /* @__PURE__ */ s(
|
|
649
|
+
"button",
|
|
650
|
+
{
|
|
651
|
+
type: "button",
|
|
652
|
+
className: "rw-dropdown-item",
|
|
653
|
+
disabled: w.disabled,
|
|
654
|
+
onClick: () => {
|
|
655
|
+
w.onClick?.(), f(!1);
|
|
656
|
+
},
|
|
657
|
+
children: w.label
|
|
658
|
+
},
|
|
659
|
+
w.key
|
|
660
|
+
)
|
|
661
|
+
) })
|
|
662
|
+
] });
|
|
663
|
+
}, tt = ({
|
|
664
|
+
windows: e,
|
|
665
|
+
activeWindowId: t,
|
|
666
|
+
onSwitchWindow: n,
|
|
667
|
+
onCloseWindow: i,
|
|
668
|
+
onToggleMinimize: f,
|
|
669
|
+
onBatchManage: h,
|
|
670
|
+
onFloatWindow: w,
|
|
671
|
+
onRestoreWindow: u,
|
|
672
|
+
onReorderWindows: g,
|
|
673
|
+
embedded: v = !1,
|
|
674
|
+
themeClassName: j,
|
|
675
|
+
allWindows: M = e
|
|
676
|
+
}) => {
|
|
677
|
+
const O = e.findIndex((l) => l.id === t), B = Y(null), L = Y(null), [x, E] = te(null), [z, H] = te(null), y = Y({ windowId: "", startX: 0, startY: 0, fromIndex: -1, mode: "none", floated: !1 }), b = R((l) => {
|
|
678
|
+
const p = L.current;
|
|
679
|
+
if (!p) return e.length;
|
|
680
|
+
const W = p.getBoundingClientRect(), S = l - W.left, I = p.querySelectorAll(".rw-tab-item");
|
|
681
|
+
if (S < 8) return 0;
|
|
682
|
+
for (let D = 0; D < I.length; D++) {
|
|
683
|
+
const k = I[D].getBoundingClientRect(), C = k.left - W.left + k.width / 2;
|
|
684
|
+
if (S < C) return D;
|
|
685
|
+
}
|
|
686
|
+
return I.length;
|
|
687
|
+
}, [e.length]), A = R(
|
|
688
|
+
(l, p, W) => {
|
|
689
|
+
if (l.target.closest(".rw-window-tab-close-btn") || l.button !== 0) return;
|
|
690
|
+
y.current = { windowId: p, startX: l.clientX, startY: l.clientY, fromIndex: W, mode: "none", floated: !1 };
|
|
691
|
+
const S = (k) => {
|
|
692
|
+
const C = k.clientX - y.current.startX, P = k.clientY - y.current.startY, F = Math.sqrt(C * C + P * P);
|
|
693
|
+
F < 8 || (y.current.mode === "none" && (Math.abs(P) > 40 && F > 50 ? y.current.mode = "float" : Math.abs(C) > 12 && Math.abs(C) > Math.abs(P) ? y.current.mode = "reorder" : F > 50 && (y.current.mode = "float")), y.current.mode === "float" && y.current.windowId === p ? y.current.floated || (y.current.floated = !0, w?.(p, { x: k.clientX, y: k.clientY })) : y.current.mode === "reorder" && E(b(k.clientX)));
|
|
694
|
+
}, I = (k) => {
|
|
695
|
+
if (y.current.mode === "reorder" && y.current.windowId === p) {
|
|
696
|
+
let P = b(k.clientX);
|
|
697
|
+
P > y.current.fromIndex && (P -= 1), P !== y.current.fromIndex && g && g(y.current.fromIndex, P);
|
|
698
|
+
}
|
|
699
|
+
E(null), D();
|
|
700
|
+
}, D = () => {
|
|
701
|
+
document.removeEventListener("mousemove", S), document.removeEventListener("mouseup", I), y.current = { windowId: "", startX: 0, startY: 0, fromIndex: -1, mode: "none", floated: !1 };
|
|
702
|
+
};
|
|
703
|
+
document.addEventListener("mousemove", S), document.addEventListener("mouseup", I);
|
|
704
|
+
},
|
|
705
|
+
[w, g, b]
|
|
706
|
+
);
|
|
707
|
+
ne(() => {
|
|
708
|
+
if (!t) return;
|
|
709
|
+
const l = L.current;
|
|
710
|
+
if (!l) return;
|
|
711
|
+
const p = e.findIndex((S) => S.id === t);
|
|
712
|
+
if (p < 0) return;
|
|
713
|
+
l.querySelectorAll(".rw-tab-item")[p]?.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "smooth" });
|
|
714
|
+
}, [t, e.length]), ne(() => {
|
|
715
|
+
let l = null;
|
|
716
|
+
const p = (I) => {
|
|
717
|
+
const { windowTitle: D, clientX: k } = I.detail, C = b(k);
|
|
718
|
+
l && cancelAnimationFrame(l), l = requestAnimationFrame(() => {
|
|
719
|
+
H({ title: D, index: C }), E(C);
|
|
720
|
+
});
|
|
721
|
+
}, W = () => {
|
|
722
|
+
H(null), E(null);
|
|
723
|
+
}, S = B.current;
|
|
724
|
+
return S?.addEventListener("floatingWindowDragOver", p), S?.addEventListener("clearFloatingWindowPreview", W), () => {
|
|
725
|
+
S?.removeEventListener("floatingWindowDragOver", p), S?.removeEventListener("clearFloatingWindowPreview", W), l && cancelAnimationFrame(l);
|
|
726
|
+
};
|
|
727
|
+
}, [b]);
|
|
728
|
+
const X = () => {
|
|
729
|
+
const l = e.map((p, W) => /* @__PURE__ */ _(
|
|
730
|
+
"div",
|
|
731
|
+
{
|
|
732
|
+
className: `rw-tab-item ${p.id === t ? "active" : ""}`,
|
|
733
|
+
onClick: () => n(p.id),
|
|
734
|
+
onMouseDown: (S) => A(S, p.id, W),
|
|
735
|
+
children: [
|
|
736
|
+
/* @__PURE__ */ s("span", { className: "rw-tab-title", children: p.title }),
|
|
737
|
+
/* @__PURE__ */ s(
|
|
738
|
+
"button",
|
|
739
|
+
{
|
|
740
|
+
type: "button",
|
|
741
|
+
title: "关闭",
|
|
742
|
+
className: "rw-icon-btn rw-window-tab-close-btn",
|
|
743
|
+
onClick: (S) => {
|
|
744
|
+
S.stopPropagation(), i(p.id);
|
|
745
|
+
},
|
|
746
|
+
children: /* @__PURE__ */ s(xe, { size: 12 })
|
|
747
|
+
}
|
|
748
|
+
)
|
|
749
|
+
]
|
|
750
|
+
},
|
|
751
|
+
p.id
|
|
752
|
+
));
|
|
753
|
+
if (z && x !== null) {
|
|
754
|
+
const p = Math.max(0, Math.min(x, l.length));
|
|
755
|
+
l.splice(p, 0, /* @__PURE__ */ s("div", { className: "rw-tab-preview", children: z.title }, "rw-preview"));
|
|
756
|
+
}
|
|
757
|
+
return l;
|
|
758
|
+
}, T = (l) => {
|
|
759
|
+
l.preventDefault();
|
|
760
|
+
try {
|
|
761
|
+
const p = sessionStorage.getItem("draggingWindowTitle");
|
|
762
|
+
p && H({ title: p, index: b(l.clientX) });
|
|
763
|
+
} catch {
|
|
764
|
+
}
|
|
765
|
+
E(b(l.clientX));
|
|
766
|
+
}, m = (l) => {
|
|
767
|
+
l.preventDefault();
|
|
768
|
+
let p = l.dataTransfer.getData("windowId") || "";
|
|
769
|
+
if (!p)
|
|
770
|
+
try {
|
|
771
|
+
p = sessionStorage.getItem("draggingWindowId") || "";
|
|
772
|
+
} catch {
|
|
773
|
+
}
|
|
774
|
+
p && u && u(p, x ?? void 0), H(null), E(null);
|
|
775
|
+
}, K = [
|
|
776
|
+
...M.length === 0 ? [] : [
|
|
777
|
+
...M.map((l) => ({
|
|
778
|
+
key: `win-${l.id}`,
|
|
779
|
+
label: /* @__PURE__ */ _("span", { className: "rw-dropdown-window", children: [
|
|
780
|
+
/* @__PURE__ */ s("span", { className: `rw-dropdown-dot ${l.id === t ? "active" : ""}` }),
|
|
781
|
+
/* @__PURE__ */ s("span", { className: "rw-dropdown-window-title", children: l.title }),
|
|
782
|
+
l.minimized && /* @__PURE__ */ s("span", { className: "rw-dropdown-tag", children: "已最小化" }),
|
|
783
|
+
l.floating && !l.minimized && /* @__PURE__ */ s("span", { className: "rw-dropdown-tag", children: "浮动" })
|
|
784
|
+
] }),
|
|
785
|
+
onClick: () => {
|
|
786
|
+
l.minimized && u?.(l.id), n(l.id);
|
|
787
|
+
}
|
|
788
|
+
})),
|
|
789
|
+
{ key: "d0", label: "", divider: !0 }
|
|
790
|
+
],
|
|
791
|
+
{ key: "close-others", label: "关闭其他", disabled: e.length <= 1, onClick: () => h("close-others") },
|
|
792
|
+
{ key: "close-left", label: "关闭左侧", disabled: O <= 0, onClick: () => h("close-left") },
|
|
793
|
+
{ key: "close-right", label: "关闭右侧", disabled: O < 0 || O >= e.length - 1, onClick: () => h("close-right") },
|
|
794
|
+
{ key: "d1", label: "", divider: !0 },
|
|
795
|
+
{ key: "close-all", label: "关闭全部", disabled: !e.length, onClick: () => h("close-all") },
|
|
796
|
+
{ key: "d2", label: "", divider: !0 },
|
|
797
|
+
{ key: "minimize-all", label: "最小化全部", disabled: !e.length, onClick: () => h("minimize-all") },
|
|
798
|
+
{ key: "restore-all", label: "还原全部", disabled: !M.some((l) => l.minimized), onClick: () => h("restore-all") },
|
|
799
|
+
{ key: "d3", label: "", divider: !0 },
|
|
800
|
+
{ key: "reset", label: "重置窗口", onClick: () => h("reset-windows") }
|
|
801
|
+
];
|
|
802
|
+
return /* @__PURE__ */ s(
|
|
803
|
+
"div",
|
|
804
|
+
{
|
|
805
|
+
className: `rw-window-tabs ${v ? "rw-tabs-embedded" : ""} ${j || ""}`,
|
|
806
|
+
ref: B,
|
|
807
|
+
onDragOver: T,
|
|
808
|
+
onDragLeave: () => {
|
|
809
|
+
H(null), E(null);
|
|
810
|
+
},
|
|
811
|
+
onDrop: m,
|
|
812
|
+
children: /* @__PURE__ */ _("div", { className: "rw-window-tabs-container", children: [
|
|
813
|
+
/* @__PURE__ */ s("div", { className: "rw-tab-list", ref: L, children: X() }),
|
|
814
|
+
x !== null && !z && /* @__PURE__ */ s(nt, { listRef: L, index: x }),
|
|
815
|
+
e.length > 0 && /* @__PURE__ */ s(
|
|
816
|
+
et,
|
|
817
|
+
{
|
|
818
|
+
items: K,
|
|
819
|
+
trigger: /* @__PURE__ */ s("button", { type: "button", className: "rw-icon-btn rw-window-tabs-batch-btn", title: "批量管理", children: /* @__PURE__ */ s(Fe, {}) })
|
|
820
|
+
}
|
|
821
|
+
)
|
|
822
|
+
] })
|
|
823
|
+
}
|
|
824
|
+
);
|
|
825
|
+
}, nt = ({ listRef: e, index: t }) => {
|
|
826
|
+
const [n, i] = te(0);
|
|
827
|
+
return ne(() => {
|
|
828
|
+
const f = () => {
|
|
829
|
+
const h = e.current;
|
|
830
|
+
if (!h) return;
|
|
831
|
+
h.getBoundingClientRect();
|
|
832
|
+
const w = h.querySelectorAll(".rw-tab-item:not(.rw-tab-preview)");
|
|
833
|
+
if (t === 0) {
|
|
834
|
+
i(8);
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
if (t >= w.length) {
|
|
838
|
+
const g = w[w.length - 1];
|
|
839
|
+
i(g.offsetLeft + g.offsetWidth + 2);
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
const u = w[t];
|
|
843
|
+
i(u.offsetLeft - 1);
|
|
844
|
+
};
|
|
845
|
+
return f(), window.addEventListener("resize", f), () => window.removeEventListener("resize", f);
|
|
846
|
+
}, [e, t]), /* @__PURE__ */ s("div", { className: "rw-window-tab-insert-indicator", style: { left: `${n}px` } });
|
|
847
|
+
}, it = {
|
|
848
|
+
x: 100,
|
|
849
|
+
y: 100,
|
|
850
|
+
width: 800,
|
|
851
|
+
height: 600,
|
|
852
|
+
minWidth: 400,
|
|
853
|
+
minHeight: 300
|
|
854
|
+
}, rt = ({
|
|
855
|
+
window: e,
|
|
856
|
+
children: t,
|
|
857
|
+
floatingDefaults: n,
|
|
858
|
+
onUpdateFloatingPosition: i,
|
|
859
|
+
onRestoreWindow: f,
|
|
860
|
+
onCloseWindow: h,
|
|
861
|
+
onToggleMinimize: w,
|
|
862
|
+
onFocusWindow: u
|
|
863
|
+
}) => {
|
|
864
|
+
const g = { ...it, ...n }, v = Y(null), j = Y(null), [M, O] = te(!1), [B, L] = te(!1), [x, E] = te(!1), z = Y(!1), H = Y(""), y = Y({ x: 0, y: 0, startX: 0, startY: 0, startWidth: 0, startHeight: 0 }), b = Y({ x: 0, y: 0, width: 0, height: 0, startX: 0, startY: 0 }), A = Y(null), X = Y(null), T = Y(null), m = e.floatingPosition || { x: g.x, y: g.y, width: g.width, height: g.height };
|
|
865
|
+
ne(() => {
|
|
866
|
+
if (!e.pendingDragStart || M || B) return;
|
|
867
|
+
let l = m.x, p = m.y;
|
|
868
|
+
if (v.current) {
|
|
869
|
+
const W = v.current.getBoundingClientRect();
|
|
870
|
+
l = W.left, p = W.top;
|
|
871
|
+
}
|
|
872
|
+
u?.(e.id), T.current = { windowId: e.id, windowTitle: e.title };
|
|
873
|
+
try {
|
|
874
|
+
sessionStorage.setItem("draggingWindowId", e.id), sessionStorage.setItem("draggingWindowTitle", e.title);
|
|
875
|
+
} catch {
|
|
876
|
+
}
|
|
877
|
+
O(!0), y.current = {
|
|
878
|
+
x: e.pendingDragStart.x - l,
|
|
879
|
+
y: e.pendingDragStart.y - p,
|
|
880
|
+
startX: l,
|
|
881
|
+
startY: p,
|
|
882
|
+
startWidth: m.width,
|
|
883
|
+
startHeight: m.height
|
|
884
|
+
};
|
|
885
|
+
}, [e.pendingDragStart, e.id, e.title, M, B, m, u]), ne(() => {
|
|
886
|
+
if (M || B || e.pendingDragStart) return;
|
|
887
|
+
const l = { minWidth: g.minWidth, minHeight: g.minHeight }, p = re(m, l);
|
|
888
|
+
(p.x !== m.x || p.y !== m.y || p.width !== m.width || p.height !== m.height) && i(e.id, p);
|
|
889
|
+
}, [e.id, e.pendingDragStart]), ne(() => {
|
|
890
|
+
if (!v.current || M || B) return;
|
|
891
|
+
const l = v.current;
|
|
892
|
+
l.style.transform = `translate(${m.x}px, ${m.y}px)`, l.style.width = `${m.width}px`, l.style.height = `${m.height}px`;
|
|
893
|
+
}, [m.x, m.y, m.width, m.height, M, B]);
|
|
894
|
+
const U = R((l) => {
|
|
895
|
+
const p = l.target;
|
|
896
|
+
if (p.closest(".rw-floating-window-action-btn") || p.closest(".rw-floating-window-resize-handle") || !j.current?.contains(p)) return;
|
|
897
|
+
u?.(e.id);
|
|
898
|
+
let W = m.x, S = m.y;
|
|
899
|
+
if (v.current) {
|
|
900
|
+
const I = v.current.getBoundingClientRect();
|
|
901
|
+
W = I.left, S = I.top;
|
|
902
|
+
}
|
|
903
|
+
T.current = { windowId: e.id, windowTitle: e.title };
|
|
904
|
+
try {
|
|
905
|
+
sessionStorage.setItem("draggingWindowId", e.id), sessionStorage.setItem("draggingWindowTitle", e.title);
|
|
906
|
+
} catch {
|
|
907
|
+
}
|
|
908
|
+
O(!0), y.current = { x: l.clientX - W, y: l.clientY - S, startX: W, startY: S, startWidth: m.width, startHeight: m.height };
|
|
909
|
+
}, [m, e.id, e.title, u]), K = R((l, p) => {
|
|
910
|
+
l.stopPropagation(), l.preventDefault(), u?.(e.id);
|
|
911
|
+
let W = m.x, S = m.y, I = m.width, D = m.height;
|
|
912
|
+
if (v.current) {
|
|
913
|
+
const k = v.current.getBoundingClientRect();
|
|
914
|
+
W = k.left, S = k.top, I = k.width, D = k.height;
|
|
915
|
+
}
|
|
916
|
+
L(!0), H.current = p, b.current = { x: l.clientX, y: l.clientY, width: I, height: D, startX: W, startY: S };
|
|
917
|
+
}, [m, e.id, u]);
|
|
918
|
+
return ne(() => {
|
|
919
|
+
const l = (W) => {
|
|
920
|
+
if (M) {
|
|
921
|
+
W.preventDefault();
|
|
922
|
+
const S = document.querySelector(".rw-window-tabs");
|
|
923
|
+
if (S && T.current) {
|
|
924
|
+
const P = S.getBoundingClientRect(), F = W.clientY >= P.top && W.clientY <= P.bottom && W.clientX >= P.left && W.clientX <= P.right, G = z.current;
|
|
925
|
+
E(F), z.current = F, F ? S.dispatchEvent(new CustomEvent("floatingWindowDragOver", { detail: { ...T.current, clientX: W.clientX, clientY: W.clientY } })) : G && S.dispatchEvent(new CustomEvent("clearFloatingWindowPreview"));
|
|
926
|
+
}
|
|
927
|
+
const I = y.current.startWidth, D = y.current.startHeight, k = Math.max(0, Math.min(W.clientX - y.current.x, globalThis.window.innerWidth - I)), C = Math.max(0, Math.min(W.clientY - y.current.y, globalThis.window.innerHeight - D));
|
|
928
|
+
v.current.style.transform = `translate(${k}px, ${C}px)`, X.current = { x: k, y: C, width: y.current.startWidth, height: y.current.startHeight };
|
|
929
|
+
} else if (B) {
|
|
930
|
+
W.preventDefault();
|
|
931
|
+
const S = H.current, I = b.current;
|
|
932
|
+
let D = I.startX, k = I.startY, C = I.width, P = I.height;
|
|
933
|
+
const F = W.clientX - I.x, G = W.clientY - I.y;
|
|
934
|
+
S.includes("e") && (C = Math.max(g.minWidth, I.width + F)), S.includes("w") && (C = Math.max(g.minWidth, I.width - F), D = I.startX + I.width - C), S.includes("s") && (P = Math.max(g.minHeight, I.height + G)), S.includes("n") && (P = Math.max(g.minHeight, I.height - G), k = I.startY + I.height - P);
|
|
935
|
+
const Q = v.current;
|
|
936
|
+
Q.style.transform = `translate(${D}px, ${k}px)`, Q.style.width = `${C}px`, Q.style.height = `${P}px`, X.current = { x: D, y: k, width: C, height: P };
|
|
937
|
+
}
|
|
938
|
+
}, p = (W) => {
|
|
939
|
+
if (W && T.current) {
|
|
940
|
+
const I = document.querySelector(".rw-window-tabs");
|
|
941
|
+
if (I) {
|
|
942
|
+
const D = I.getBoundingClientRect();
|
|
943
|
+
if (W.clientY >= D.top && W.clientY <= D.bottom && W.clientX >= D.left && W.clientX <= D.right) {
|
|
944
|
+
const k = I.querySelector(".rw-tab-list");
|
|
945
|
+
if (k) {
|
|
946
|
+
let C = k.querySelectorAll(".rw-tab-item").length;
|
|
947
|
+
const P = k.getBoundingClientRect(), F = W.clientX - P.left;
|
|
948
|
+
k.querySelectorAll(".rw-tab-item").forEach((G, Q) => {
|
|
949
|
+
const ie = G.getBoundingClientRect();
|
|
950
|
+
F < ie.left - P.left + ie.width / 2 && (C = Math.min(C, Q));
|
|
951
|
+
}), f(T.current.windowId, C), T.current = null, O(!1), L(!1), E(!1);
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
let S = X.current;
|
|
958
|
+
S && (S = re(S, { minWidth: g.minWidth, minHeight: g.minHeight })), S && i(e.id, S), X.current = null, T.current = null;
|
|
959
|
+
try {
|
|
960
|
+
sessionStorage.removeItem("draggingWindowId"), sessionStorage.removeItem("draggingWindowTitle");
|
|
961
|
+
} catch {
|
|
962
|
+
}
|
|
963
|
+
O(!1), L(!1), E(!1), z.current = !1;
|
|
964
|
+
};
|
|
965
|
+
if (M || B) {
|
|
966
|
+
const W = (S) => {
|
|
967
|
+
A.current && cancelAnimationFrame(A.current), A.current = requestAnimationFrame(() => l(S));
|
|
968
|
+
};
|
|
969
|
+
return document.addEventListener("mousemove", W, { passive: !1 }), document.addEventListener("mouseup", p), document.body.style.userSelect = "none", () => {
|
|
970
|
+
document.removeEventListener("mousemove", W), document.removeEventListener("mouseup", p), document.body.style.userSelect = "";
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
}, [M, B, e.id, g.minWidth, g.minHeight, i, f]), /* @__PURE__ */ _(
|
|
974
|
+
"div",
|
|
975
|
+
{
|
|
976
|
+
ref: v,
|
|
977
|
+
className: "rw-floating-window",
|
|
978
|
+
style: {
|
|
979
|
+
transform: `translate(${m.x}px, ${m.y}px)`,
|
|
980
|
+
width: m.width,
|
|
981
|
+
height: m.height,
|
|
982
|
+
zIndex: e.floatingZIndex || 1e3,
|
|
983
|
+
opacity: x ? 0.5 : 1,
|
|
984
|
+
minWidth: g.minWidth,
|
|
985
|
+
minHeight: g.minHeight
|
|
986
|
+
},
|
|
987
|
+
onClick: (l) => {
|
|
988
|
+
l.target.closest("button, a, input, select, textarea") || u?.(e.id);
|
|
989
|
+
},
|
|
990
|
+
children: [
|
|
991
|
+
/* @__PURE__ */ _("div", { ref: j, className: "rw-floating-window-header", onMouseDown: U, onDoubleClick: () => f(e.id), children: [
|
|
992
|
+
/* @__PURE__ */ s("div", { className: "rw-floating-window-title", children: e.title }),
|
|
993
|
+
/* @__PURE__ */ _("div", { className: "rw-floating-window-actions", children: [
|
|
994
|
+
/* @__PURE__ */ s("button", { type: "button", title: "放回", className: "rw-icon-btn rw-floating-window-action-btn", onClick: () => f(e.id), children: /* @__PURE__ */ s(Le, { size: 12 }) }),
|
|
995
|
+
/* @__PURE__ */ s("button", { type: "button", title: "最小化", className: "rw-icon-btn rw-floating-window-action-btn", onClick: () => w(e.id), children: /* @__PURE__ */ s(Xe, { size: 12 }) }),
|
|
996
|
+
/* @__PURE__ */ s("button", { type: "button", title: "关闭", className: "rw-icon-btn rw-floating-window-action-btn", onClick: () => h(e.id), children: /* @__PURE__ */ s(xe, { size: 12 }) })
|
|
997
|
+
] })
|
|
998
|
+
] }),
|
|
999
|
+
/* @__PURE__ */ s("div", { className: "rw-floating-window-content", children: t }),
|
|
1000
|
+
["nw", "ne", "sw", "se", "n", "s", "w", "e"].map((l) => /* @__PURE__ */ s("div", { className: `rw-floating-window-resize-handle rw-floating-window-resize-${l}`, onMouseDown: (p) => K(p, l) }, l))
|
|
1001
|
+
]
|
|
1002
|
+
}
|
|
1003
|
+
);
|
|
1004
|
+
}, ot = ({
|
|
1005
|
+
windows: e,
|
|
1006
|
+
activeWindowId: t,
|
|
1007
|
+
renderWindow: n,
|
|
1008
|
+
onSwitchWindow: i,
|
|
1009
|
+
onCloseWindow: f,
|
|
1010
|
+
onToggleMinimize: h,
|
|
1011
|
+
onBatchManage: w,
|
|
1012
|
+
onFloatWindow: u,
|
|
1013
|
+
onRestoreWindow: g,
|
|
1014
|
+
onUpdateFloatingPosition: v,
|
|
1015
|
+
onFocusWindow: j,
|
|
1016
|
+
onReorderWindows: M,
|
|
1017
|
+
emptyDescription: O = "从左侧菜单选择功能开始工作",
|
|
1018
|
+
floatingDefaults: B,
|
|
1019
|
+
tabsContainer: L,
|
|
1020
|
+
themeClassName: x
|
|
1021
|
+
}) => {
|
|
1022
|
+
if (e.length === 0)
|
|
1023
|
+
return /* @__PURE__ */ s("div", { className: "rw-window-manager-empty", children: /* @__PURE__ */ s(Ge, { description: O }) });
|
|
1024
|
+
const E = e.filter((b) => b.minimized), z = e.filter((b) => b.floating && !b.minimized), H = e.filter((b) => !b.minimized && !b.floating), y = /* @__PURE__ */ s(
|
|
1025
|
+
tt,
|
|
1026
|
+
{
|
|
1027
|
+
windows: H,
|
|
1028
|
+
activeWindowId: t,
|
|
1029
|
+
onSwitchWindow: i,
|
|
1030
|
+
onCloseWindow: f,
|
|
1031
|
+
onToggleMinimize: h,
|
|
1032
|
+
onBatchManage: w,
|
|
1033
|
+
onFloatWindow: u,
|
|
1034
|
+
onRestoreWindow: g,
|
|
1035
|
+
onReorderWindows: M,
|
|
1036
|
+
allWindows: e,
|
|
1037
|
+
embedded: !!L,
|
|
1038
|
+
themeClassName: x
|
|
1039
|
+
}
|
|
1040
|
+
);
|
|
1041
|
+
return /* @__PURE__ */ _("div", { className: "rw-window-manager", children: [
|
|
1042
|
+
L ? Re(y, L) : y,
|
|
1043
|
+
/* @__PURE__ */ s("div", { className: "rw-window-content-area", children: H.map((b) => /* @__PURE__ */ s(Qe, { window: b, active: b.id === t, children: n(b, {}) }, b.id)) }),
|
|
1044
|
+
E.length > 0 && /* @__PURE__ */ s("div", { className: "rw-minimized-windows-bar", children: E.map((b) => /* @__PURE__ */ _(
|
|
1045
|
+
"div",
|
|
1046
|
+
{
|
|
1047
|
+
className: "rw-minimized-window-item",
|
|
1048
|
+
onClick: () => h(b.id),
|
|
1049
|
+
title: b.floating ? `${b.title} (浮动窗口)` : b.title,
|
|
1050
|
+
role: "button",
|
|
1051
|
+
tabIndex: 0,
|
|
1052
|
+
onKeyDown: (A) => A.key === "Enter" && h(b.id),
|
|
1053
|
+
children: [
|
|
1054
|
+
/* @__PURE__ */ s("span", { children: b.title }),
|
|
1055
|
+
b.floating && /* @__PURE__ */ s("span", { className: "rw-minimized-floating-badge", children: "🔲" })
|
|
1056
|
+
]
|
|
1057
|
+
},
|
|
1058
|
+
b.id
|
|
1059
|
+
)) }),
|
|
1060
|
+
z.map((b) => /* @__PURE__ */ s(
|
|
1061
|
+
rt,
|
|
1062
|
+
{
|
|
1063
|
+
window: b,
|
|
1064
|
+
floatingDefaults: B,
|
|
1065
|
+
onUpdateFloatingPosition: v || (() => {
|
|
1066
|
+
}),
|
|
1067
|
+
onRestoreWindow: g || (() => {
|
|
1068
|
+
}),
|
|
1069
|
+
onCloseWindow: f,
|
|
1070
|
+
onToggleMinimize: h,
|
|
1071
|
+
onFocusWindow: j,
|
|
1072
|
+
children: n(b, {})
|
|
1073
|
+
},
|
|
1074
|
+
b.id
|
|
1075
|
+
))
|
|
1076
|
+
] });
|
|
1077
|
+
};
|
|
1078
|
+
function st(e) {
|
|
1079
|
+
return "type" in e && e.type === "divider";
|
|
1080
|
+
}
|
|
1081
|
+
function ke(e) {
|
|
1082
|
+
for (const t of e) {
|
|
1083
|
+
if (st(t)) continue;
|
|
1084
|
+
const n = t;
|
|
1085
|
+
if (n.windowType) return n;
|
|
1086
|
+
if (n.children) {
|
|
1087
|
+
const i = ke(n.children);
|
|
1088
|
+
if (i) return i;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
return null;
|
|
1092
|
+
}
|
|
1093
|
+
function lt(e, t) {
|
|
1094
|
+
if (t) return { minimized: !1, ...t };
|
|
1095
|
+
const n = ke(e);
|
|
1096
|
+
if (!n?.windowType)
|
|
1097
|
+
return { type: "home", title: "首页", minimized: !1 };
|
|
1098
|
+
const i = Se(n.label) || n.key;
|
|
1099
|
+
return { type: n.windowType, title: i, minimized: !1 };
|
|
1100
|
+
}
|
|
1101
|
+
function at(e, t) {
|
|
1102
|
+
const { fallback: n } = t ?? {};
|
|
1103
|
+
return (i, f) => {
|
|
1104
|
+
const h = e[i.type] ?? n;
|
|
1105
|
+
return h ? Pe(h, { window: i, ctx: f }) : null;
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
const ct = {
|
|
1109
|
+
colorPrimary: "--rw-color-primary",
|
|
1110
|
+
colorPrimaryHover: "--rw-color-primary-hover",
|
|
1111
|
+
colorPrimaryBg: "--rw-color-primary-bg",
|
|
1112
|
+
colorBg: "--rw-color-bg",
|
|
1113
|
+
colorBgSecondary: "--rw-color-bg-secondary",
|
|
1114
|
+
colorBgTertiary: "--rw-color-bg-tertiary",
|
|
1115
|
+
colorBgHover: "--rw-color-bg-hover",
|
|
1116
|
+
colorBgActive: "--rw-color-bg-active",
|
|
1117
|
+
colorBorder: "--rw-color-border",
|
|
1118
|
+
colorBorderStrong: "--rw-color-border-strong",
|
|
1119
|
+
colorText: "--rw-color-text",
|
|
1120
|
+
colorTextSecondary: "--rw-color-text-secondary",
|
|
1121
|
+
colorTextMuted: "--rw-color-text-muted",
|
|
1122
|
+
sidebarWidth: "--rw-sidebar-width",
|
|
1123
|
+
tabHeight: "--rw-tab-height",
|
|
1124
|
+
radius: "--rw-radius",
|
|
1125
|
+
fontSize: "--rw-font-size"
|
|
1126
|
+
};
|
|
1127
|
+
function ze(e) {
|
|
1128
|
+
const t = {};
|
|
1129
|
+
return Object.keys(e).forEach((n) => {
|
|
1130
|
+
const i = e[n];
|
|
1131
|
+
if (i !== void 0) {
|
|
1132
|
+
const f = ct[n];
|
|
1133
|
+
t[f] = typeof i == "number" ? `${i}px` : i;
|
|
1134
|
+
}
|
|
1135
|
+
}), t;
|
|
1136
|
+
}
|
|
1137
|
+
function dt(e) {
|
|
1138
|
+
return {
|
|
1139
|
+
colorPrimary: e.colorPrimary,
|
|
1140
|
+
colorPrimaryHover: e.colorPrimaryHover,
|
|
1141
|
+
colorPrimaryBg: e.colorPrimaryBg,
|
|
1142
|
+
colorBg: e.colorBgContainer,
|
|
1143
|
+
colorBgSecondary: e.colorFillAlter ?? e.colorBgContainer,
|
|
1144
|
+
colorBgTertiary: e.colorBgLayout,
|
|
1145
|
+
colorBgHover: e.colorBgTextHover,
|
|
1146
|
+
colorBgActive: e.colorPrimaryBg,
|
|
1147
|
+
colorBorder: e.colorBorder,
|
|
1148
|
+
colorBorderStrong: e.colorBorderSecondary ?? e.colorBorder,
|
|
1149
|
+
colorText: e.colorText,
|
|
1150
|
+
colorTextSecondary: e.colorTextSecondary,
|
|
1151
|
+
colorTextMuted: e.colorTextTertiary,
|
|
1152
|
+
radius: e.borderRadius,
|
|
1153
|
+
fontSize: e.fontSize
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
function wt(e) {
|
|
1157
|
+
return ze(dt(e));
|
|
1158
|
+
}
|
|
1159
|
+
const yt = De(function({
|
|
1160
|
+
workspaceId: t = "default",
|
|
1161
|
+
menuItems: n,
|
|
1162
|
+
renderWindow: i,
|
|
1163
|
+
windows: f,
|
|
1164
|
+
sidebarHeader: h,
|
|
1165
|
+
sidebarFooter: w,
|
|
1166
|
+
defaultWindow: u,
|
|
1167
|
+
loading: g = !1,
|
|
1168
|
+
loadingTip: v = "加载中...",
|
|
1169
|
+
onAction: j,
|
|
1170
|
+
activeWindowType: M,
|
|
1171
|
+
emptyDescription: O,
|
|
1172
|
+
syncToUrl: B = !1,
|
|
1173
|
+
preserveUrlParams: L = !0,
|
|
1174
|
+
searchParams: x,
|
|
1175
|
+
setSearchParams: E,
|
|
1176
|
+
floatingDefaults: z,
|
|
1177
|
+
onWindowsChange: H,
|
|
1178
|
+
resolveTitle: y,
|
|
1179
|
+
onReady: b,
|
|
1180
|
+
siderWidth: A = 240,
|
|
1181
|
+
contentBackground: X,
|
|
1182
|
+
themeClassName: T,
|
|
1183
|
+
theme: m,
|
|
1184
|
+
renderSidebar: U,
|
|
1185
|
+
tabsContainer: K,
|
|
1186
|
+
className: l,
|
|
1187
|
+
style: p
|
|
1188
|
+
}, W) {
|
|
1189
|
+
const S = le(
|
|
1190
|
+
() => lt(n, u),
|
|
1191
|
+
[n, u]
|
|
1192
|
+
), I = le(() => {
|
|
1193
|
+
if (i) return i;
|
|
1194
|
+
if (f) return at(f);
|
|
1195
|
+
throw new Error("[react-workspace] 请提供 renderWindow 或 windows");
|
|
1196
|
+
}, [i, f]), D = He({
|
|
1197
|
+
workspaceId: t,
|
|
1198
|
+
defaultWindow: S,
|
|
1199
|
+
syncToUrl: B,
|
|
1200
|
+
preserveUrlParams: L,
|
|
1201
|
+
searchParams: x,
|
|
1202
|
+
setSearchParams: E,
|
|
1203
|
+
floatingDefaults: z,
|
|
1204
|
+
onWindowsChange: H,
|
|
1205
|
+
// 恢复窗口标题:使用者给的优先(详情类窗口要按参数拼),
|
|
1206
|
+
// 其次按类型去菜单里查,都查不到就退回类型本身。
|
|
1207
|
+
resolveTitle: (V, se) => y?.(V, se) ?? be(n, V)
|
|
1208
|
+
}), {
|
|
1209
|
+
windows: k,
|
|
1210
|
+
activeWindowId: C,
|
|
1211
|
+
openWindow: P,
|
|
1212
|
+
switchWindow: F,
|
|
1213
|
+
closeWindow: G,
|
|
1214
|
+
toggleMinimize: Q,
|
|
1215
|
+
floatWindow: ie,
|
|
1216
|
+
restoreWindow: fe,
|
|
1217
|
+
updateFloatingPosition: r,
|
|
1218
|
+
focusWindow: o,
|
|
1219
|
+
batchManage: a,
|
|
1220
|
+
updateWindowProps: d,
|
|
1221
|
+
clearPendingAction: c,
|
|
1222
|
+
reorderWindows: N
|
|
1223
|
+
} = D, Z = { workspaceId: t, ...D };
|
|
1224
|
+
Ee(W, () => Z, [t, k, C]), ne(() => {
|
|
1225
|
+
b && k.length > 0 && b({ workspaceId: t, ...D });
|
|
1226
|
+
}, [b, t, k.length]);
|
|
1227
|
+
const q = le(() => M !== void 0 ? M : k.find((V) => V.id === C)?.type, [M, k, C]), J = R(
|
|
1228
|
+
(V, se) => {
|
|
1229
|
+
P({ type: V, title: be(n, V), minimized: !1 }, se);
|
|
1230
|
+
},
|
|
1231
|
+
[P, n]
|
|
1232
|
+
), $ = R(
|
|
1233
|
+
(V, se) => ({
|
|
1234
|
+
workspaceId: t,
|
|
1235
|
+
active: se,
|
|
1236
|
+
activeWindowId: C,
|
|
1237
|
+
windows: k,
|
|
1238
|
+
openWindow: P,
|
|
1239
|
+
switchWindow: F,
|
|
1240
|
+
closeWindow: G,
|
|
1241
|
+
toggleMinimize: Q,
|
|
1242
|
+
floatWindow: ie,
|
|
1243
|
+
updateWindowProps: (Ce, Me) => d(Ce, Me),
|
|
1244
|
+
clearPendingAction: c
|
|
1245
|
+
}),
|
|
1246
|
+
[t, C, k, P, F, G, Q, ie, d, c]
|
|
1247
|
+
), ee = le(
|
|
1248
|
+
() => ({ ...Z, buildRenderContext: $ }),
|
|
1249
|
+
[t, k, C, $]
|
|
1250
|
+
), Ie = X ?? "var(--rw-color-bg-tertiary)", Ne = { minHeight: "100vh", height: "100vh", display: "flex", ...m ? ze(m) : void 0, ...p }, he = {
|
|
1251
|
+
menuItems: n,
|
|
1252
|
+
onMenuClick: J,
|
|
1253
|
+
onAction: j,
|
|
1254
|
+
activeWindowType: q,
|
|
1255
|
+
header: h,
|
|
1256
|
+
footer: w,
|
|
1257
|
+
defaultOpenKeys: Ke(n),
|
|
1258
|
+
siderWidth: A
|
|
1259
|
+
};
|
|
1260
|
+
return /* @__PURE__ */ s(Ae, { value: ee, children: /* @__PURE__ */ _(
|
|
1261
|
+
"div",
|
|
1262
|
+
{
|
|
1263
|
+
className: `rw-workspace ${T || ""} ${l || ""}`.trim(),
|
|
1264
|
+
style: Ne,
|
|
1265
|
+
children: [
|
|
1266
|
+
U ? U(he) : /* @__PURE__ */ s(Ve, { ...he }),
|
|
1267
|
+
/* @__PURE__ */ s("main", { className: "rw-workspace-main", style: { background: Ie }, children: /* @__PURE__ */ s($e, { spinning: g, tip: v, children: /* @__PURE__ */ s(
|
|
1268
|
+
ot,
|
|
1269
|
+
{
|
|
1270
|
+
workspaceId: t,
|
|
1271
|
+
windows: k,
|
|
1272
|
+
activeWindowId: C,
|
|
1273
|
+
renderWindow: (V) => I(V, $(V, V.id === C && !V.floating)),
|
|
1274
|
+
onSwitchWindow: F,
|
|
1275
|
+
onCloseWindow: G,
|
|
1276
|
+
onToggleMinimize: Q,
|
|
1277
|
+
onBatchManage: a,
|
|
1278
|
+
onOpenWindow: P,
|
|
1279
|
+
onFloatWindow: ie,
|
|
1280
|
+
onRestoreWindow: fe,
|
|
1281
|
+
onUpdateFloatingPosition: r,
|
|
1282
|
+
onFocusWindow: o,
|
|
1283
|
+
onReorderWindows: N,
|
|
1284
|
+
emptyDescription: O,
|
|
1285
|
+
tabsContainer: K,
|
|
1286
|
+
themeClassName: T,
|
|
1287
|
+
floatingDefaults: z
|
|
1288
|
+
}
|
|
1289
|
+
) }) })
|
|
1290
|
+
]
|
|
1291
|
+
}
|
|
1292
|
+
) });
|
|
1293
|
+
});
|
|
1294
|
+
export {
|
|
1295
|
+
rt as F,
|
|
1296
|
+
Qe as W,
|
|
1297
|
+
ot as a,
|
|
1298
|
+
tt as b,
|
|
1299
|
+
yt as c,
|
|
1300
|
+
Ae as d,
|
|
1301
|
+
Ve as e,
|
|
1302
|
+
Ke as f,
|
|
1303
|
+
at as g,
|
|
1304
|
+
ke as h,
|
|
1305
|
+
Ue as i,
|
|
1306
|
+
We as j,
|
|
1307
|
+
re as k,
|
|
1308
|
+
ae as l,
|
|
1309
|
+
Se as m,
|
|
1310
|
+
wt as n,
|
|
1311
|
+
dt as o,
|
|
1312
|
+
we as p,
|
|
1313
|
+
be as q,
|
|
1314
|
+
lt as r,
|
|
1315
|
+
ce as s,
|
|
1316
|
+
ze as t,
|
|
1317
|
+
ue as u,
|
|
1318
|
+
He as v,
|
|
1319
|
+
ht as w,
|
|
1320
|
+
pt as x
|
|
1321
|
+
};
|