@liuman/react-workspace 1.2.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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +470 -0
  3. package/dist/antd.d.ts +84 -0
  4. package/dist/components/FloatingWindow.d.ts +19 -0
  5. package/dist/components/FloatingWindow.d.ts.map +1 -0
  6. package/dist/components/WindowContainer.d.ts +14 -0
  7. package/dist/components/WindowContainer.d.ts.map +1 -0
  8. package/dist/components/WindowManager.d.ts +30 -0
  9. package/dist/components/WindowManager.d.ts.map +1 -0
  10. package/dist/components/WindowTabs.d.ts +24 -0
  11. package/dist/components/WindowTabs.d.ts.map +1 -0
  12. package/dist/components/Workspace.d.ts +10 -0
  13. package/dist/components/Workspace.d.ts.map +1 -0
  14. package/dist/components/WorkspaceSidebar.d.ts +20 -0
  15. package/dist/components/WorkspaceSidebar.d.ts.map +1 -0
  16. package/dist/context/WorkspaceContext.d.ts +16 -0
  17. package/dist/context/WorkspaceContext.d.ts.map +1 -0
  18. package/dist/hooks/useKeyboardShortcuts.d.ts +14 -0
  19. package/dist/hooks/useKeyboardShortcuts.d.ts.map +1 -0
  20. package/dist/hooks/useWorkspace.d.ts +3 -0
  21. package/dist/hooks/useWorkspace.d.ts.map +1 -0
  22. package/dist/index.d.ts +30 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/integrations/AntdSidebar.d.ts +24 -0
  25. package/dist/integrations/AntdSidebar.d.ts.map +1 -0
  26. package/dist/integrations/antd.d.ts +4 -0
  27. package/dist/integrations/antd.d.ts.map +1 -0
  28. package/dist/react-workspace-antd.cjs +1 -0
  29. package/dist/react-workspace-antd.js +99 -0
  30. package/dist/react-workspace.cjs +1 -0
  31. package/dist/react-workspace.css +1 -0
  32. package/dist/react-workspace.js +1142 -0
  33. package/dist/theme-CzPgEJDm.js +113 -0
  34. package/dist/theme-DIsh66tX.cjs +1 -0
  35. package/dist/types.d.ts +194 -0
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/ui/Dropdown.d.ts +17 -0
  38. package/dist/ui/Dropdown.d.ts.map +1 -0
  39. package/dist/ui/EmptyState.d.ts +7 -0
  40. package/dist/ui/EmptyState.d.ts.map +1 -0
  41. package/dist/ui/Icons.d.ts +15 -0
  42. package/dist/ui/Icons.d.ts.map +1 -0
  43. package/dist/ui/Spinner.d.ts +8 -0
  44. package/dist/ui/Spinner.d.ts.map +1 -0
  45. package/dist/utils/menuUtils.d.ts +20 -0
  46. package/dist/utils/menuUtils.d.ts.map +1 -0
  47. package/dist/utils/theme.d.ts +41 -0
  48. package/dist/utils/theme.d.ts.map +1 -0
  49. package/dist/utils/windowStorage.d.ts +19 -0
  50. package/dist/utils/windowStorage.d.ts.map +1 -0
  51. package/package.json +84 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 react-workspace contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,470 @@
1
+ # react-workspace
2
+
3
+ 一个 React IDE 风格的多窗口工作区组件库,提供类似桌面 IDE 的多窗口管理体验。
4
+
5
+ ## 特性
6
+
7
+ - **零 UI 框架依赖** — 不依赖 antd,仅 React + CSS
8
+ - **多窗口标签页** — 打开、切换、关闭、最小化
9
+ - **标签拖拽排序** — 水平拖动标签调整顺序
10
+ - **浮动窗口** — 拖出为独立窗口,可调整大小,拖回标签栏还原
11
+ - **键盘快捷键** — `Ctrl/Cmd+W` 关闭,`Ctrl/Cmd+Tab` 切换
12
+ - **CSS 主题变量** — 支持亮色/暗色主题定制
13
+ - **URL 状态同步** — 刷新恢复、分享链接
14
+ - **localStorage 持久化** — 浮动窗口位置自动保存
15
+ - **在线 Demo** — GitHub Pages 一键体验
16
+
17
+ ## 安装
18
+
19
+ ```bash
20
+ yarn add @liuman/react-workspace
21
+ ```
22
+
23
+ ### Peer Dependencies
24
+
25
+ ```bash
26
+ yarn add react react-dom
27
+ # URL 同步(可选)
28
+ yarn add react-router-dom
29
+ ```
30
+
31
+ ## 快速开始
32
+
33
+ ```tsx
34
+ import { Workspace } from '@liuman/react-workspace';
35
+ import '@liuman/react-workspace/style.css';
36
+ import { useSearchParams } from 'react-router-dom';
37
+ import { HomeOutlined, SettingOutlined } from '@ant-design/icons';
38
+
39
+ function App() {
40
+ const [searchParams, setSearchParams] = useSearchParams();
41
+
42
+ const menuItems = [
43
+ {
44
+ key: 'home',
45
+ icon: <HomeOutlined />,
46
+ label: '首页',
47
+ windowType: 'home',
48
+ },
49
+ {
50
+ key: 'settings',
51
+ icon: <SettingOutlined />,
52
+ label: '设置',
53
+ windowType: 'settings',
54
+ },
55
+ ];
56
+
57
+ return (
58
+ <Workspace
59
+ workspaceId="my-app"
60
+ menuItems={menuItems}
61
+ defaultWindow={{ type: 'home', title: '首页' }}
62
+ syncToUrl
63
+ searchParams={searchParams}
64
+ setSearchParams={setSearchParams}
65
+ sidebarHeader={<div>我的工作区</div>}
66
+ sidebarFooter={<div>用户信息</div>}
67
+ renderWindow={(window, ctx) => {
68
+ switch (window.type) {
69
+ case 'home':
70
+ return <div style={{ padding: 24 }}>欢迎!</div>;
71
+ case 'settings':
72
+ return <div style={{ padding: 24 }}>设置页面</div>;
73
+ default:
74
+ return <div>未知窗口: {window.type}</div>;
75
+ }
76
+ }}
77
+ />
78
+ );
79
+ }
80
+ ```
81
+
82
+ ## API
83
+
84
+ ### `<Workspace />`
85
+
86
+ | 属性 | 类型 | 默认值 | 说明 |
87
+ |------|------|--------|------|
88
+ | `workspaceId` | `string` | 必填 | 工作区唯一标识,用于 localStorage 隔离 |
89
+ | `menuItems` | `SidebarMenuEntry[]` | 必填 | 侧边栏菜单(支持 `{ type: 'divider' }` 分隔线) |
90
+ | `renderWindow` | `(window, ctx) => ReactNode` | 必填 | 渲染窗口内容 |
91
+ | `defaultWindow` | `{ type, title }` | `{ type: 'home', title: '首页' }` | 默认打开的窗口 |
92
+ | `sidebarHeader` | `ReactNode` | - | 侧边栏顶部区域 |
93
+ | `sidebarFooter` | `ReactNode` | - | 侧边栏底部区域(固定底部) |
94
+ | `loading` | `boolean` | `false` | 加载状态 |
95
+ | `syncToUrl` | `boolean` | `false` | 是否同步窗口状态到 URL |
96
+ | `preserveUrlParams` | `boolean` | `true` | syncToUrl 时保留 URL 其他参数 |
97
+ | `floatingDefaults` | `FloatingWindowDefaults` | - | 浮动窗口默认尺寸 |
98
+ | `onWindowsChange` | `(windows, activeId) => void` | - | 窗口列表变化回调 |
99
+ | `onReady` | `(api: WorkspaceRef) => void` | - | 工作区就绪回调 |
100
+ | `ref` | `WorkspaceRef` | - | 暴露完整工作区 API |
101
+ | `siderWidth` | `number` | `240` | 侧边栏宽度 |
102
+ | `contentBackground` | `string` | `#f0f2f5` | 内容区背景色 |
103
+ | `enableKeyboardShortcuts` | `boolean` | `true` | Ctrl+W / Ctrl+Tab |
104
+ | `themeClassName` | `string` | - | 如 `rw-theme-dark` 启用暗色主题 |
105
+ | `theme` | `WorkspaceTheme` | - | 通过 props 覆盖 CSS 变量(可与 antd token 映射) |
106
+ | `renderSidebar` | `(props) => ReactNode` | - | 自定义侧边栏,例如 Ant Design Menu |
107
+
108
+ ### 与 Ant Design 集成
109
+
110
+ 库核心**零 antd 依赖**,但可无缝配合 Ant Design 使用:
111
+
112
+ ```bash
113
+ yarn add @liuman/react-workspace antd @ant-design/icons
114
+ ```
115
+
116
+ #### 1. 主题同步(推荐)
117
+
118
+ 将 antd Design Token 映射为 Workspace CSS 变量,标签栏、边框等会自动与 antd 风格一致:
119
+
120
+ ```tsx
121
+ import { ConfigProvider, theme } from 'antd';
122
+ import { Workspace, mapAntdTokenToWorkspaceTheme } from '@liuman/react-workspace';
123
+ import '@liuman/react-workspace/style.css';
124
+
125
+ function ThemedApp() {
126
+ const { token } = theme.useToken();
127
+ return (
128
+ <Workspace
129
+ theme={mapAntdTokenToWorkspaceTheme(token)}
130
+ menuItems={menuItems}
131
+ renderWindow={renderWindow}
132
+ workspaceId="app"
133
+ />
134
+ );
135
+ }
136
+
137
+ export default function App() {
138
+ return (
139
+ <ConfigProvider theme={{ token: { colorPrimary: '#1677ff' } }}>
140
+ <ThemedApp />
141
+ </ConfigProvider>
142
+ );
143
+ }
144
+ ```
145
+
146
+ 也可直接得到 inline style:`mapAntdTokenToCssVars(token)`。
147
+
148
+ #### 2. 使用 Ant Design 侧边栏
149
+
150
+ ```tsx
151
+ import { AntdWorkspaceSidebar } from '@liuman/react-workspace/antd';
152
+
153
+ <Workspace
154
+ renderSidebar={(props) => (
155
+ <AntdWorkspaceSidebar {...props} theme="light" siderWidth={240} />
156
+ )}
157
+ ...
158
+ />
159
+ ```
160
+
161
+ `AntdWorkspaceSidebar` 接收与默认侧边栏相同的 props,内部使用 antd `Menu` + `Layout.Sider`。
162
+
163
+ #### 3. 窗口内容使用 antd 组件
164
+
165
+ `renderWindow` 渲染的内容完全由你控制,可直接使用 Table、Form、Modal 等任意 antd 组件:
166
+
167
+ ```tsx
168
+ renderWindow={(window) => {
169
+ if (window.type === 'users') return <UserTable />;
170
+ return <Empty description="未知页面" />;
171
+ }}
172
+ ```
173
+
174
+ #### 4. 纯 CSS 定制(不用 antd)
175
+
176
+ ```css
177
+ .my-workspace {
178
+ --rw-color-primary: #6366f1;
179
+ --rw-sidebar-width: 260px;
180
+ --rw-tab-height: 36px;
181
+ }
182
+ ```
183
+
184
+ ```tsx
185
+ <Workspace className="my-workspace" themeClassName="rw-theme-dark" ... />
186
+ ```
187
+
188
+ ### 快捷键
189
+
190
+ | 快捷键 | 操作 |
191
+ |--------|------|
192
+ | `Ctrl/Cmd + W` | 关闭当前窗口 |
193
+ | `Ctrl/Cmd + Tab` | 切换到下一个窗口 |
194
+ | `Ctrl/Cmd + Shift + Tab` | 切换到上一个窗口 |
195
+
196
+ ### 主题定制
197
+
198
+ ```css
199
+ /* 覆盖 CSS 变量 */
200
+ .my-app {
201
+ --rw-color-primary: #6366f1;
202
+ --rw-sidebar-width: 260px;
203
+ }
204
+ ```
205
+
206
+ ```tsx
207
+ <Workspace themeClassName="rw-theme-dark" ... />
208
+ ```
209
+
210
+ ### 本地 Demo
211
+
212
+ ```bash
213
+ cd packages/react-workspace
214
+ yarn dev:demo # 开发
215
+ yarn build:demo # 构建
216
+ ```
217
+
218
+ ### `useWorkspaceContext`
219
+
220
+ 在 `renderWindow` 渲染的内容中访问工作区 API:
221
+
222
+ ```tsx
223
+ function MyPage() {
224
+ const { openWindow, closeWindow, windows } = useWorkspaceContext();
225
+ // ...
226
+ }
227
+ ```
228
+
229
+ ### `useWorkspace` Hook
230
+
231
+ 如需更细粒度控制,可直接使用 hook:
232
+
233
+ ```tsx
234
+ import { useWorkspace, WindowManager, WorkspaceSidebar } from '@liuman/react-workspace';
235
+
236
+ const workspace = useWorkspace({
237
+ workspaceId: 'my-app',
238
+ defaultWindow: { type: 'home', title: '首页' },
239
+ syncToUrl: true,
240
+ searchParams,
241
+ setSearchParams,
242
+ });
243
+
244
+ const {
245
+ windows,
246
+ activeWindowId,
247
+ openWindow,
248
+ switchWindow,
249
+ closeWindow,
250
+ toggleMinimize,
251
+ floatWindow,
252
+ restoreWindow,
253
+ batchManage,
254
+ updateWindowProps,
255
+ updateWindowTitle,
256
+ clearPendingAction,
257
+ resetWorkspace,
258
+ } = workspace;
259
+ ```
260
+
261
+ ### WindowRenderContext
262
+
263
+ `renderWindow` 第二个参数提供窗口操作上下文:
264
+
265
+ ```typescript
266
+ interface WindowRenderContext {
267
+ workspaceId: string;
268
+ active: boolean; // 当前窗口是否激活
269
+ activeWindowId: string | null;
270
+ windows: WindowConfig[];
271
+ openWindow: (...) => void;
272
+ switchWindow: (id) => void;
273
+ closeWindow: (id) => void;
274
+ toggleMinimize: (id) => void;
275
+ floatWindow: (id) => void;
276
+ updateWindowProps: (id, props) => void;
277
+ clearPendingAction: (id) => void;
278
+ }
279
+ ```
280
+
281
+ ### 工具函数
282
+
283
+ ```typescript
284
+ import { resolveWindowTitle, findMenuItem, collectParentMenuKeys } from '@liuman/react-workspace';
285
+ ```
286
+
287
+ ### 类型定义
288
+
289
+ ```typescript
290
+ interface WindowConfig {
291
+ id: string;
292
+ type: string; // 自定义窗口类型
293
+ title: string;
294
+ minimized: boolean;
295
+ floating?: boolean;
296
+ floatingPosition?: { x, y, width, height };
297
+ props?: Record<string, unknown>;
298
+ }
299
+
300
+ interface SidebarMenuItem {
301
+ key: string;
302
+ label: ReactNode;
303
+ icon?: ReactNode;
304
+ windowType?: string; // 点击打开的窗口类型
305
+ action?: string; // 自定义操作标识
306
+ children?: SidebarMenuItem[];
307
+ props?: Record<string, unknown>;
308
+ }
309
+ ```
310
+
311
+ ## URL 状态格式
312
+
313
+ 启用 `syncToUrl` 后,窗口状态保存在 URL 参数中:
314
+
315
+ ```
316
+ /app/workspace?windows=[{"id":"...","type":"home","title":"首页"}]&active=window-id
317
+ ```
318
+
319
+ 浮动窗口的位置和最小化状态保存在 localStorage 中(避免 URL 过长)。
320
+
321
+ ## 窗口操作
322
+
323
+ | 操作 | 方式 |
324
+ |------|------|
325
+ | 打开窗口 | 点击侧边栏菜单 / `openWindow()` |
326
+ | 切换窗口 | 点击标签 / `switchWindow(id)` |
327
+ | 最小化 | 标签 `-` 按钮 / `toggleMinimize(id)` |
328
+ | 浮动 | 标签浮动按钮 / 拖动标签 / `floatWindow(id)` |
329
+ | 关闭 | 标签 `×` 按钮 / `closeWindow(id)` |
330
+ | 批量管理 | 标签栏 `...` 菜单 / `batchManage(action)` |
331
+
332
+ ## 开发
333
+
334
+ ```bash
335
+ cd packages/react-workspace
336
+ yarn install
337
+ yarn build
338
+ yarn type-check
339
+ ```
340
+
341
+ ## 发布到 GitHub
342
+
343
+ ### 第一步:创建 GitHub 仓库
344
+
345
+ 1. 登录 [GitHub](https://github.com/new)
346
+ 2. 仓库名建议:`react-workspace`
347
+ 3. 选择 **Public**
348
+ 4. **不要**勾选 "Add a README"(保持空仓库)
349
+ 5. 创建后复制仓库地址,例如:
350
+ - HTTPS: `https://github.com/mxyg/react-workspace.git`
351
+ - SSH: `git@github.com:mxyg/react-workspace.git`
352
+
353
+ ### 第二步:修改 package.json 元信息
354
+
355
+ 发布前把 `package.json` 里的占位地址改成你的:
356
+
357
+ ```json
358
+ {
359
+ "repository": {
360
+ "type": "git",
361
+ "url": "https://github.com/mxyg/react-workspace.git"
362
+ },
363
+ "homepage": "https://github.com/mxyg/react-workspace#readme",
364
+ "bugs": {
365
+ "url": "https://github.com/mxyg/react-workspace/issues"
366
+ }
367
+ }
368
+ ```
369
+
370
+ ### 第三步:执行发布脚本
371
+
372
+ 在本 monorepo 中:
373
+
374
+ ```bash
375
+ cd packages/react-workspace
376
+ chmod +x scripts/publish-to-git.sh
377
+ ./scripts/publish-to-git.sh https://github.com/mxyg/react-workspace.git
378
+ ```
379
+
380
+ 脚本会自动 `build` → `type-check` → 复制源码 → 推送到 GitHub。
381
+
382
+ 加 `--yes` 可跳过确认:
383
+
384
+ ```bash
385
+ ./scripts/publish-to-git.sh https://github.com/mxyg/react-workspace.git --yes
386
+ ```
387
+
388
+ ### 第四步:启用 GitHub Pages(必做,否则 Deploy 会 404)
389
+
390
+ 1. 打开 [Settings → Pages](https://github.com/mxyg/react-workspace/settings/pages)
391
+ 2. **Build and deployment** → **Source** 选择 **GitHub Actions**(不是 Deploy from a branch)
392
+ 3. 保存后,到 [Actions](https://github.com/mxyg/react-workspace/actions) → 选中失败的 **Deploy Demo** → **Re-run all jobs**
393
+
394
+ 若未执行第 2 步,会出现如下错误:
395
+
396
+ ```
397
+ Error: Failed to create deployment (status: 404)
398
+ Ensure GitHub Pages has been enabled
399
+ ```
400
+
401
+ ### 第五步:完善 GitHub 仓库
402
+
403
+ | 项目 | 建议 |
404
+ |------|------|
405
+ | Description | React IDE-style multi-window workspace component |
406
+ | Topics | `react` `workspace` `multi-window` `tabs` `floating-window` `ide` `antd` |
407
+ | About 网站 | 若发布 npm,填 npm 包地址 |
408
+
409
+ 推送后 GitHub Actions 会自动:
410
+ - **CI** — build + type-check
411
+ - **Deploy Demo** — 部署到 GitHub Pages(需在 Settings → Pages → Source 选 GitHub Actions)
412
+
413
+ Demo 地址:`https://mxyg.github.io/react-workspace/`
414
+
415
+ > 首次部署需在 Settings → Pages 将 Source 设为 **GitHub Actions**,然后 Re-run 工作流。
416
+
417
+ ### 后续更新
418
+
419
+ 修改代码后重新执行发布脚本即可。若远程已有历史,建议改用正常 git 流程:
420
+
421
+ ```bash
422
+ # 克隆独立仓库后
423
+ git remote add upstream /path/to/pms/packages/react-workspace # 或手动 copy 文件
424
+ git add -A && git commit -m "feat: xxx" && git push
425
+ ```
426
+
427
+ ---
428
+
429
+ ## 发布到 npm(可选)
430
+
431
+ ```bash
432
+ cd packages/react-workspace
433
+
434
+ # 1. 注册 npm 账号 https://www.npmjs.com/signup
435
+ npm login
436
+
437
+ # 2. package.json 包名为 @liuman/react-workspace(react-workspace 已被他人占用)
438
+
439
+ # 3. 发布(需已开启 2FA,并带 OTP)
440
+ yarn build
441
+ npm publish --access public --otp=你的6位验证码
442
+ ```
443
+
444
+ 安装方式:
445
+
446
+ ```bash
447
+ yarn add @liuman/react-workspace
448
+ ```
449
+
450
+ ---
451
+
452
+ ## 版本历史
453
+
454
+ ### v1.2.0
455
+ - 修复侧边栏 footer 遮挡菜单、loading 遮罩覆盖侧边栏等问题
456
+ - 优化默认 UI(标签高亮、菜单选中态)
457
+ - 新增 `theme` prop 与 antd token 映射工具
458
+ - 新增 `renderSidebar` 与 `react-workspace/antd` 可选集成
459
+ - Demo 改为 Ant Design 示例
460
+
461
+ ### v1.1.0
462
+ - 移除 antd 依赖,零 UI 框架
463
+ - 标签拖拽排序
464
+ - 键盘快捷键
465
+ - CSS 主题变量 + 暗色主题
466
+ - GitHub Pages Demo
467
+
468
+ ## License
469
+
470
+ MIT
package/dist/antd.d.ts ADDED
@@ -0,0 +1,84 @@
1
+ import { CSSProperties } from 'react';
2
+ import { default as default_2 } from 'react';
3
+ import { ReactNode } from 'react';
4
+
5
+ export declare const AntdWorkspaceSidebar: default_2.FC<AntdWorkspaceSidebarProps>;
6
+
7
+ export declare interface AntdWorkspaceSidebarProps {
8
+ menuItems: SidebarMenuEntry[];
9
+ onMenuClick: (windowType: string, props?: Record<string, unknown>) => void;
10
+ onAction?: (action: string) => void;
11
+ activeWindowType?: string;
12
+ header?: default_2.ReactNode;
13
+ footer?: default_2.ReactNode;
14
+ defaultOpenKeys?: string[];
15
+ siderWidth?: number;
16
+ theme?: 'light' | 'dark';
17
+ }
18
+
19
+ export declare function mapAntdTokenToCssVars(token: Parameters<typeof mapAntdTokenToWorkspaceTheme>[0]): CSSProperties;
20
+
21
+ /** 将 Ant Design token 映射为 Workspace CSS 变量(无需在库内 import antd) */
22
+ export declare function mapAntdTokenToWorkspaceTheme(token: {
23
+ colorPrimary?: string;
24
+ colorPrimaryHover?: string;
25
+ colorPrimaryBg?: string;
26
+ colorBgContainer?: string;
27
+ colorBgLayout?: string;
28
+ colorBgTextHover?: string;
29
+ colorFillAlter?: string;
30
+ colorBorder?: string;
31
+ colorBorderSecondary?: string;
32
+ colorText?: string;
33
+ colorTextSecondary?: string;
34
+ colorTextTertiary?: string;
35
+ borderRadius?: number;
36
+ fontSize?: number;
37
+ }): WorkspaceTheme;
38
+
39
+ /** 侧边栏分隔线 */
40
+ declare interface SidebarMenuDivider {
41
+ type: 'divider';
42
+ key?: string;
43
+ }
44
+
45
+ declare type SidebarMenuEntry = SidebarMenuItem | SidebarMenuDivider;
46
+
47
+ /** 侧边栏菜单项 */
48
+ declare interface SidebarMenuItem {
49
+ key: string;
50
+ label: ReactNode;
51
+ icon?: ReactNode;
52
+ /** 点击后打开的窗口类型 */
53
+ windowType?: string;
54
+ children?: SidebarMenuEntry[];
55
+ /** 自定义操作标识 */
56
+ action?: string;
57
+ /** 传递给窗口的额外属性 */
58
+ props?: Record<string, unknown>;
59
+ /** 是否禁用 */
60
+ disabled?: boolean;
61
+ }
62
+
63
+ /** 可覆盖的 Workspace 主题变量(对应 CSS --rw-* 变量) */
64
+ declare interface WorkspaceTheme {
65
+ colorPrimary?: string;
66
+ colorPrimaryHover?: string;
67
+ colorPrimaryBg?: string;
68
+ colorBg?: string;
69
+ colorBgSecondary?: string;
70
+ colorBgTertiary?: string;
71
+ colorBgHover?: string;
72
+ colorBgActive?: string;
73
+ colorBorder?: string;
74
+ colorBorderStrong?: string;
75
+ colorText?: string;
76
+ colorTextSecondary?: string;
77
+ colorTextMuted?: string;
78
+ sidebarWidth?: number;
79
+ tabHeight?: number;
80
+ radius?: number;
81
+ fontSize?: number;
82
+ }
83
+
84
+ export { }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 浮动窗口 - 无 antd 依赖
3
+ */
4
+ import React from 'react';
5
+ import type { WindowConfig, WindowPosition, FloatingWindowDefaults } from '../types';
6
+ import '../styles/floating-window.css';
7
+ export interface FloatingWindowProps {
8
+ window: WindowConfig;
9
+ children: React.ReactNode;
10
+ floatingDefaults?: FloatingWindowDefaults;
11
+ onUpdateFloatingPosition: (windowId: string, position: WindowPosition) => void;
12
+ onRestoreWindow: (windowId: string, insertIndex?: number) => void;
13
+ onCloseWindow: (windowId: string) => void;
14
+ onToggleMinimize: (windowId: string) => void;
15
+ onFocusWindow?: (windowId: string) => void;
16
+ }
17
+ export declare const FloatingWindow: React.FC<FloatingWindowProps>;
18
+ export default FloatingWindow;
19
+ //# sourceMappingURL=FloatingWindow.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 窗口容器 - 通用内容包装
3
+ */
4
+ import React from 'react';
5
+ import type { WindowConfig } from '../types';
6
+ import '../styles/window-container.css';
7
+ export interface WindowContainerProps {
8
+ window: WindowConfig;
9
+ active: boolean;
10
+ children: React.ReactNode;
11
+ }
12
+ export declare const WindowContainer: React.FC<WindowContainerProps>;
13
+ export default WindowContainer;
14
+ //# sourceMappingURL=WindowContainer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowContainer.d.ts","sourceRoot":"","sources":["../../src/components/WindowContainer.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,gCAAgC,CAAC;AAExC,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAQ1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 窗口管理器
3
+ */
4
+ import React from 'react';
5
+ import type { WindowConfig, WindowPosition, WindowRenderContext, BatchWindowAction, FloatingWindowDefaults } from '../types';
6
+ import '../styles/window-manager.css';
7
+ export interface WindowManagerProps {
8
+ workspaceId: string;
9
+ windows: WindowConfig[];
10
+ activeWindowId: string | null;
11
+ renderWindow: (window: WindowConfig, context: WindowRenderContext) => React.ReactNode;
12
+ onSwitchWindow: (windowId: string) => void;
13
+ onCloseWindow: (windowId: string) => void;
14
+ onToggleMinimize: (windowId: string) => void;
15
+ onBatchManage: (action: BatchWindowAction) => void;
16
+ onOpenWindow: (config: Omit<WindowConfig, 'id'>, props?: Record<string, unknown>) => void;
17
+ onFloatWindow?: (windowId: string, mousePosition?: {
18
+ x: number;
19
+ y: number;
20
+ }) => void;
21
+ onRestoreWindow?: (windowId: string, insertIndex?: number) => void;
22
+ onUpdateFloatingPosition?: (windowId: string, position: WindowPosition) => void;
23
+ onFocusWindow?: (windowId: string) => void;
24
+ onReorderWindows?: (fromIndex: number, toIndex: number) => void;
25
+ emptyDescription?: React.ReactNode;
26
+ floatingDefaults?: FloatingWindowDefaults;
27
+ }
28
+ export declare const WindowManager: React.FC<WindowManagerProps>;
29
+ export default WindowManager;
30
+ //# sourceMappingURL=WindowManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowManager.d.ts","sourceRoot":"","sources":["../../src/components/WindowManager.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAI7H,OAAO,8BAA8B,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,mBAAmB,KAAK,KAAK,CAAC,SAAS,CAAC;IACtF,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,aAAa,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACnD,YAAY,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAC1F,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACrF,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnE,wBAAwB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAChF,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;CAC3C;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsFtD,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 窗口标签栏 - 无 antd 依赖,支持拖拽排序与拖出浮动
3
+ */
4
+ import React from 'react';
5
+ import type { WindowConfig, BatchWindowAction } from '../types';
6
+ import '../styles/window-tabs.css';
7
+ export interface WindowTabsProps {
8
+ windows: WindowConfig[];
9
+ activeWindowId: string | null;
10
+ onSwitchWindow: (windowId: string) => void;
11
+ onCloseWindow: (windowId: string) => void;
12
+ onToggleMinimize: (windowId: string) => void;
13
+ onBatchManage: (action: BatchWindowAction) => void;
14
+ onFloatWindow?: (windowId: string, mousePosition?: {
15
+ x: number;
16
+ y: number;
17
+ }) => void;
18
+ onRestoreWindow?: (windowId: string, insertIndex?: number) => void;
19
+ onReorderWindows?: (fromIndex: number, toIndex: number) => void;
20
+ allWindows?: WindowConfig[];
21
+ }
22
+ export declare const WindowTabs: React.FC<WindowTabsProps>;
23
+ export default WindowTabs;
24
+ //# sourceMappingURL=WindowTabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowTabs.d.ts","sourceRoot":"","sources":["../../src/components/WindowTabs.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAmD,MAAM,OAAO,CAAC;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,2BAA2B,CAAC;AAEnC,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,aAAa,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACnD,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACrF,eAAe,CAAC,EAAE,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,CAyNhD,CAAC;AA+BF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Workspace 主组件
3
+ */
4
+ import React from 'react';
5
+ import type { WorkspaceProps, WorkspaceRef } from '../types';
6
+ import '../styles/theme.css';
7
+ import '../styles/workspace.css';
8
+ export declare const Workspace: React.ForwardRefExoticComponent<Omit<WorkspaceProps, "ref"> & React.RefAttributes<WorkspaceRef>>;
9
+ export default Workspace;
10
+ //# sourceMappingURL=Workspace.d.ts.map