@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.
- package/README.md +99 -48
- package/dist/Workspace-BBzK2L-Z.cjs +1 -0
- package/dist/Workspace-BD4jIdrk.js +1248 -0
- package/dist/antd.d.ts +193 -0
- package/dist/components/FloatingWindow.d.ts.map +1 -1
- package/dist/components/WindowTabs.d.ts.map +1 -1
- package/dist/components/Workspace.d.ts.map +1 -1
- package/dist/hooks/useWorkspace.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/integrations/AntdWorkspace.d.ts +26 -0
- package/dist/integrations/AntdWorkspace.d.ts.map +1 -0
- package/dist/integrations/antd.d.ts +2 -0
- package/dist/integrations/antd.d.ts.map +1 -1
- package/dist/react-workspace-antd.cjs +1 -1
- package/dist/react-workspace-antd.js +74 -42
- package/dist/react-workspace.cjs +1 -1
- package/dist/react-workspace.css +1 -1
- package/dist/react-workspace.js +28 -1140
- package/dist/types.d.ts +21 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/createWindowRenderer.d.ts +15 -0
- package/dist/utils/createWindowRenderer.d.ts.map +1 -0
- package/dist/utils/resolveDefaultWindow.d.ts +6 -0
- package/dist/utils/resolveDefaultWindow.d.ts.map +1 -0
- package/dist/utils/windowStorage.d.ts +6 -2
- package/dist/utils/windowStorage.d.ts.map +1 -1
- package/package.json +3 -4
- package/dist/hooks/useKeyboardShortcuts.d.ts +0 -14
- package/dist/hooks/useKeyboardShortcuts.d.ts.map +0 -1
- package/dist/theme-CzPgEJDm.js +0 -113
- package/dist/theme-DIsh66tX.cjs +0 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* react-workspace 类型定义
|
|
3
3
|
*/
|
|
4
|
-
import type { ReactNode, Dispatch, SetStateAction, CSSProperties, Ref } from 'react';
|
|
4
|
+
import type { ReactNode, Dispatch, SetStateAction, CSSProperties, Ref, ComponentType } from 'react';
|
|
5
5
|
import type { WorkspaceTheme } from './utils/theme';
|
|
6
6
|
/** 窗口位置和大小 */
|
|
7
7
|
export interface WindowPosition {
|
|
@@ -139,13 +139,30 @@ export interface WorkspaceSidebarRenderProps {
|
|
|
139
139
|
defaultOpenKeys?: string[];
|
|
140
140
|
siderWidth?: number;
|
|
141
141
|
}
|
|
142
|
+
/** 窗口面板组件接收的 props */
|
|
143
|
+
export interface WindowPanelProps {
|
|
144
|
+
window: WindowConfig;
|
|
145
|
+
ctx: WindowRenderContext;
|
|
146
|
+
}
|
|
147
|
+
/** 窗口类型 → 面板组件映射(开箱即用) */
|
|
148
|
+
export type WindowPanelComponent = ComponentType<WindowPanelProps>;
|
|
149
|
+
export type WorkspaceWindowsMap = Record<string, WindowPanelComponent>;
|
|
142
150
|
/** Workspace 组件 Props */
|
|
143
151
|
export interface WorkspaceProps {
|
|
144
|
-
|
|
152
|
+
/** 工作区唯一标识,用于 localStorage / URL 隔离,默认 `default` */
|
|
153
|
+
workspaceId?: string;
|
|
145
154
|
/** 侧边栏菜单项 */
|
|
146
155
|
menuItems: SidebarMenuEntry[];
|
|
147
|
-
/**
|
|
148
|
-
|
|
156
|
+
/**
|
|
157
|
+
* 渲染窗口内容(与 windows 二选一)
|
|
158
|
+
* 需要完全自定义渲染逻辑时使用
|
|
159
|
+
*/
|
|
160
|
+
renderWindow?: (window: WindowConfig, context: WindowRenderContext) => ReactNode;
|
|
161
|
+
/**
|
|
162
|
+
* 窗口类型 → 组件映射(与 renderWindow 二选一,推荐)
|
|
163
|
+
* @example windows={{ home: HomePage, settings: SettingsPage }}
|
|
164
|
+
*/
|
|
165
|
+
windows?: WorkspaceWindowsMap;
|
|
149
166
|
/** 侧边栏顶部区域(如项目切换器) */
|
|
150
167
|
sidebarHeader?: ReactNode;
|
|
151
168
|
/** 侧边栏底部区域(如用户信息) */
|
|
@@ -180,8 +197,6 @@ export interface WorkspaceProps {
|
|
|
180
197
|
siderWidth?: number;
|
|
181
198
|
/** 内容区背景色 */
|
|
182
199
|
contentBackground?: string;
|
|
183
|
-
/** 是否启用快捷键 Ctrl+W / Ctrl+Tab */
|
|
184
|
-
enableKeyboardShortcuts?: boolean;
|
|
185
200
|
/** 主题 class,如 rw-theme-dark */
|
|
186
201
|
themeClassName?: string;
|
|
187
202
|
/** 通过 props 覆盖 CSS 变量主题(可与 antd token 映射配合) */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,cAAc;AACd,MAAM,WAAW,cAAc;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAe;AACf,MAAM,WAAW,sBAAsB;IACrC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,WAAW;AACX,MAAM,WAAW,YAAY;I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G,IAAI,KAAK,IAAI,CAAC;IACnF,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IACtC,aAAa;IACb,GAAG,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IACxB,YAAY;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,+BAA+B;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,oCAAoC;IACpC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,SAAS,CAAC;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { WindowConfig, WindowPanelComponent, WindowRenderContext, WorkspaceWindowsMap } from '../types';
|
|
3
|
+
export interface CreateWindowRendererOptions {
|
|
4
|
+
/** 未匹配到窗口类型时的兜底组件 */
|
|
5
|
+
fallback?: WindowPanelComponent;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 将 windows 映射表转为 renderWindow,开箱即用:
|
|
9
|
+
*
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <Workspace menuItems={menu} windows={{ home: HomePage, settings: SettingsPage }} />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function createWindowRenderer(windows: WorkspaceWindowsMap, options?: CreateWindowRendererOptions): (window: WindowConfig, ctx: WindowRenderContext) => ReactNode;
|
|
15
|
+
//# sourceMappingURL=createWindowRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createWindowRenderer.d.ts","sourceRoot":"","sources":["../../src/utils/createWindowRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE7G,MAAM,WAAW,2BAA2B;IAC1C,qBAAqB;IACrB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,2BAA2B,GACpC,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,mBAAmB,KAAK,SAAS,CAQ/D"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DefaultWindowConfig, SidebarMenuEntry, SidebarMenuItem } from '../types';
|
|
2
|
+
/** 从菜单中取第一个带 windowType 的项 */
|
|
3
|
+
export declare function findFirstMenuItemWithWindowType(items: SidebarMenuEntry[]): SidebarMenuItem | null;
|
|
4
|
+
/** 根据菜单自动推断默认窗口,也可手动覆盖 */
|
|
5
|
+
export declare function resolveDefaultWindow(menuItems: SidebarMenuEntry[], override?: DefaultWindowConfig): DefaultWindowConfig;
|
|
6
|
+
//# sourceMappingURL=resolveDefaultWindow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveDefaultWindow.d.ts","sourceRoot":"","sources":["../../src/utils/resolveDefaultWindow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAOvF,8BAA8B;AAC9B,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,eAAe,GAAG,IAAI,CAWjG;AAED,0BAA0B;AAC1B,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,gBAAgB,EAAE,EAC7B,QAAQ,CAAC,EAAE,mBAAmB,GAC7B,mBAAmB,CAUrB"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { WindowPosition } from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export interface FixWindowPositionOptions {
|
|
3
|
+
minWidth?: number;
|
|
4
|
+
minHeight?: number;
|
|
5
|
+
}
|
|
6
|
+
/** 检测并修复窗口位置与尺寸,确保窗口完整落在视口内 */
|
|
7
|
+
export declare function fixWindowPosition(position: WindowPosition, options?: FixWindowPositionOptions): WindowPosition;
|
|
4
8
|
export interface WindowState {
|
|
5
9
|
position?: WindowPosition;
|
|
6
10
|
minimized?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windowStorage.d.ts","sourceRoot":"","sources":["../../src/utils/windowStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C,
|
|
1
|
+
{"version":3,"file":"windowStorage.d.ts","sourceRoot":"","sources":["../../src/utils/windowStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,+BAA+B;AAC/B,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,wBAAwB,GACjC,cAAc,CAmBhB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,GAClB,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CA4C7B;AAED,wBAAgB,wBAAwB,CACtC,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,WAAW,GACjB,IAAI,CASN;AAED,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,IAAI,CAsCN;AAED,qBAAqB;AACrB,wBAAgB,sBAAsB,CACpC,OAAO,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EACvC,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,IAAI,CAsBf"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liuman/react-workspace",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Zero-dependency React IDE-like multi-window workspace with tabs, floating windows,
|
|
3
|
+
"version": "1.3.1",
|
|
4
|
+
"description": "Zero-dependency React IDE-like multi-window workspace with tabs, floating windows, theming, and optional Ant Design integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/react-workspace.cjs",
|
|
7
7
|
"module": "./dist/react-workspace.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"build:demo": "vite build --config demo/vite.config.ts",
|
|
33
33
|
"dev:demo": "vite --config demo/vite.config.ts",
|
|
34
34
|
"type-check": "tsc --noEmit",
|
|
35
|
-
"prepublishOnly": "
|
|
35
|
+
"prepublishOnly": "npm run build"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|
|
38
38
|
"react",
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"tabs",
|
|
42
42
|
"floating-window",
|
|
43
43
|
"ide",
|
|
44
|
-
"keyboard-shortcuts",
|
|
45
44
|
"zero-dependencies"
|
|
46
45
|
],
|
|
47
46
|
"license": "MIT",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface KeyboardShortcutsOptions {
|
|
2
|
-
enabled?: boolean;
|
|
3
|
-
windows: {
|
|
4
|
-
id: string;
|
|
5
|
-
minimized?: boolean;
|
|
6
|
-
floating?: boolean;
|
|
7
|
-
}[];
|
|
8
|
-
activeWindowId: string | null;
|
|
9
|
-
onSwitchWindow: (id: string) => void;
|
|
10
|
-
onCloseWindow: (id: string) => void;
|
|
11
|
-
}
|
|
12
|
-
/** IDE 快捷键:Ctrl/Cmd+W 关闭,Ctrl/Cmd+Tab 切换 */
|
|
13
|
-
export declare function useKeyboardShortcuts(options: KeyboardShortcutsOptions): void;
|
|
14
|
-
//# sourceMappingURL=useKeyboardShortcuts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useKeyboardShortcuts.d.ts","sourceRoot":"","sources":["../../src/hooks/useKeyboardShortcuts.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IACnE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,4CAA4C;AAC5C,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,wBAAwB,QA0CrE"}
|
package/dist/theme-CzPgEJDm.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
function a(r, c) {
|
|
2
|
-
for (const e of r) {
|
|
3
|
-
if ("type" in e && e.type === "divider") continue;
|
|
4
|
-
const o = e;
|
|
5
|
-
if (o.key === c) return o;
|
|
6
|
-
if (o.children) {
|
|
7
|
-
const t = a(o.children, c);
|
|
8
|
-
if (t) return t;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
function f(r, c, e) {
|
|
14
|
-
const o = (t) => {
|
|
15
|
-
for (const n of t) {
|
|
16
|
-
if ("type" in n && n.type === "divider") continue;
|
|
17
|
-
const i = n;
|
|
18
|
-
if (i.windowType === c)
|
|
19
|
-
return typeof i.label == "string" ? i.label : i.key;
|
|
20
|
-
if (i.children) {
|
|
21
|
-
const l = o(i.children);
|
|
22
|
-
if (l) return l;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return null;
|
|
26
|
-
};
|
|
27
|
-
return o(r) ?? e ?? c;
|
|
28
|
-
}
|
|
29
|
-
function d(r, c) {
|
|
30
|
-
for (const e of r) {
|
|
31
|
-
if ("type" in e && e.type === "divider") continue;
|
|
32
|
-
const o = e;
|
|
33
|
-
if (o.windowType === c) return o.key;
|
|
34
|
-
if (o.children) {
|
|
35
|
-
const t = d(o.children, c);
|
|
36
|
-
if (t) return t;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
function g(r) {
|
|
42
|
-
const c = [];
|
|
43
|
-
for (const e of r) {
|
|
44
|
-
if ("type" in e && e.type === "divider") continue;
|
|
45
|
-
const o = e;
|
|
46
|
-
o.children?.length && c.push(o.key);
|
|
47
|
-
}
|
|
48
|
-
return c;
|
|
49
|
-
}
|
|
50
|
-
function m(r) {
|
|
51
|
-
return typeof r == "string" || typeof r == "number" ? String(r) : "";
|
|
52
|
-
}
|
|
53
|
-
const s = {
|
|
54
|
-
colorPrimary: "--rw-color-primary",
|
|
55
|
-
colorPrimaryHover: "--rw-color-primary-hover",
|
|
56
|
-
colorPrimaryBg: "--rw-color-primary-bg",
|
|
57
|
-
colorBg: "--rw-color-bg",
|
|
58
|
-
colorBgSecondary: "--rw-color-bg-secondary",
|
|
59
|
-
colorBgTertiary: "--rw-color-bg-tertiary",
|
|
60
|
-
colorBgHover: "--rw-color-bg-hover",
|
|
61
|
-
colorBgActive: "--rw-color-bg-active",
|
|
62
|
-
colorBorder: "--rw-color-border",
|
|
63
|
-
colorBorderStrong: "--rw-color-border-strong",
|
|
64
|
-
colorText: "--rw-color-text",
|
|
65
|
-
colorTextSecondary: "--rw-color-text-secondary",
|
|
66
|
-
colorTextMuted: "--rw-color-text-muted",
|
|
67
|
-
sidebarWidth: "--rw-sidebar-width",
|
|
68
|
-
tabHeight: "--rw-tab-height",
|
|
69
|
-
radius: "--rw-radius",
|
|
70
|
-
fontSize: "--rw-font-size"
|
|
71
|
-
};
|
|
72
|
-
function u(r) {
|
|
73
|
-
const c = {};
|
|
74
|
-
return Object.keys(r).forEach((e) => {
|
|
75
|
-
const o = r[e];
|
|
76
|
-
if (o !== void 0) {
|
|
77
|
-
const t = s[e];
|
|
78
|
-
c[t] = typeof o == "number" ? `${o}px` : o;
|
|
79
|
-
}
|
|
80
|
-
}), c;
|
|
81
|
-
}
|
|
82
|
-
function y(r) {
|
|
83
|
-
return {
|
|
84
|
-
colorPrimary: r.colorPrimary,
|
|
85
|
-
colorPrimaryHover: r.colorPrimaryHover,
|
|
86
|
-
colorPrimaryBg: r.colorPrimaryBg,
|
|
87
|
-
colorBg: r.colorBgContainer,
|
|
88
|
-
colorBgSecondary: r.colorFillAlter ?? r.colorBgContainer,
|
|
89
|
-
colorBgTertiary: r.colorBgLayout,
|
|
90
|
-
colorBgHover: r.colorBgTextHover,
|
|
91
|
-
colorBgActive: r.colorPrimaryBg,
|
|
92
|
-
colorBorder: r.colorBorder,
|
|
93
|
-
colorBorderStrong: r.colorBorderSecondary ?? r.colorBorder,
|
|
94
|
-
colorText: r.colorText,
|
|
95
|
-
colorTextSecondary: r.colorTextSecondary,
|
|
96
|
-
colorTextMuted: r.colorTextTertiary,
|
|
97
|
-
radius: r.borderRadius,
|
|
98
|
-
fontSize: r.fontSize
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function B(r) {
|
|
102
|
-
return u(y(r));
|
|
103
|
-
}
|
|
104
|
-
export {
|
|
105
|
-
a,
|
|
106
|
-
y as b,
|
|
107
|
-
g as c,
|
|
108
|
-
d as f,
|
|
109
|
-
m as l,
|
|
110
|
-
B as m,
|
|
111
|
-
f as r,
|
|
112
|
-
u as t
|
|
113
|
-
};
|
package/dist/theme-DIsh66tX.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function d(r,t){for(const e of r){if("type"in e&&e.type==="divider")continue;const o=e;if(o.key===t)return o;if(o.children){const n=d(o.children,t);if(n)return n}}return null}function y(r,t,e){const o=n=>{for(const i of n){if("type"in i&&i.type==="divider")continue;const c=i;if(c.windowType===t)return typeof c.label=="string"?c.label:c.key;if(c.children){const l=o(c.children);if(l)return l}}return null};return o(r)??e??t}function s(r,t){for(const e of r){if("type"in e&&e.type==="divider")continue;const o=e;if(o.windowType===t)return o.key;if(o.children){const n=s(o.children,t);if(n)return n}}return null}function f(r){const t=[];for(const e of r){if("type"in e&&e.type==="divider")continue;const o=e;o.children?.length&&t.push(o.key)}return t}function m(r){return typeof r=="string"||typeof r=="number"?String(r):""}const g={colorPrimary:"--rw-color-primary",colorPrimaryHover:"--rw-color-primary-hover",colorPrimaryBg:"--rw-color-primary-bg",colorBg:"--rw-color-bg",colorBgSecondary:"--rw-color-bg-secondary",colorBgTertiary:"--rw-color-bg-tertiary",colorBgHover:"--rw-color-bg-hover",colorBgActive:"--rw-color-bg-active",colorBorder:"--rw-color-border",colorBorderStrong:"--rw-color-border-strong",colorText:"--rw-color-text",colorTextSecondary:"--rw-color-text-secondary",colorTextMuted:"--rw-color-text-muted",sidebarWidth:"--rw-sidebar-width",tabHeight:"--rw-tab-height",radius:"--rw-radius",fontSize:"--rw-font-size"};function u(r){const t={};return Object.keys(r).forEach(e=>{const o=r[e];if(o!==void 0){const n=g[e];t[n]=typeof o=="number"?`${o}px`:o}}),t}function a(r){return{colorPrimary:r.colorPrimary,colorPrimaryHover:r.colorPrimaryHover,colorPrimaryBg:r.colorPrimaryBg,colorBg:r.colorBgContainer,colorBgSecondary:r.colorFillAlter??r.colorBgContainer,colorBgTertiary:r.colorBgLayout,colorBgHover:r.colorBgTextHover,colorBgActive:r.colorPrimaryBg,colorBorder:r.colorBorder,colorBorderStrong:r.colorBorderSecondary??r.colorBorder,colorText:r.colorText,colorTextSecondary:r.colorTextSecondary,colorTextMuted:r.colorTextTertiary,radius:r.borderRadius,fontSize:r.fontSize}}function T(r){return u(a(r))}exports.collectParentMenuKeys=f;exports.findMenuItem=d;exports.findMenuKeyByWindowType=s;exports.labelToString=m;exports.mapAntdTokenToCssVars=T;exports.mapAntdTokenToWorkspaceTheme=a;exports.resolveWindowTitle=y;exports.themeToCssVars=u;
|