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