@liuman/react-workspace 1.2.1 → 1.3.1

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