@liuman/react-workspace 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/antd.d.ts CHANGED
@@ -1,6 +1,22 @@
1
+ import { ComponentType } from 'react';
1
2
  import { CSSProperties } from 'react';
2
3
  import { default as default_2 } from 'react';
4
+ import { Dispatch } from 'react';
3
5
  import { ReactNode } from 'react';
6
+ import { Ref } from 'react';
7
+ import { SetStateAction } from 'react';
8
+ import { ThemeConfig } from 'antd';
9
+
10
+ export declare const AntdWorkspace: default_2.FC<AntdWorkspaceProps>;
11
+
12
+ export declare interface AntdWorkspaceProps extends Omit<WorkspaceProps, 'renderSidebar' | 'theme' | 'themeClassName'> {
13
+ /** 是否启用暗色模式 */
14
+ dark?: boolean;
15
+ /** 侧边栏主题,默认跟随 dark */
16
+ sidebarTheme?: 'light' | 'dark';
17
+ /** 透传给 antd ConfigProvider 的 theme 配置 */
18
+ antdTheme?: ThemeConfig;
19
+ }
4
20
 
5
21
  export declare const AntdWorkspaceSidebar: default_2.FC<AntdWorkspaceSidebarProps>;
6
22
 
@@ -16,6 +32,26 @@ export declare interface AntdWorkspaceSidebarProps {
16
32
  theme?: 'light' | 'dark';
17
33
  }
18
34
 
35
+ /** 批量窗口管理操作 */
36
+ declare type BatchWindowAction = 'close-all' | 'close-others' | 'close-left' | 'close-right' | 'minimize-all' | 'restore-all' | 'reset-windows';
37
+
38
+ /** 默认窗口配置(不含 id) */
39
+ declare interface DefaultWindowConfig {
40
+ type: string;
41
+ title: string;
42
+ minimized?: boolean;
43
+ }
44
+
45
+ /** 浮动窗口默认尺寸 */
46
+ declare interface FloatingWindowDefaults {
47
+ x?: number;
48
+ y?: number;
49
+ width?: number;
50
+ height?: number;
51
+ minWidth?: number;
52
+ minHeight?: number;
53
+ }
54
+
19
55
  export declare function mapAntdTokenToCssVars(token: Parameters<typeof mapAntdTokenToWorkspaceTheme>[0]): CSSProperties;
20
56
 
21
57
  /** 将 Ant Design token 映射为 Workspace CSS 变量(无需在库内 import antd) */
@@ -60,6 +96,161 @@ declare interface SidebarMenuItem {
60
96
  disabled?: boolean;
61
97
  }
62
98
 
99
+ /** useWorkspace 返回值 */
100
+ declare interface UseWorkspaceReturn {
101
+ windows: WindowConfig[];
102
+ activeWindowId: string | null;
103
+ openWindow: (config: Omit<WindowConfig, 'id'>, props?: Record<string, unknown>) => void;
104
+ switchWindow: (windowId: string) => void;
105
+ closeWindow: (windowId: string) => void;
106
+ toggleMinimize: (windowId: string) => void;
107
+ floatWindow: (windowId: string, mousePosition?: {
108
+ x: number;
109
+ y: number;
110
+ }) => void;
111
+ restoreWindow: (windowId: string, insertIndex?: number) => void;
112
+ updateFloatingPosition: (windowId: string, position: WindowPosition) => void;
113
+ focusWindow: (windowId: string) => void;
114
+ batchManage: (action: BatchWindowAction) => void;
115
+ updateWindowProps: (windowId: string, props: Record<string, unknown>) => void;
116
+ updateWindowTitle: (windowId: string, title: string) => void;
117
+ clearPendingAction: (windowId: string) => void;
118
+ setWindows: Dispatch<SetStateAction<WindowConfig[]>>;
119
+ setActiveWindowId: Dispatch<SetStateAction<string | null>>;
120
+ resetWorkspace: () => void;
121
+ reorderWindows: (fromIndex: number, toIndex: number) => void;
122
+ }
123
+
124
+ /** 窗口配置 */
125
+ declare interface WindowConfig {
126
+ id: string;
127
+ /** 窗口类型标识,由使用者自定义 */
128
+ type: string;
129
+ title: string;
130
+ minimized: boolean;
131
+ floating?: boolean;
132
+ floatingPosition?: WindowPosition;
133
+ floatingZIndex?: number;
134
+ props?: Record<string, unknown>;
135
+ pendingAction?: string;
136
+ pendingDragStart?: {
137
+ x: number;
138
+ y: number;
139
+ };
140
+ }
141
+
142
+ /** 窗口类型 → 面板组件映射(开箱即用) */
143
+ declare type WindowPanelComponent = ComponentType<WindowPanelProps>;
144
+
145
+ /** 窗口面板组件接收的 props */
146
+ declare interface WindowPanelProps {
147
+ window: WindowConfig;
148
+ ctx: WindowRenderContext;
149
+ }
150
+
151
+ /** 窗口位置和大小 */
152
+ declare interface WindowPosition {
153
+ x: number;
154
+ y: number;
155
+ width: number;
156
+ height: number;
157
+ }
158
+
159
+ /** 窗口渲染上下文 */
160
+ declare interface WindowRenderContext {
161
+ workspaceId: string;
162
+ active: boolean;
163
+ activeWindowId: string | null;
164
+ windows: WindowConfig[];
165
+ openWindow: (config: Omit<WindowConfig, 'id'>, props?: Record<string, unknown>) => void;
166
+ switchWindow: (windowId: string) => void;
167
+ closeWindow: (windowId: string) => void;
168
+ toggleMinimize: (windowId: string) => void;
169
+ floatWindow: (windowId: string, mousePosition?: {
170
+ x: number;
171
+ y: number;
172
+ }) => void;
173
+ updateWindowProps: (windowId: string, props: Record<string, unknown>) => void;
174
+ clearPendingAction: (windowId: string) => void;
175
+ }
176
+
177
+ /** Workspace 组件 Props */
178
+ declare interface WorkspaceProps {
179
+ /** 工作区唯一标识,用于 localStorage / URL 隔离,默认 `default` */
180
+ workspaceId?: string;
181
+ /** 侧边栏菜单项 */
182
+ menuItems: SidebarMenuEntry[];
183
+ /**
184
+ * 渲染窗口内容(与 windows 二选一)
185
+ * 需要完全自定义渲染逻辑时使用
186
+ */
187
+ renderWindow?: (window: WindowConfig, context: WindowRenderContext) => ReactNode;
188
+ /**
189
+ * 窗口类型 → 组件映射(与 renderWindow 二选一,推荐)
190
+ * @example windows={{ home: HomePage, settings: SettingsPage }}
191
+ */
192
+ windows?: WorkspaceWindowsMap;
193
+ /** 侧边栏顶部区域(如项目切换器) */
194
+ sidebarHeader?: ReactNode;
195
+ /** 侧边栏底部区域(如用户信息) */
196
+ sidebarFooter?: ReactNode;
197
+ /** 默认打开的窗口 */
198
+ defaultWindow?: DefaultWindowConfig;
199
+ /** 加载状态 */
200
+ loading?: boolean;
201
+ loadingTip?: string;
202
+ /** 自定义操作回调 */
203
+ onAction?: (action: string) => void;
204
+ /** 当前激活的窗口类型(用于菜单高亮,不传则自动推断) */
205
+ activeWindowType?: string;
206
+ /** 空状态描述 */
207
+ emptyDescription?: ReactNode;
208
+ /** 是否同步 URL */
209
+ syncToUrl?: boolean;
210
+ preserveUrlParams?: boolean;
211
+ searchParams?: URLSearchParams;
212
+ setSearchParams?: (params: URLSearchParams, options?: {
213
+ replace?: boolean;
214
+ }) => void;
215
+ /** 浮动窗口默认尺寸 */
216
+ floatingDefaults?: FloatingWindowDefaults;
217
+ /** 窗口列表变化回调 */
218
+ onWindowsChange?: (windows: WindowConfig[], activeWindowId: string | null) => void;
219
+ /** 工作区就绪回调,可获取完整 API */
220
+ onReady?: (api: WorkspaceRef) => void;
221
+ /** 暴露 ref */
222
+ ref?: Ref<WorkspaceRef>;
223
+ /** 侧边栏宽度 */
224
+ siderWidth?: number;
225
+ /** 内容区背景色 */
226
+ contentBackground?: string;
227
+ /** 主题 class,如 rw-theme-dark */
228
+ themeClassName?: string;
229
+ /** 通过 props 覆盖 CSS 变量主题(可与 antd token 映射配合) */
230
+ theme?: WorkspaceTheme;
231
+ /** 完全自定义侧边栏,例如使用 Ant Design Menu */
232
+ renderSidebar?: (props: WorkspaceSidebarRenderProps) => ReactNode;
233
+ className?: string;
234
+ style?: CSSProperties;
235
+ }
236
+
237
+ /** Workspace 组件暴露的 Ref */
238
+ declare interface WorkspaceRef extends UseWorkspaceReturn {
239
+ workspaceId: string;
240
+ }
241
+
242
+ /** 自定义侧边栏 renderSidebar 接收的参数 */
243
+ declare interface WorkspaceSidebarRenderProps {
244
+ menuItems: SidebarMenuEntry[];
245
+ onMenuClick: (windowType: string, props?: Record<string, unknown>) => void;
246
+ onAction?: (action: string) => void;
247
+ activeWindowType?: string;
248
+ header?: ReactNode;
249
+ footer?: ReactNode;
250
+ defaultOpenKeys?: string[];
251
+ siderWidth?: number;
252
+ }
253
+
63
254
  /** 可覆盖的 Workspace 主题变量(对应 CSS --rw-* 变量) */
64
255
  declare interface WorkspaceTheme {
65
256
  colorPrimary?: string;
@@ -81,4 +272,6 @@ declare interface WorkspaceTheme {
81
272
  fontSize?: number;
82
273
  }
83
274
 
275
+ declare type WorkspaceWindowsMap = Record<string, WindowPanelComponent>;
276
+
84
277
  export { }
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingWindow.d.ts","sourceRoot":"","sources":["../../src/components/FloatingWindow.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAErF,OAAO,+BAA+B,CAAC;AAMvC,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAC1C,wBAAwB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAC/E,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAyMxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"FloatingWindow.d.ts","sourceRoot":"","sources":["../../src/components/FloatingWindow.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAErF,OAAO,+BAA+B,CAAC;AAMvC,MAAM,WAAW,mBAAmB;I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AAE,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnE,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;CAC7B;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAsNhD,CAAC;AA+BF,eAAe,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Workspace.d.ts","sourceRoot":"","sources":["../../src/components/Workspace.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAA2E,MAAM,OAAO,CAAC;AAShG,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAkE,MAAM,UAAU,CAAC;AAC7H,OAAO,qBAAqB,CAAC;AAC7B,OAAO,yBAAyB,CAAC;AAEjC,eAAO,MAAM,SAAS,kGA+JpB,CAAC;AAEH,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"Workspace.d.ts","sourceRoot":"","sources":["../../src/components/Workspace.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAA2E,MAAM,OAAO,CAAC;AAUhG,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAkE,MAAM,UAAU,CAAC;AAC7H,OAAO,qBAAqB,CAAC;AAC7B,OAAO,yBAAyB,CAAC;AAEjC,eAAO,MAAM,SAAS,kGAkKpB,CAAC;AAEH,eAAe,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useWorkspace.d.ts","sourceRoot":"","sources":["../../src/hooks/useWorkspace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,mBAAmB,EACnB,kBAAkB,EAGnB,MAAM,UAAU,CAAC;AA4BlB,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAwf7E"}
1
+ {"version":3,"file":"useWorkspace.d.ts","sourceRoot":"","sources":["../../src/hooks/useWorkspace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,mBAAmB,EACnB,kBAAkB,EAGnB,MAAM,UAAU,CAAC;AA4BlB,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CA4f7E"}
package/dist/index.d.ts CHANGED
@@ -13,18 +13,19 @@ export { WindowTabs } from './components/WindowTabs';
13
13
  export { FloatingWindow } from './components/FloatingWindow';
14
14
  export { WindowContainer } from './components/WindowContainer';
15
15
  export { useWorkspace } from './hooks/useWorkspace';
16
- export { useKeyboardShortcuts } from './hooks/useKeyboardShortcuts';
17
16
  export { WorkspaceProvider, useWorkspaceContext, useWorkspaceContextOptional } from './context/WorkspaceContext';
18
- export type { WindowConfig, WindowPosition, SidebarMenuItem, SidebarMenuDivider, SidebarMenuEntry, BatchWindowAction, DefaultWindowConfig, FloatingWindowDefaults, WindowRenderContext, UseWorkspaceOptions, UseWorkspaceReturn, WorkspaceProps, WorkspaceRef, WorkspaceSidebarRenderProps, } from './types';
17
+ export type { WindowConfig, WindowPosition, SidebarMenuItem, SidebarMenuDivider, SidebarMenuEntry, BatchWindowAction, DefaultWindowConfig, FloatingWindowDefaults, WindowRenderContext, UseWorkspaceOptions, UseWorkspaceReturn, WorkspaceProps, WorkspaceRef, WorkspaceSidebarRenderProps, WindowPanelProps, WindowPanelComponent, WorkspaceWindowsMap, } from './types';
19
18
  export type { WindowTabsProps } from './components/WindowTabs';
20
19
  export type { FloatingWindowProps } from './components/FloatingWindow';
21
20
  export type { WindowContainerProps } from './components/WindowContainer';
22
21
  export type { WindowManagerProps } from './components/WindowManager';
23
22
  export type { WorkspaceSidebarProps } from './components/WorkspaceSidebar';
24
23
  export type { WorkspaceContextValue } from './context/WorkspaceContext';
25
- export type { KeyboardShortcutsOptions } from './hooks/useKeyboardShortcuts';
26
24
  export { fixWindowPosition, getAllWindowStatesFromStorage, saveWindowStateToStorage, updateTabClickOrder, pickNextActiveWindowId, } from './utils/windowStorage';
27
25
  export { findMenuItem, resolveWindowTitle, findMenuKeyByWindowType, collectParentMenuKeys, labelToString, } from './utils/menuUtils';
26
+ export { createWindowRenderer } from './utils/createWindowRenderer';
27
+ export type { CreateWindowRendererOptions } from './utils/createWindowRenderer';
28
+ export { resolveDefaultWindow, findFirstMenuItemWithWindowType } from './utils/resolveDefaultWindow';
28
29
  export { themeToCssVars, mapAntdTokenToWorkspaceTheme, mapAntdTokenToCssVars, } from './utils/theme';
29
30
  export type { WorkspaceTheme } from './utils/theme';
30
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,iBAAiB,CAAC;AACzB,OAAO,wBAAwB,CAAC;AAChC,OAAO,gCAAgC,CAAC;AACxC,OAAO,0BAA0B,CAAC;AAClC,OAAO,6BAA6B,CAAC;AACrC,OAAO,+BAA+B,CAAC;AACvC,OAAO,8BAA8B,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAEjH,YAAY,EACV,YAAY,EACZ,cAAc,E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EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,YAAY,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAErG,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Ant Design 开箱即用工作区
3
+ *
4
+ * 内置 ConfigProvider、侧边栏、主题同步,最少配置即可运行:
5
+ *
6
+ * ```tsx
7
+ * import { AntdWorkspace } from '@liuman/react-workspace/antd';
8
+ * import '@liuman/react-workspace/style.css';
9
+ *
10
+ * <AntdWorkspace menuItems={menuItems} windows={{ home: HomePage }} />
11
+ * ```
12
+ */
13
+ import React from 'react';
14
+ import type { ThemeConfig } from 'antd';
15
+ import type { WorkspaceProps } from '../types';
16
+ export interface AntdWorkspaceProps extends Omit<WorkspaceProps, 'renderSidebar' | 'theme' | 'themeClassName'> {
17
+ /** 是否启用暗色模式 */
18
+ dark?: boolean;
19
+ /** 侧边栏主题,默认跟随 dark */
20
+ sidebarTheme?: 'light' | 'dark';
21
+ /** 透传给 antd ConfigProvider 的 theme 配置 */
22
+ antdTheme?: ThemeConfig;
23
+ }
24
+ export declare const AntdWorkspace: React.FC<AntdWorkspaceProps>;
25
+ export default AntdWorkspace;
26
+ //# sourceMappingURL=AntdWorkspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AntdWorkspace.d.ts","sourceRoot":"","sources":["../../src/integrations/AntdWorkspace.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAIxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,cAAc,EAAE,eAAe,GAAG,OAAO,GAAG,gBAAgB,CAAC;IAC5G,eAAe;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sBAAsB;IACtB,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAChC,yCAAyC;IACzC,SAAS,CAAC,EAAE,WAAW,CAAC;CACzB;AAuBD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CActD,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,4 +1,6 @@
1
1
  export { AntdWorkspaceSidebar } from './AntdSidebar';
2
2
  export type { AntdWorkspaceSidebarProps } from './AntdSidebar';
3
+ export { AntdWorkspace } from './AntdWorkspace';
4
+ export type { AntdWorkspaceProps } from './AntdWorkspace';
3
5
  export { mapAntdTokenToWorkspaceTheme, mapAntdTokenToCssVars } from '../utils/theme';
4
6
  //# sourceMappingURL=antd.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"antd.d.ts","sourceRoot":"","sources":["../../src/integrations/antd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"antd.d.ts","sourceRoot":"","sources":["../../src/integrations/antd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),f=require("react"),k=require("antd"),m=require("@ant-design/icons"),l=require("./theme-DIsh66tX.cjs"),{Sider:v}=k.Layout;function h(n){return"type"in n&&n.type==="divider"}function w(n){return n.map((r,i)=>{if(h(r))return{type:"divider",key:r.key??`d-${i}`};const e=r;return{key:e.key,icon:e.icon,label:e.label,disabled:e.disabled,children:e.children?w(e.children):void 0}})}function b(n,r){for(const i of n){if(h(i))continue;const e=i;if(e.key===r)return e;if(e.children){const d=b(e.children,r);if(d)return d}}return null}const A=({menuItems:n,onMenuClick:r,onAction:i,activeWindowType:e,header:d,footer:a,defaultOpenKeys:y=[],siderWidth:u=240,theme:p="light"})=>{const[t,T]=f.useState(!1),j=f.useMemo(()=>{if(!e)return[];const c=l.findMenuKeyByWindowType(n,e);return c?[c]:[]},[e,n]),x=({key:c})=>{const o=b(n,c);!o||o.disabled||(o.windowType?r(o.windowType,o.props):o.action&&i&&i(o.action))};return s.jsxs("div",{className:"rw-workspace-sidebar-wrapper rw-antd-sidebar",children:[s.jsxs(v,{width:u,collapsed:t,collapsedWidth:64,theme:p,className:"rw-antd-sider",children:[d&&s.jsx("div",{className:`rw-workspace-sidebar-header ${t?"collapsed":""}`,children:d}),s.jsx("div",{className:"rw-antd-menu-wrap",children:s.jsx(k.Menu,{mode:"inline",theme:p,selectedKeys:j,defaultOpenKeys:y,items:w(n),onClick:x,inlineCollapsed:t})}),a&&s.jsx("div",{className:`rw-workspace-sidebar-footer ${t?"collapsed":""}`,children:a})]}),s.jsx("button",{type:"button",className:"rw-workspace-collapse-button",style:{left:t?64:u},onClick:()=>T(!t),title:t?"展开":"折叠",children:t?s.jsx(m.MenuUnfoldOutlined,{}):s.jsx(m.MenuFoldOutlined,{})})]})};exports.mapAntdTokenToCssVars=l.mapAntdTokenToCssVars;exports.mapAntdTokenToWorkspaceTheme=l.mapAntdTokenToWorkspaceTheme;exports.AntdWorkspaceSidebar=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),m=require("react"),a=require("antd"),f=require("@ant-design/icons"),c=require("./Workspace-D7d8kiGm.cjs"),{Sider:v}=a.Layout;function w(n){return"type"in n&&n.type==="divider"}function T(n){return n.map((r,t)=>{if(w(r))return{type:"divider",key:r.key??`d-${t}`};const e=r;return{key:e.key,icon:e.icon,label:e.label,disabled:e.disabled,children:e.children?T(e.children):void 0}})}function b(n,r){for(const t of n){if(w(t))continue;const e=t;if(e.key===r)return e;if(e.children){const i=b(e.children,r);if(i)return i}}return null}const y=({menuItems:n,onMenuClick:r,onAction:t,activeWindowType:e,header:i,footer:l,defaultOpenKeys:p=[],siderWidth:h=240,theme:k="light"})=>{const[o,j]=m.useState(!1),x=m.useMemo(()=>{if(!e)return[];const u=c.findMenuKeyByWindowType(n,e);return u?[u]:[]},[e,n]),A=({key:u})=>{const d=b(n,u);!d||d.disabled||(d.windowType?r(d.windowType,d.props):d.action&&t&&t(d.action))};return s.jsxs("div",{className:"rw-workspace-sidebar-wrapper rw-antd-sidebar",children:[s.jsxs(v,{width:h,collapsed:o,collapsedWidth:64,theme:k,className:"rw-antd-sider",children:[i&&s.jsx("div",{className:`rw-workspace-sidebar-header ${o?"collapsed":""}`,children:i}),s.jsx("div",{className:"rw-antd-menu-wrap",children:s.jsx(a.Menu,{mode:"inline",theme:k,selectedKeys:x,defaultOpenKeys:p,items:T(n),onClick:A,inlineCollapsed:o})}),l&&s.jsx("div",{className:`rw-workspace-sidebar-footer ${o?"collapsed":""}`,children:l})]}),s.jsx("button",{type:"button",className:"rw-workspace-collapse-button",style:{left:o?64:h},onClick:()=>j(!o),title:o?"展开":"折叠",children:o?s.jsx(f.MenuUnfoldOutlined,{}):s.jsx(f.MenuFoldOutlined,{})})]})};function W({dark:n=!1,sidebarTheme:r,...t}){const{token:e}=a.theme.useToken(),i=m.useMemo(()=>c.mapAntdTokenToWorkspaceTheme(e),[e]),l=r??(n?"dark":"light");return s.jsx(c.Workspace,{...t,theme:i,themeClassName:n?"rw-theme-dark":void 0,renderSidebar:p=>s.jsx(y,{...p,theme:l})})}const g=({dark:n=!1,sidebarTheme:r,antdTheme:t,...e})=>s.jsx(a.ConfigProvider,{theme:{algorithm:n?a.theme.darkAlgorithm:a.theme.defaultAlgorithm,...t},children:s.jsx(W,{dark:n,sidebarTheme:r,...e})});exports.mapAntdTokenToCssVars=c.mapAntdTokenToCssVars;exports.mapAntdTokenToWorkspaceTheme=c.mapAntdTokenToWorkspaceTheme;exports.AntdWorkspace=g;exports.AntdWorkspaceSidebar=y;
@@ -1,34 +1,34 @@
1
- import { jsxs as f, jsx as s } from "react/jsx-runtime";
2
- import { useState as v, useMemo as N } from "react";
3
- import { Layout as T, Menu as C } from "antd";
1
+ import { jsxs as u, jsx as t } from "react/jsx-runtime";
2
+ import { useState as C, useMemo as h } from "react";
3
+ import { Layout as N, Menu as g, ConfigProvider as A, theme as p } from "antd";
4
4
  import { MenuUnfoldOutlined as M, MenuFoldOutlined as x } from "@ant-design/icons";
5
- import { f as A } from "./theme-CzPgEJDm.js";
6
- import { m as L, b as U } from "./theme-CzPgEJDm.js";
7
- const { Sider: S } = T;
8
- function u(r) {
5
+ import { j as S, o as W, c as j } from "./Workspace-MEGCvs9U.js";
6
+ import { n as z } from "./Workspace-MEGCvs9U.js";
7
+ const { Sider: $ } = N;
8
+ function k(r) {
9
9
  return "type" in r && r.type === "divider";
10
10
  }
11
- function m(r) {
11
+ function w(r) {
12
12
  return r.map((n, o) => {
13
- if (u(n)) return { type: "divider", key: n.key ?? `d-${o}` };
13
+ if (k(n)) return { type: "divider", key: n.key ?? `d-${o}` };
14
14
  const e = n;
15
15
  return {
16
16
  key: e.key,
17
17
  icon: e.icon,
18
18
  label: e.label,
19
19
  disabled: e.disabled,
20
- children: e.children ? m(e.children) : void 0
20
+ children: e.children ? w(e.children) : void 0
21
21
  };
22
22
  });
23
23
  }
24
- function w(r, n) {
24
+ function y(r, n) {
25
25
  for (const o of r) {
26
- if (u(o)) continue;
26
+ if (k(o)) continue;
27
27
  const e = o;
28
28
  if (e.key === n) return e;
29
29
  if (e.children) {
30
- const d = w(e.children, n);
31
- if (d) return d;
30
+ const s = y(e.children, n);
31
+ if (s) return s;
32
32
  }
33
33
  }
34
34
  return null;
@@ -38,62 +38,94 @@ const B = ({
38
38
  onMenuClick: n,
39
39
  onAction: o,
40
40
  activeWindowType: e,
41
- header: d,
41
+ header: s,
42
42
  footer: a,
43
- defaultOpenKeys: k = [],
44
- siderWidth: c = 240,
45
- theme: p = "light"
43
+ defaultOpenKeys: c = [],
44
+ siderWidth: m = 240,
45
+ theme: f = "light"
46
46
  }) => {
47
- const [i, b] = v(!1), y = N(() => {
47
+ const [i, b] = C(!1), T = h(() => {
48
48
  if (!e) return [];
49
- const l = A(r, e);
49
+ const l = S(r, e);
50
50
  return l ? [l] : [];
51
- }, [e, r]), h = ({ key: l }) => {
52
- const t = w(r, l);
53
- !t || t.disabled || (t.windowType ? n(t.windowType, t.props) : t.action && o && o(t.action));
51
+ }, [e, r]), v = ({ key: l }) => {
52
+ const d = y(r, l);
53
+ !d || d.disabled || (d.windowType ? n(d.windowType, d.props) : d.action && o && o(d.action));
54
54
  };
55
- return /* @__PURE__ */ f("div", { className: "rw-workspace-sidebar-wrapper rw-antd-sidebar", children: [
56
- /* @__PURE__ */ f(
57
- S,
55
+ return /* @__PURE__ */ u("div", { className: "rw-workspace-sidebar-wrapper rw-antd-sidebar", children: [
56
+ /* @__PURE__ */ u(
57
+ $,
58
58
  {
59
- width: c,
59
+ width: m,
60
60
  collapsed: i,
61
61
  collapsedWidth: 64,
62
- theme: p,
62
+ theme: f,
63
63
  className: "rw-antd-sider",
64
64
  children: [
65
- d && /* @__PURE__ */ s("div", { className: `rw-workspace-sidebar-header ${i ? "collapsed" : ""}`, children: d }),
66
- /* @__PURE__ */ s("div", { className: "rw-antd-menu-wrap", children: /* @__PURE__ */ s(
67
- C,
65
+ s && /* @__PURE__ */ t("div", { className: `rw-workspace-sidebar-header ${i ? "collapsed" : ""}`, children: s }),
66
+ /* @__PURE__ */ t("div", { className: "rw-antd-menu-wrap", children: /* @__PURE__ */ t(
67
+ g,
68
68
  {
69
69
  mode: "inline",
70
- theme: p,
71
- selectedKeys: y,
72
- defaultOpenKeys: k,
73
- items: m(r),
74
- onClick: h,
70
+ theme: f,
71
+ selectedKeys: T,
72
+ defaultOpenKeys: c,
73
+ items: w(r),
74
+ onClick: v,
75
75
  inlineCollapsed: i
76
76
  }
77
77
  ) }),
78
- a && /* @__PURE__ */ s("div", { className: `rw-workspace-sidebar-footer ${i ? "collapsed" : ""}`, children: a })
78
+ a && /* @__PURE__ */ t("div", { className: `rw-workspace-sidebar-footer ${i ? "collapsed" : ""}`, children: a })
79
79
  ]
80
80
  }
81
81
  ),
82
- /* @__PURE__ */ s(
82
+ /* @__PURE__ */ t(
83
83
  "button",
84
84
  {
85
85
  type: "button",
86
86
  className: "rw-workspace-collapse-button",
87
- style: { left: i ? 64 : c },
87
+ style: { left: i ? 64 : m },
88
88
  onClick: () => b(!i),
89
89
  title: i ? "展开" : "折叠",
90
- children: i ? /* @__PURE__ */ s(M, {}) : /* @__PURE__ */ s(x, {})
90
+ children: i ? /* @__PURE__ */ t(M, {}) : /* @__PURE__ */ t(x, {})
91
91
  }
92
92
  )
93
93
  ] });
94
94
  };
95
+ function K({
96
+ dark: r = !1,
97
+ sidebarTheme: n,
98
+ ...o
99
+ }) {
100
+ const { token: e } = p.useToken(), s = h(() => W(e), [e]), a = n ?? (r ? "dark" : "light");
101
+ return /* @__PURE__ */ t(
102
+ j,
103
+ {
104
+ ...o,
105
+ theme: s,
106
+ themeClassName: r ? "rw-theme-dark" : void 0,
107
+ renderSidebar: (c) => /* @__PURE__ */ t(B, { ...c, theme: a })
108
+ }
109
+ );
110
+ }
111
+ const U = ({
112
+ dark: r = !1,
113
+ sidebarTheme: n,
114
+ antdTheme: o,
115
+ ...e
116
+ }) => /* @__PURE__ */ t(
117
+ A,
118
+ {
119
+ theme: {
120
+ algorithm: r ? p.darkAlgorithm : p.defaultAlgorithm,
121
+ ...o
122
+ },
123
+ children: /* @__PURE__ */ t(K, { dark: r, sidebarTheme: n, ...e })
124
+ }
125
+ );
95
126
  export {
127
+ U as AntdWorkspace,
96
128
  B as AntdWorkspaceSidebar,
97
- L as mapAntdTokenToCssVars,
98
- U as mapAntdTokenToWorkspaceTheme
129
+ z as mapAntdTokenToCssVars,
130
+ W as mapAntdTokenToWorkspaceTheme
99
131
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./theme-DIsh66tX.cjs"),n=require("react/jsx-runtime"),o=require("react"),ze=({tip:e="加载中...",spinning:t=!1,children:b})=>n.jsxs("div",{className:"rw-spinner-wrap",children:[b,t&&n.jsxs("div",{className:"rw-spinner-overlay",children:[n.jsx("div",{className:"rw-spinner"}),e&&n.jsx("span",{className:"rw-spinner-tip",children:e})]})]}),ie=100;function te(e){const t=globalThis.window.innerWidth,b=globalThis.window.innerHeight;let x=e.x,w=e.y,m=!1;return e.x+e.width<ie?(x=-e.width+ie,m=!0):e.x>t-ie&&(x=t-ie,m=!0),e.y<0?(w=0,m=!0):e.y>b-ie&&(w=b-ie,m=!0),m?{x,y:w,width:e.width,height:e.height}:e}function le(e,t){return`${e}${t}`}function re(e,t){if(!t)return{};try{const b=le(e,t),x=localStorage.getItem(b);if(x){const w=JSON.parse(x);if(w&&typeof w=="object"){const m={};return Object.entries(w).forEach(([v,u])=>{if(u&&typeof u=="object"){const d=u,y={};d.position&&typeof d.position.x=="number"&&typeof d.position.y=="number"&&typeof d.position.width=="number"&&typeof d.position.height=="number"&&(y.position=te(d.position)),typeof d.minimized=="boolean"&&(y.minimized=d.minimized),typeof d.floating=="boolean"&&(y.floating=d.floating),typeof d.floatingZIndex=="number"&&(y.floatingZIndex=d.floatingZIndex),m[v]=y}}),m}}}catch(b){console.warn("[react-workspace] 从 localStorage 读取窗口状态失败:",b)}return{}}function se(e,t,b,x){if(t)try{const w=re(e,t);w[b]={...w[b],...x},localStorage.setItem(le(e,t),JSON.stringify(w))}catch(w){console.warn("[react-workspace] 保存窗口状态到 localStorage 失败:",w)}}function oe(e,t,b){if(t)try{const x=le(e,t),w=localStorage.getItem(x);let m=w?JSON.parse(w):{};const v=Object.values(m).map(N=>N?.floatingZIndex||0).filter(N=>N>=1e3),u=v.length>0?Math.max(...v):999,d=m[b]||{},y=d.floatingZIndex||0,P=Math.max(1e3,u+1);y>=1e3?(m[b]={...d,floatingZIndex:P},Object.keys(m).forEach(N=>{if(N!==b&&m[N]){const M=m[N];M.floatingZIndex!==void 0&&M.floatingZIndex>=1e3&&(m[N]={...M,floatingZIndex:Math.max(1e3,M.floatingZIndex-1)})}})):m[b]={...d,floatingZIndex:P},localStorage.setItem(x,JSON.stringify(m))}catch(x){console.error("[react-workspace] 保存标签点击顺序失败:",x)}}function ce(e,t,b){if(e.length===0)return null;try{const x=localStorage.getItem(le(t,b));if(x){const w=JSON.parse(x);return[...e].sort((v,u)=>{const d=w[v.type]?.floatingZIndex||0,y=w[u.type]?.floatingZIndex||0;return d>=1e3&&y>=1e3?y-d:d>=1e3?-1:y>=1e3?1:0})[0]?.id??e[e.length-1].id}}catch{}return e[e.length-1].id}const Ne="react_workspace_windows_",Me={x:100,y:100,width:800,height:600,minWidth:400,minHeight:300};function fe(e){return{...Me,...e}}function ge(){return`window-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function me(e){const{workspaceId:t,defaultWindow:b,syncToUrl:x=!1,preserveUrlParams:w=!0,searchParams:m,setSearchParams:v,storageKeyPrefix:u=Ne,floatingDefaults:d,onWindowsChange:y}=e,P=o.useRef(b??{type:"home",title:"首页",minimized:!1});P.current=b??P.current;const N=o.useRef(fe(d));N.current=fe(d);const M=o.useRef(y);M.current=y;const[g,T]=o.useState([]),[C,X]=o.useState(null),[h,O]=o.useState({}),S=o.useCallback((i,r)=>{M.current?.(i,r)},[]),q=o.useCallback(i=>re(u,t)[i]||null,[u,t]),F=o.useCallback(i=>q(i)?.position||null,[q]),L=o.useCallback((i,r)=>{if(!x||!v)return;const l=w&&m?new URLSearchParams(m):new URLSearchParams;i.length>0?l.set("windows",encodeURIComponent(JSON.stringify(i.map(a=>({id:a.id,type:a.type,title:a.title}))))):l.delete("windows"),r?l.set("active",r):l.delete("active"),v(l,{replace:!0})},[x,v,w,m]),s=o.useCallback((i,r)=>{T(i),X(r),L(i,r),S(i,r)},[L,S]),c=o.useCallback(i=>{const r=q(i.type),l={...i,minimized:r?.minimized??i.minimized??!1,floating:r?.floating??i.floating??!1};if(l.floating){let a=i.floatingPosition||r?.position;a||(a=F(i.type)??void 0),a&&(l.floatingPosition=te(a)),l.floatingZIndex=r?.floatingZIndex??i.floatingZIndex??1e3}return l},[q,F]),R=o.useCallback(()=>{const i=P.current,r={id:ge(),type:i.type,title:i.title,minimized:i.minimized??!1};s([r],r.id)},[s]),$=o.useCallback(()=>{if(t)try{localStorage.removeItem(`${u}${t}`)}catch{}O(i=>{const r={...i};return delete r[t],r}),R()},[t,u,R]);o.useEffect(()=>{if(!t||h[t])return;const i=x?m?.get("windows"):null,r=x?m?.get("active"):null;if(i)try{const a=JSON.parse(decodeURIComponent(i)).map(c),f=r&&a.some(z=>z.id===r)?r:a[0]?.id??null;T(a),X(f),S(a,f)}catch(l){console.error("[react-workspace] 解析窗口配置失败:",l),R()}else R();O(l=>({...l,[t]:!0}))},[t,m,x,h,c,R,S]);const k=o.useCallback((i,r)=>{const l=r!==void 0?{...i.props,...r}:i.props,a={...i,props:l},f=g.find(z=>z.type===a.type);if(f){const z=r&&Object.keys(r).length===0?void 0:l,H=c({...f,...a,props:z}),K=g.map(D=>D.id===f.id?H:D);s(K,f.id)}else{const z=c({...a,id:ge(),minimized:a.minimized??!1});s([...g,z],z.id)}},[g,s,c]),E=o.useCallback(i=>{const r=g.find(l=>l.id===i);if(r){if(oe(u,t,r.type),r.floating){const l=re(u,t)[r.type];if(l?.floatingZIndex){const a=g.map(f=>f.id===i?{...f,minimized:!1,floatingZIndex:l.floatingZIndex}:f);s(a,i);return}}s(g.map(l=>l.id===i?{...l,minimized:!1}:l),i)}},[g,s,u,t]),j=o.useCallback(i=>{const r=g.filter(a=>a.id!==i),l=C===i?ce(r,u,t):C;s(r,l)},[g,C,s,u,t]),p=o.useCallback(i=>{const r=g.map(a=>{if(a.id===i){const f={...a,minimized:!a.minimized};return se(u,t,a.type,{minimized:f.minimized,floating:f.floating}),f}return a}),l=r.find(a=>a.id===i);if(l?.minimized&&C===i&&!l.floating){const a=r.find(f=>!f.minimized&&!f.floating);s(r,a?.id??null)}else l&&!l.minimized&&!l.floating?s(r,i):s(r,C)},[g,C,t,u,s]),W=o.useCallback((i,r)=>{const l=g.find(D=>D.id===i);if(!l||!t||l.floating)return;const a=g.filter(D=>!D.floating&&!D.minimized);if(a.length===1&&a[0].id===i)return;const f=N.current;let z={x:f.x,y:f.y,width:f.width,height:f.height};if(r)z=te({x:r.x-f.width/2,y:Math.max(0,r.y-40),width:f.width,height:f.height});else if(l.floatingPosition)z=te(l.floatingPosition);else{const D=F(l.type);D&&(z=te(D))}oe(u,t,l.type);const H=re(u,t)[l.type]?.floatingZIndex??1e3,K=g.map(D=>D.id===i?(se(u,t,D.type,{floating:!0,minimized:!1,position:z,floatingZIndex:H}),{...D,floating:!0,minimized:!1,floatingPosition:z,floatingZIndex:H,pendingDragStart:r}):D);if(C===i){const D=K.filter(J=>!J.floating&&!J.minimized);s(K,D.length>0?ce(D,u,t):null)}else s(K,C)},[g,C,t,u,s,F]),I=o.useCallback((i,r)=>{const l=g.find(ee=>ee.id===i);if(!l?.floating)return;const{floating:a,floatingPosition:f,floatingZIndex:z,pendingDragStart:H,...K}=l;se(u,t,l.type,{floating:!1,minimized:K.minimized});const D=g.filter(ee=>!ee.floating);let J;r!==void 0&&r>=0&&r<=D.length?J=[...D.slice(0,r),K,...D.slice(r)]:J=[...D,K],J=[...J,...g.filter(ee=>ee.floating&&ee.id!==i)],s(J,i),setTimeout(()=>{document.querySelector(".rw-window-tabs")?.dispatchEvent(new CustomEvent("clearFloatingWindowPreview"))},0)},[g,s,u,t]),Z=o.useCallback((i,r)=>{const l=g.find(f=>f.id===i);if(!l)return;const a=g.map(f=>{if(f.id===i){const{pendingDragStart:z,...H}=f;return{...H,floatingPosition:r}}return f});T(a),l.floating&&se(u,t,l.type,{position:r,floating:!0,minimized:l.minimized,floatingZIndex:l.floatingZIndex})},[g,t,u]),A=o.useCallback(i=>{const r=g.find(a=>a.id===i);if(!r?.floating||!t)return;oe(u,t,r.type);const l=re(u,t)[r.type];l?.floatingZIndex&&T(a=>a.map(f=>f.id===i&&f.floating?{...f,floatingZIndex:l.floatingZIndex}:f))},[g,t,u]),Y=o.useCallback((i,r)=>{T(l=>{const a=l.map(f=>f.id===i?{...f,props:{...f.props,...r}}:f);return S(a,C),a})},[C,S]),U=o.useCallback((i,r)=>{T(l=>{const a=l.map(f=>f.id===i?{...f,title:r}:f);return L(a,C),S(a,C),a})},[C,L,S]),G=o.useCallback(i=>{T(r=>r.map(l=>{if(l.id!==i)return l;const{pendingAction:a,...f}=l;return f}))},[]),Q=o.useCallback(i=>{if(i==="reset-windows"){$();return}if(!C&&!["close-all","minimize-all","restore-all"].includes(i))return;const r=g.filter(z=>!z.floating),l=g.filter(z=>z.floating);let a=[],f=C;switch(i){case"close-left":{const z=r.findIndex(H=>H.id===C);a=r.slice(z);break}case"close-right":{const z=r.findIndex(H=>H.id===C);a=r.slice(0,z+1);break}case"close-others":a=r.filter(z=>z.id===C);break;case"close-all":a=[],f=null;break;case"minimize-all":a=r.map(z=>({...z,minimized:!0})),f=null;break;case"restore-all":a=r.map(z=>({...z,minimized:!1})),f=C??a[0]?.id??null;break;default:a=r}s([...a,...l],f)},[g,C,s,$]),B=o.useCallback((i,r)=>{const l=g.filter(K=>!K.minimized&&!K.floating);if(i<0||i>=l.length||r<0||r>=l.length||i===r)return;const a=[...l],[f]=a.splice(i,1);a.splice(r,0,f);let z=0;const H=g.map(K=>K.minimized||K.floating?K:a[z++]);s(H,C)},[g,C,s]);return{windows:g,activeWindowId:C,openWindow:k,switchWindow:E,closeWindow:j,toggleMinimize:p,floatWindow:W,restoreWindow:I,updateFloatingPosition:Z,focusWindow:A,batchManage:Q,updateWindowProps:Y,updateWindowTitle:U,clearPendingAction:G,setWindows:T,setActiveWindowId:X,resetWorkspace:$,reorderWindows:B}}function he(e){const{enabled:t=!0,windows:b,activeWindowId:x,onSwitchWindow:w,onCloseWindow:m}=e,v=o.useCallback(()=>b.filter(u=>!u.minimized&&!u.floating),[b]);o.useEffect(()=>{if(!t)return;const u=d=>{if(!(d.ctrlKey||d.metaKey))return;const P=d.target,N=P.tagName;if(!(N==="INPUT"||N==="TEXTAREA"||N==="SELECT"||P.isContentEditable)){if(d.key==="w"||d.key==="W"){x&&(d.preventDefault(),m(x));return}if(d.key==="Tab"){const M=v();if(M.length<2)return;d.preventDefault();const g=M.findIndex(C=>C.id===x),T=d.shiftKey?M[(g-1+M.length)%M.length]:M[(g+1)%M.length];T&&w(T.id)}}};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[t,x,v,w,m])}const de=o.createContext(null),pe=de.Provider;function Te(){const e=o.useContext(de);if(!e)throw new Error("[react-workspace] useWorkspaceContext 必须在 Workspace 或 WorkspaceProvider 内使用");return e}function Ee(){return o.useContext(de)}const ne=e=>({width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor"}),xe=({size:e=14,className:t})=>n.jsx("svg",{...ne(e),className:t,children:n.jsx("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor",strokeWidth:"2",fill:"none"})}),we=({size:e=14,className:t})=>n.jsx("svg",{...ne(e),className:t,children:n.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",fill:"none"})}),be=({size:e=14,className:t})=>n.jsx("svg",{...ne(e),className:t,children:n.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"1",stroke:"currentColor",strokeWidth:"2",fill:"none"})}),Re=({size:e=16,className:t})=>n.jsxs("svg",{...ne(e),className:t,children:[n.jsx("circle",{cx:"6",cy:"12",r:"1.5"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),n.jsx("circle",{cx:"18",cy:"12",r:"1.5"})]}),De=({size:e=12,className:t})=>n.jsx("svg",{...ne(e),className:t,children:n.jsx("path",{d:"M9 6l6 6-6 6",stroke:"currentColor",strokeWidth:"2",fill:"none"})}),Pe=({size:e=12,className:t})=>n.jsx("svg",{...ne(e),className:t,children:n.jsx("path",{d:"M15 6l-6 6 6 6",stroke:"currentColor",strokeWidth:"2",fill:"none"})}),Ze=({size:e=64,className:t})=>n.jsx("svg",{...ne(e),className:t,fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:n.jsx("path",{d:"M3 7a2 2 0 012-2h5l2 2h9a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V7z"})}),Oe=({size:e=12,className:t})=>n.jsx("svg",{...ne(e),className:t,children:n.jsx("path",{d:"M6 9l6 6 6-6",stroke:"currentColor",strokeWidth:"2",fill:"none"})});function Xe(e){return"type"in e&&e.type==="divider"}const ye=({menuItems:e,onMenuClick:t,onAction:b,activeWindowType:x,header:w,footer:m,defaultOpenKeys:v=[],siderWidth:u=240,onCollapsedChange:d})=>{const[y,P]=o.useState(!1),[N,M]=o.useState(new Set(v)),g=o.useMemo(()=>x?_.findMenuKeyByWindowType(e,x):null,[x,e]),T=()=>{P(S=>(d?.(!S),!S))},C=(S,q)=>{q?.stopPropagation(),M(F=>{const L=new Set(F);return L.has(S)?L.delete(S):L.add(S),L})},X=S=>{if(!S.disabled){if(S.windowType){t(S.windowType,S.props);return}if(S.action&&b){b(S.action);return}S.children?.length&&C(S.key)}},h=(S,q=0)=>S.map((F,L)=>{if(Xe(F))return n.jsx("div",{className:"rw-menu-divider"},F.key??`div-${L}`);const s=F,c=!!s.children?.length,R=N.has(s.key),$=s.key===g;return n.jsxs("div",{className:"rw-menu-group",children:[n.jsxs("button",{type:"button",className:`rw-menu-item ${$?"selected":""} ${s.disabled?"disabled":""}`,style:{paddingLeft:y?12:12+q*16},onClick:()=>X(s),disabled:s.disabled,title:y?_.labelToString(s.label):void 0,children:[s.icon&&n.jsx("span",{className:"rw-menu-icon",children:s.icon}),!y&&n.jsx("span",{className:"rw-menu-label",children:s.label}),!y&&c&&n.jsx("span",{className:`rw-menu-arrow ${R?"open":""}`,onClick:k=>C(s.key,k),role:"presentation",children:n.jsx(Oe,{size:10})})]}),!y&&c&&R&&n.jsx("div",{className:"rw-menu-children",children:h(s.children,q+1)})]},s.key)}),O=y?64:u;return n.jsxs("div",{className:"rw-workspace-sidebar-wrapper",children:[n.jsxs("aside",{className:"rw-workspace-sider",style:{width:O},children:[w&&n.jsx("div",{className:`rw-workspace-sidebar-header ${y?"collapsed":""}`,children:w}),n.jsx("nav",{className:"rw-workspace-sidebar-menu",children:h(e)}),m&&n.jsx("div",{className:`rw-workspace-sidebar-footer ${y?"collapsed":""}`,children:m})]}),n.jsx("button",{type:"button",className:"rw-workspace-collapse-button",style:{left:O},onClick:T,title:y?"展开导航":"折叠导航",children:y?n.jsx(Pe,{}):n.jsx(De,{})})]})},Le=({description:e="暂无内容",icon:t})=>n.jsxs("div",{className:"rw-empty",children:[n.jsx("div",{className:"rw-empty-icon",children:t??n.jsx(Ze,{size:64})}),n.jsx("div",{className:"rw-empty-desc",children:e})]}),ve=({window:e,active:t,children:b})=>n.jsx("div",{className:`rw-window-container ${t?"active":""}`,style:{display:t?"flex":"none",height:"100%",overflow:"auto",flexDirection:"column"},"data-window-type":e.type,children:b}),$e=({items:e,trigger:t,className:b})=>{const[x,w]=o.useState(!1),m=o.useRef(null);return o.useEffect(()=>{if(!x)return;const v=u=>{m.current?.contains(u.target)||w(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[x]),n.jsxs("div",{className:`rw-dropdown ${b||""}`,ref:m,children:[n.jsx("div",{className:"rw-dropdown-trigger",onClick:()=>w(v=>!v),role:"button",tabIndex:0,children:t}),x&&n.jsx("div",{className:"rw-dropdown-menu",children:e.map(v=>v.divider?n.jsx("div",{className:"rw-dropdown-divider"},v.key):n.jsx("button",{type:"button",className:"rw-dropdown-item",disabled:v.disabled,onClick:()=>{v.onClick?.(),w(!1)},children:v.label},v.key))})]})},ke=({windows:e,activeWindowId:t,onSwitchWindow:b,onCloseWindow:x,onToggleMinimize:w,onBatchManage:m,onFloatWindow:v,onRestoreWindow:u,onReorderWindows:d,allWindows:y=e})=>{const P=e.findIndex(s=>s.id===t),N=o.useRef(null),M=o.useRef(null),[g,T]=o.useState(null),[C,X]=o.useState(null),h=o.useRef({windowId:"",startX:0,startY:0,fromIndex:-1,mode:"none",floated:!1}),O=o.useCallback(s=>{const c=M.current;if(!c)return e.length;const R=c.getBoundingClientRect(),$=s-R.left,k=c.querySelectorAll(".rw-tab-item");if($<8)return 0;for(let E=0;E<k.length;E++){const j=k[E].getBoundingClientRect(),p=j.left-R.left+j.width/2;if($<p)return E}return k.length},[e.length]),S=o.useCallback((s,c,R)=>{if(s.target.closest(".rw-window-tab-action-btn")||s.button!==0)return;h.current={windowId:c,startX:s.clientX,startY:s.clientY,fromIndex:R,mode:"none",floated:!1};const $=j=>{const p=j.clientX-h.current.startX,W=j.clientY-h.current.startY,I=Math.sqrt(p*p+W*W);I<8||(h.current.mode==="none"&&(Math.abs(W)>40&&I>50?h.current.mode="float":Math.abs(p)>12&&Math.abs(p)>Math.abs(W)?h.current.mode="reorder":I>50&&(h.current.mode="float")),h.current.mode==="float"&&h.current.windowId===c?h.current.floated||(h.current.floated=!0,v?.(c,{x:j.clientX,y:j.clientY})):h.current.mode==="reorder"&&T(O(j.clientX)))},k=j=>{if(h.current.mode==="reorder"&&h.current.windowId===c){let W=O(j.clientX);W>h.current.fromIndex&&(W-=1),W!==h.current.fromIndex&&d&&d(h.current.fromIndex,W)}T(null),E()},E=()=>{document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",k),h.current={windowId:"",startX:0,startY:0,fromIndex:-1,mode:"none",floated:!1}};document.addEventListener("mousemove",$),document.addEventListener("mouseup",k)},[v,d,O]);o.useEffect(()=>{let s=null;const c=k=>{const{windowTitle:E,clientX:j}=k.detail,p=O(j);s&&cancelAnimationFrame(s),s=requestAnimationFrame(()=>{X({title:E,index:p}),T(p)})},R=()=>{X(null),T(null)},$=N.current;return $?.addEventListener("floatingWindowDragOver",c),$?.addEventListener("clearFloatingWindowPreview",R),()=>{$?.removeEventListener("floatingWindowDragOver",c),$?.removeEventListener("clearFloatingWindowPreview",R),s&&cancelAnimationFrame(s)}},[O]);const q=s=>{s.preventDefault();try{const c=sessionStorage.getItem("draggingWindowTitle");c&&X({title:c,index:O(s.clientX)})}catch{}T(O(s.clientX))},F=s=>{s.preventDefault();let c=s.dataTransfer.getData("windowId")||"";if(!c)try{c=sessionStorage.getItem("draggingWindowId")||""}catch{}c&&u&&u(c,g??void 0),X(null),T(null)},L=[{key:"close-others",label:"关闭其他",disabled:e.length<=1,onClick:()=>m("close-others")},{key:"close-left",label:"关闭左侧",disabled:P<=0,onClick:()=>m("close-left")},{key:"close-right",label:"关闭右侧",disabled:P<0||P>=e.length-1,onClick:()=>m("close-right")},{key:"d1",label:"",divider:!0},{key:"close-all",label:"关闭全部",disabled:!e.length,onClick:()=>m("close-all")},{key:"d2",label:"",divider:!0},{key:"minimize-all",label:"最小化全部",disabled:!e.length,onClick:()=>m("minimize-all")},{key:"restore-all",label:"还原全部",disabled:!y.some(s=>s.minimized),onClick:()=>m("restore-all")},{key:"d3",label:"",divider:!0},{key:"reset",label:"重置窗口",onClick:()=>m("reset-windows")}];return n.jsx("div",{className:"rw-window-tabs",ref:N,onDragOver:q,onDragLeave:()=>{X(null),T(null)},onDrop:F,children:n.jsxs("div",{className:"rw-window-tabs-container",children:[n.jsxs("div",{className:"rw-tab-list",ref:M,children:[e.map((s,c)=>n.jsxs("div",{className:`rw-tab-item ${s.id===t?"active":""}`,onClick:()=>b(s.id),onMouseDown:R=>S(R,s.id,c),children:[n.jsx("span",{className:"rw-tab-title",children:s.title}),n.jsxs("div",{className:"rw-window-tab-actions",children:[n.jsx("button",{type:"button",title:"浮动窗口",className:"rw-icon-btn rw-window-tab-action-btn",onClick:R=>{R.stopPropagation(),v?.(s.id)},children:n.jsx(be,{size:12})}),n.jsx("button",{type:"button",title:"最小化",className:"rw-icon-btn rw-window-tab-action-btn",onClick:R=>{R.stopPropagation(),w(s.id)},children:n.jsx(we,{size:12})}),n.jsx("button",{type:"button",title:"关闭",className:"rw-icon-btn rw-window-tab-action-btn",onClick:R=>{R.stopPropagation(),x(s.id)},children:n.jsx(xe,{size:12})})]})]},s.id)),C&&g!==null&&n.jsx("div",{className:"rw-tab-preview",style:{order:g},children:C.title})]}),g!==null&&!C&&n.jsx(Ae,{listRef:M,index:g}),e.length>0&&n.jsx($e,{items:L,trigger:n.jsx("button",{type:"button",className:"rw-icon-btn rw-window-tabs-batch-btn",title:"批量管理",children:n.jsx(Re,{})})})]})})},Ae=({listRef:e,index:t})=>{const[b,x]=o.useState(0);return o.useEffect(()=>{const w=()=>{const m=e.current;if(!m)return;m.getBoundingClientRect();const v=m.querySelectorAll(".rw-tab-item:not(.rw-tab-preview)");if(t===0){x(8);return}if(t>=v.length){const d=v[v.length-1];x(d.offsetLeft+d.offsetWidth+2);return}const u=v[t];x(u.offsetLeft-1)};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[e,t]),n.jsx("div",{className:"rw-window-tab-insert-indicator",style:{left:`${b}px`}})},Ye={x:100,y:100,width:800,height:600,minWidth:400,minHeight:300},We=({window:e,children:t,floatingDefaults:b,onUpdateFloatingPosition:x,onRestoreWindow:w,onCloseWindow:m,onToggleMinimize:v,onFocusWindow:u})=>{const d={...Ye,...b},y=o.useRef(null),P=o.useRef(null),[N,M]=o.useState(!1),[g,T]=o.useState(!1),[C,X]=o.useState(!1),h=o.useRef(!1),O=o.useRef(""),S=o.useRef({x:0,y:0,startX:0,startY:0,startWidth:0,startHeight:0}),q=o.useRef({x:0,y:0,width:0,height:0,startX:0,startY:0}),F=o.useRef(null),L=o.useRef(null),s=o.useRef(null),c=e.floatingPosition||{x:d.x,y:d.y,width:d.width,height:d.height};o.useEffect(()=>{if(!e.pendingDragStart||N||g)return;let k=c.x,E=c.y;if(y.current){const j=y.current.getBoundingClientRect();k=j.left,E=j.top}u?.(e.id),s.current={windowId:e.id,windowTitle:e.title};try{sessionStorage.setItem("draggingWindowId",e.id),sessionStorage.setItem("draggingWindowTitle",e.title)}catch{}M(!0),S.current={x:e.pendingDragStart.x-k,y:e.pendingDragStart.y-E,startX:k,startY:E,startWidth:c.width,startHeight:c.height}},[e.pendingDragStart,e.id,e.title,N,g,c,u]),o.useEffect(()=>{if(N||g||e.pendingDragStart)return;const k=te(c);(k.x!==c.x||k.y!==c.y)&&x(e.id,k)},[e.id,e.pendingDragStart]),o.useEffect(()=>{if(!y.current||N||g)return;const k=y.current;k.style.transform=`translate(${c.x}px, ${c.y}px)`,k.style.width=`${c.width}px`,k.style.height=`${c.height}px`},[c.x,c.y,c.width,c.height,N,g]);const R=o.useCallback(k=>{const E=k.target;if(E.closest(".rw-floating-window-action-btn")||E.closest(".rw-floating-window-resize-handle")||!P.current?.contains(E))return;u?.(e.id);let j=c.x,p=c.y;if(y.current){const W=y.current.getBoundingClientRect();j=W.left,p=W.top}s.current={windowId:e.id,windowTitle:e.title};try{sessionStorage.setItem("draggingWindowId",e.id),sessionStorage.setItem("draggingWindowTitle",e.title)}catch{}M(!0),S.current={x:k.clientX-j,y:k.clientY-p,startX:j,startY:p,startWidth:c.width,startHeight:c.height}},[c,e.id,e.title,u]),$=o.useCallback((k,E)=>{k.stopPropagation(),k.preventDefault(),u?.(e.id);let j=c.x,p=c.y,W=c.width,I=c.height;if(y.current){const Z=y.current.getBoundingClientRect();j=Z.left,p=Z.top,W=Z.width,I=Z.height}T(!0),O.current=E,q.current={x:k.clientX,y:k.clientY,width:W,height:I,startX:j,startY:p}},[c,e.id,u]);return o.useEffect(()=>{const E=p=>{if(N){p.preventDefault();const W=document.querySelector(".rw-window-tabs");if(W&&s.current){const A=W.getBoundingClientRect(),Y=p.clientY>=A.top&&p.clientY<=A.bottom&&p.clientX>=A.left&&p.clientX<=A.right,U=h.current;X(Y),h.current=Y,Y?W.dispatchEvent(new CustomEvent("floatingWindowDragOver",{detail:{...s.current,clientX:p.clientX,clientY:p.clientY}})):U&&W.dispatchEvent(new CustomEvent("clearFloatingWindowPreview"))}const I=Math.max(-S.current.startWidth+100,Math.min(p.clientX-S.current.x,globalThis.window.innerWidth-100)),Z=Math.max(0,Math.min(p.clientY-S.current.y,globalThis.window.innerHeight-100));y.current.style.transform=`translate(${I}px, ${Z}px)`,L.current={x:I,y:Z,width:S.current.startWidth,height:S.current.startHeight}}else if(g){p.preventDefault();const W=O.current,I=q.current;let Z=I.startX,A=I.startY,Y=I.width,U=I.height;const G=p.clientX-I.x,Q=p.clientY-I.y;W.includes("e")&&(Y=Math.max(d.minWidth,I.width+G)),W.includes("w")&&(Y=Math.max(d.minWidth,I.width-G),Z=I.startX+I.width-Y),W.includes("s")&&(U=Math.max(d.minHeight,I.height+Q)),W.includes("n")&&(U=Math.max(d.minHeight,I.height-Q),A=I.startY+I.height-U);const B=y.current;B.style.transform=`translate(${Z}px, ${A}px)`,B.style.width=`${Y}px`,B.style.height=`${U}px`,L.current={x:Z,y:A,width:Y,height:U}}},j=p=>{if(p&&s.current){const I=document.querySelector(".rw-window-tabs");if(I){const Z=I.getBoundingClientRect();if(p.clientY>=Z.top&&p.clientY<=Z.bottom&&p.clientX>=Z.left&&p.clientX<=Z.right){const A=I.querySelector(".rw-tab-list");if(A){let Y=A.querySelectorAll(".rw-tab-item").length;const U=A.getBoundingClientRect(),G=p.clientX-U.left;A.querySelectorAll(".rw-tab-item").forEach((Q,B)=>{const i=Q.getBoundingClientRect();G<i.left-U.left+i.width/2&&(Y=Math.min(Y,B))}),w(s.current.windowId,Y),s.current=null,M(!1),T(!1),X(!1);return}}}}let W=L.current;g&&W&&(W=te(W)),W&&x(e.id,W),L.current=null,s.current=null;try{sessionStorage.removeItem("draggingWindowId"),sessionStorage.removeItem("draggingWindowTitle")}catch{}M(!1),T(!1),X(!1),h.current=!1};if(N||g){const p=W=>{F.current&&cancelAnimationFrame(F.current),F.current=requestAnimationFrame(()=>E(W))};return document.addEventListener("mousemove",p,{passive:!1}),document.addEventListener("mouseup",j),document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",j),document.body.style.userSelect=""}}},[N,g,e.id,d.minWidth,d.minHeight,x,w]),n.jsxs("div",{ref:y,className:"rw-floating-window",style:{transform:`translate(${c.x}px, ${c.y}px)`,width:c.width,height:c.height,zIndex:e.floatingZIndex||1e3,opacity:C?.5:1,minWidth:d.minWidth,minHeight:d.minHeight},onClick:k=>{k.target.closest("button, a, input, select, textarea")||u?.(e.id)},children:[n.jsxs("div",{ref:P,className:"rw-floating-window-header",onMouseDown:R,onDoubleClick:()=>w(e.id),children:[n.jsx("div",{className:"rw-floating-window-title",children:e.title}),n.jsxs("div",{className:"rw-floating-window-actions",children:[n.jsx("button",{type:"button",title:"放回",className:"rw-icon-btn rw-floating-window-action-btn",onClick:()=>w(e.id),children:n.jsx(be,{size:12})}),n.jsx("button",{type:"button",title:"最小化",className:"rw-icon-btn rw-floating-window-action-btn",onClick:()=>v(e.id),children:n.jsx(we,{size:12})}),n.jsx("button",{type:"button",title:"关闭",className:"rw-icon-btn rw-floating-window-action-btn",onClick:()=>m(e.id),children:n.jsx(xe,{size:12})})]})]}),n.jsx("div",{className:"rw-floating-window-content",children:t}),["nw","ne","sw","se","n","s","w","e"].map(k=>n.jsx("div",{className:`rw-floating-window-resize-handle rw-floating-window-resize-${k}`,onMouseDown:E=>$(E,k)},k))]})},Ce=({windows:e,activeWindowId:t,renderWindow:b,onSwitchWindow:x,onCloseWindow:w,onToggleMinimize:m,onBatchManage:v,onFloatWindow:u,onRestoreWindow:d,onUpdateFloatingPosition:y,onFocusWindow:P,onReorderWindows:N,emptyDescription:M="从左侧菜单选择功能开始工作",floatingDefaults:g})=>{if(e.length===0)return n.jsx("div",{className:"rw-window-manager-empty",children:n.jsx(Le,{description:M})});const T=e.filter(h=>h.minimized),C=e.filter(h=>h.floating&&!h.minimized),X=e.filter(h=>!h.minimized&&!h.floating);return n.jsxs("div",{className:"rw-window-manager",children:[n.jsx(ke,{windows:X,activeWindowId:t,onSwitchWindow:x,onCloseWindow:w,onToggleMinimize:m,onBatchManage:v,onFloatWindow:u,onRestoreWindow:d,onReorderWindows:N,allWindows:e}),n.jsx("div",{className:"rw-window-content-area",children:X.map(h=>n.jsx(ve,{window:h,active:h.id===t,children:b(h,{})},h.id))}),T.length>0&&n.jsx("div",{className:"rw-minimized-windows-bar",children:T.map(h=>n.jsxs("div",{className:"rw-minimized-window-item",onClick:()=>m(h.id),title:h.floating?`${h.title} (浮动窗口)`:h.title,role:"button",tabIndex:0,onKeyDown:O=>O.key==="Enter"&&m(h.id),children:[n.jsx("span",{children:h.title}),h.floating&&n.jsx("span",{className:"rw-minimized-floating-badge",children:"🔲"})]},h.id))}),C.map(h=>n.jsx(We,{window:h,floatingDefaults:g,onUpdateFloatingPosition:y||(()=>{}),onRestoreWindow:d||(()=>{}),onCloseWindow:w,onToggleMinimize:m,onFocusWindow:P,children:b(h,{})},h.id))]})},Se=o.forwardRef(function({workspaceId:t,menuItems:b,renderWindow:x,sidebarHeader:w,sidebarFooter:m,defaultWindow:v,loading:u=!1,loadingTip:d="加载中...",onAction:y,activeWindowType:P,emptyDescription:N,syncToUrl:M=!1,preserveUrlParams:g=!0,searchParams:T,setSearchParams:C,floatingDefaults:X,onWindowsChange:h,onReady:O,siderWidth:S=240,contentBackground:q,enableKeyboardShortcuts:F=!0,themeClassName:L,theme:s,renderSidebar:c,className:R,style:$},k){const E=me({workspaceId:t,defaultWindow:v,syncToUrl:M,preserveUrlParams:g,searchParams:T,setSearchParams:C,floatingDefaults:X,onWindowsChange:h}),{windows:j,activeWindowId:p,openWindow:W,switchWindow:I,closeWindow:Z,toggleMinimize:A,floatWindow:Y,restoreWindow:U,updateFloatingPosition:G,focusWindow:Q,batchManage:B,updateWindowProps:i,clearPendingAction:r,reorderWindows:l}=E;he({enabled:F,windows:j,activeWindowId:p,onSwitchWindow:I,onCloseWindow:Z});const a={workspaceId:t,...E};o.useImperativeHandle(k,()=>a,[t,j,p]),o.useEffect(()=>{O&&j.length>0&&O({workspaceId:t,...E})},[O,t,j.length]);const f=o.useMemo(()=>P!==void 0?P:j.find(V=>V.id===p)?.type,[P,j,p]),z=o.useCallback((V,ae)=>{W({type:V,title:_.resolveWindowTitle(b,V),minimized:!1},ae)},[W,b]),H=o.useCallback((V,ae)=>({workspaceId:t,active:ae,activeWindowId:p,windows:j,openWindow:W,switchWindow:I,closeWindow:Z,toggleMinimize:A,floatWindow:Y,updateWindowProps:(je,Ie)=>i(je,Ie),clearPendingAction:r}),[t,p,j,W,I,Z,A,Y,i,r]),K=o.useMemo(()=>({...a,buildRenderContext:H}),[t,j,p,H]),D=q??"var(--rw-color-bg-tertiary)",ee={minHeight:"100vh",height:"100vh",display:"flex",...s?_.themeToCssVars(s):void 0,...$},ue={menuItems:b,onMenuClick:z,onAction:y,activeWindowType:f,header:w,footer:m,defaultOpenKeys:_.collectParentMenuKeys(b),siderWidth:S};return n.jsx(pe,{value:K,children:n.jsxs("div",{className:`rw-workspace ${L||""} ${R||""}`.trim(),style:ee,children:[c?c(ue):n.jsx(ye,{...ue}),n.jsx("main",{className:"rw-workspace-main",style:{background:D},children:n.jsx(ze,{spinning:u,tip:d,children:n.jsx(Ce,{workspaceId:t,windows:j,activeWindowId:p,renderWindow:V=>x(V,H(V,V.id===p&&!V.floating)),onSwitchWindow:I,onCloseWindow:Z,onToggleMinimize:A,onBatchManage:B,onOpenWindow:W,onFloatWindow:Y,onRestoreWindow:U,onUpdateFloatingPosition:G,onFocusWindow:Q,onReorderWindows:l,emptyDescription:N,floatingDefaults:X})})})]})})});exports.collectParentMenuKeys=_.collectParentMenuKeys;exports.findMenuItem=_.findMenuItem;exports.findMenuKeyByWindowType=_.findMenuKeyByWindowType;exports.labelToString=_.labelToString;exports.mapAntdTokenToCssVars=_.mapAntdTokenToCssVars;exports.mapAntdTokenToWorkspaceTheme=_.mapAntdTokenToWorkspaceTheme;exports.resolveWindowTitle=_.resolveWindowTitle;exports.themeToCssVars=_.themeToCssVars;exports.FloatingWindow=We;exports.WindowContainer=ve;exports.WindowManager=Ce;exports.WindowTabs=ke;exports.Workspace=Se;exports.WorkspaceDefault=Se;exports.WorkspaceProvider=pe;exports.WorkspaceSidebar=ye;exports.fixWindowPosition=te;exports.getAllWindowStatesFromStorage=re;exports.pickNextActiveWindowId=ce;exports.saveWindowStateToStorage=se;exports.updateTabClickOrder=oe;exports.useKeyboardShortcuts=he;exports.useWorkspace=me;exports.useWorkspaceContext=Te;exports.useWorkspaceContextOptional=Ee;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Workspace-D7d8kiGm.cjs");exports.FloatingWindow=e.FloatingWindow;exports.WindowContainer=e.WindowContainer;exports.WindowManager=e.WindowManager;exports.WindowTabs=e.WindowTabs;exports.Workspace=e.Workspace;exports.WorkspaceDefault=e.Workspace;exports.WorkspaceProvider=e.WorkspaceProvider;exports.WorkspaceSidebar=e.WorkspaceSidebar;exports.collectParentMenuKeys=e.collectParentMenuKeys;exports.createWindowRenderer=e.createWindowRenderer;exports.findFirstMenuItemWithWindowType=e.findFirstMenuItemWithWindowType;exports.findMenuItem=e.findMenuItem;exports.findMenuKeyByWindowType=e.findMenuKeyByWindowType;exports.fixWindowPosition=e.fixWindowPosition;exports.getAllWindowStatesFromStorage=e.getAllWindowStatesFromStorage;exports.labelToString=e.labelToString;exports.mapAntdTokenToCssVars=e.mapAntdTokenToCssVars;exports.mapAntdTokenToWorkspaceTheme=e.mapAntdTokenToWorkspaceTheme;exports.pickNextActiveWindowId=e.pickNextActiveWindowId;exports.resolveDefaultWindow=e.resolveDefaultWindow;exports.resolveWindowTitle=e.resolveWindowTitle;exports.saveWindowStateToStorage=e.saveWindowStateToStorage;exports.themeToCssVars=e.themeToCssVars;exports.updateTabClickOrder=e.updateTabClickOrder;exports.useWorkspace=e.useWorkspace;exports.useWorkspaceContext=e.useWorkspaceContext;exports.useWorkspaceContextOptional=e.useWorkspaceContextOptional;