@spacego/fe-components 0.0.1-alpha.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 (113) hide show
  1. package/README.md +37 -0
  2. package/lib/assets/svg/chrome-bg-after.svg.js +4 -0
  3. package/lib/assets/svg/chrome-bg-before.svg.js +4 -0
  4. package/lib/assets/svg/icon-arrows-right.svg.js +4 -0
  5. package/lib/assets/svg/icon-bell.svg.js +4 -0
  6. package/lib/assets/svg/icon-custom.svg.js +4 -0
  7. package/lib/assets/svg/icon-sun-moon.svg.js +4 -0
  8. package/lib/assets/svg/icon-system.svg.js +4 -0
  9. package/lib/assets/svg/login-view.svg.js +4 -0
  10. package/lib/config/constants.js +10 -0
  11. package/lib/config/theme.js +8 -0
  12. package/lib/fe-layouts/auth-layout/index.js +95 -0
  13. package/lib/fe-layouts/basics-layout/components/basics-layout/header.js +102 -0
  14. package/lib/fe-layouts/basics-layout/components/basics-layout/setting-custom-color.js +34 -0
  15. package/lib/fe-layouts/basics-layout/components/basics-layout/setting-drawer.js +118 -0
  16. package/lib/fe-layouts/basics-layout/components/basics-layout/sidebar.js +60 -0
  17. package/lib/fe-layouts/basics-layout/components/basics-layout/tabs.js +60 -0
  18. package/lib/fe-layouts/basics-layout/components/utils/index.js +72 -0
  19. package/lib/fe-layouts/basics-layout/index.js +98 -0
  20. package/lib/fe-layouts/blank-layout/index.js +8 -0
  21. package/lib/fe-layouts/context/context.js +6 -0
  22. package/lib/fe-layouts/context/global-context.provider.js +53 -0
  23. package/lib/fe-layouts/layout.js +49 -0
  24. package/lib/hooks/use-auth.hook.js +23 -0
  25. package/lib/index.css +1 -0
  26. package/lib/index.js +48 -0
  27. package/lib/router/index.js +43 -0
  28. package/lib/router/permission.js +43 -0
  29. package/lib/router/routes.js +57 -0
  30. package/lib/router/utils.js +105 -0
  31. package/lib/store/modules/layout-config.store.js +217 -0
  32. package/lib/store/modules/theme.store.js +60 -0
  33. package/lib/types/config/constants.d.ts +9 -0
  34. package/lib/types/config/index.d.ts +2 -0
  35. package/lib/types/config/theme.d.ts +7 -0
  36. package/lib/types/fe-layouts/auth-layout/index.d.ts +1 -0
  37. package/lib/types/fe-layouts/basics-layout/components/basics-layout/header.d.ts +7 -0
  38. package/lib/types/fe-layouts/basics-layout/components/basics-layout/setting-custom-color.d.ts +3 -0
  39. package/lib/types/fe-layouts/basics-layout/components/basics-layout/setting-drawer.d.ts +6 -0
  40. package/lib/types/fe-layouts/basics-layout/components/basics-layout/sidebar.d.ts +11 -0
  41. package/lib/types/fe-layouts/basics-layout/components/basics-layout/tabs.d.ts +9 -0
  42. package/lib/types/fe-layouts/basics-layout/components/utils/index.d.ts +41 -0
  43. package/lib/types/fe-layouts/basics-layout/index.d.ts +1 -0
  44. package/lib/types/fe-layouts/blank-layout/index.d.ts +1 -0
  45. package/lib/types/fe-layouts/context/context.d.ts +7 -0
  46. package/lib/types/fe-layouts/context/global-context.provider.d.ts +2 -0
  47. package/lib/types/fe-layouts/context/index.d.ts +3 -0
  48. package/lib/types/fe-layouts/index.d.ts +6 -0
  49. package/lib/types/fe-layouts/layout.d.ts +7 -0
  50. package/lib/types/hooks/index.d.ts +1 -0
  51. package/lib/types/hooks/use-auth.hook.d.ts +8 -0
  52. package/lib/types/index.d.ts +10 -0
  53. package/lib/types/router/index.d.ts +40 -0
  54. package/lib/types/router/permission.d.ts +23 -0
  55. package/lib/types/router/routes.d.ts +11 -0
  56. package/lib/types/router/utils.d.ts +56 -0
  57. package/lib/types/store/index.d.ts +2 -0
  58. package/lib/types/store/modules/layout-config.store.d.ts +612 -0
  59. package/lib/types/store/modules/theme.store.d.ts +186 -0
  60. package/lib/types/utils/icon.d.ts +14 -0
  61. package/lib/types/utils/index.d.ts +2 -0
  62. package/lib/types/utils/theme.d.ts +43 -0
  63. package/lib/utils/icon.js +13 -0
  64. package/lib/utils/theme.js +100 -0
  65. package/package.json +60 -0
  66. package/src/assets/styles/animate.css +62 -0
  67. package/src/assets/styles/index.css +49 -0
  68. package/src/assets/svg/chrome-bg-after.svg +1 -0
  69. package/src/assets/svg/chrome-bg-before.svg +1 -0
  70. package/src/assets/svg/icon-arrows-right.svg +1 -0
  71. package/src/assets/svg/icon-bell.svg +1 -0
  72. package/src/assets/svg/icon-custom.svg +1 -0
  73. package/src/assets/svg/icon-sun-moon.svg +1 -0
  74. package/src/assets/svg/icon-system.svg +1 -0
  75. package/src/assets/svg/loading.svg +13 -0
  76. package/src/assets/svg/login-view.svg +193 -0
  77. package/src/config/constants.ts +19 -0
  78. package/src/config/index.ts +2 -0
  79. package/src/config/theme.ts +20 -0
  80. package/src/fe-layouts/auth-layout/index.scss +34 -0
  81. package/src/fe-layouts/auth-layout/index.tsx +121 -0
  82. package/src/fe-layouts/basics-layout/components/basics-layout/header.tsx +148 -0
  83. package/src/fe-layouts/basics-layout/components/basics-layout/setting-custom-color.tsx +52 -0
  84. package/src/fe-layouts/basics-layout/components/basics-layout/setting-drawer.tsx +165 -0
  85. package/src/fe-layouts/basics-layout/components/basics-layout/sidebar.tsx +88 -0
  86. package/src/fe-layouts/basics-layout/components/basics-layout/tabs.tsx +94 -0
  87. package/src/fe-layouts/basics-layout/components/utils/index.ts +142 -0
  88. package/src/fe-layouts/basics-layout/index.scss +110 -0
  89. package/src/fe-layouts/basics-layout/index.tsx +207 -0
  90. package/src/fe-layouts/blank-layout/index.tsx +12 -0
  91. package/src/fe-layouts/context/context.ts +11 -0
  92. package/src/fe-layouts/context/global-context.d.ts +241 -0
  93. package/src/fe-layouts/context/global-context.provider.tsx +81 -0
  94. package/src/fe-layouts/context/index.ts +10 -0
  95. package/src/fe-layouts/index.ts +13 -0
  96. package/src/fe-layouts/layout.tsx +74 -0
  97. package/src/hooks/index.ts +1 -0
  98. package/src/hooks/use-auth.hook.ts +54 -0
  99. package/src/index.ts +21 -0
  100. package/src/router/index.ts +110 -0
  101. package/src/router/permission.tsx +134 -0
  102. package/src/router/routes.tsx +94 -0
  103. package/src/router/utils.ts +283 -0
  104. package/src/store/index.ts +9 -0
  105. package/src/store/modules/layout-config.store.ts +343 -0
  106. package/src/store/modules/theme.store.ts +99 -0
  107. package/src/typings/index.d.ts +59 -0
  108. package/src/typings/shims-axios.d.ts +38 -0
  109. package/src/utils/icon.tsx +32 -0
  110. package/src/utils/index.ts +9 -0
  111. package/src/utils/theme.ts +219 -0
  112. package/tsconfig.json +28 -0
  113. package/vite.config.ts +85 -0
@@ -0,0 +1,186 @@
1
+ import { TUpdateStore } from '../../typings';
2
+ export type ThemeMode = 'light' | 'dark' | 'system';
3
+ type State = {
4
+ theme: ThemeMode;
5
+ themeColor: string;
6
+ /** 是否是自定义主题色 */
7
+ isCustomThemeColor: boolean;
8
+ };
9
+ type Actions = {
10
+ SET_THEME: (theme: ThemeMode) => void;
11
+ TOGGLE_THEME: () => void;
12
+ SET_THEME_COLOR: (color: string) => void;
13
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
14
+ SET_STATE: (data: {
15
+ key: keyof State;
16
+ val: State[keyof State];
17
+ }) => void;
18
+ };
19
+ type Update = TUpdateStore<State>;
20
+ type ThemeStore = State & Actions;
21
+ export declare const useThemeStore: import('zustand').UseBoundStore<Omit<Omit<import('zustand').StoreApi<Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
22
+ SET_STATE: (data: Update) => unknown;
23
+ SET_THEME: (theme: ThemeMode) => void;
24
+ TOGGLE_THEME: () => void;
25
+ SET_THEME_COLOR: (color: string) => void;
26
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
27
+ }>, "setState" | "devtools"> & {
28
+ setState(partial: (Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
29
+ SET_STATE: (data: Update) => unknown;
30
+ SET_THEME: (theme: ThemeMode) => void;
31
+ TOGGLE_THEME: () => void;
32
+ SET_THEME_COLOR: (color: string) => void;
33
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
34
+ }) | Partial<Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
35
+ SET_STATE: (data: Update) => unknown;
36
+ SET_THEME: (theme: ThemeMode) => void;
37
+ TOGGLE_THEME: () => void;
38
+ SET_THEME_COLOR: (color: string) => void;
39
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
40
+ }> | ((state: Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
41
+ SET_STATE: (data: Update) => unknown;
42
+ SET_THEME: (theme: ThemeMode) => void;
43
+ TOGGLE_THEME: () => void;
44
+ SET_THEME_COLOR: (color: string) => void;
45
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
46
+ }) => (Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
47
+ SET_STATE: (data: Update) => unknown;
48
+ SET_THEME: (theme: ThemeMode) => void;
49
+ TOGGLE_THEME: () => void;
50
+ SET_THEME_COLOR: (color: string) => void;
51
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
52
+ }) | Partial<Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
53
+ SET_STATE: (data: Update) => unknown;
54
+ SET_THEME: (theme: ThemeMode) => void;
55
+ TOGGLE_THEME: () => void;
56
+ SET_THEME_COLOR: (color: string) => void;
57
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
58
+ }>), replace?: false | undefined, action?: (string | {
59
+ [x: string]: unknown;
60
+ [x: number]: unknown;
61
+ [x: symbol]: unknown;
62
+ type: string;
63
+ }) | undefined): void;
64
+ setState(state: (Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
65
+ SET_STATE: (data: Update) => unknown;
66
+ SET_THEME: (theme: ThemeMode) => void;
67
+ TOGGLE_THEME: () => void;
68
+ SET_THEME_COLOR: (color: string) => void;
69
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
70
+ }) | ((state: Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
71
+ SET_STATE: (data: Update) => unknown;
72
+ SET_THEME: (theme: ThemeMode) => void;
73
+ TOGGLE_THEME: () => void;
74
+ SET_THEME_COLOR: (color: string) => void;
75
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
76
+ }) => Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
77
+ SET_STATE: (data: Update) => unknown;
78
+ SET_THEME: (theme: ThemeMode) => void;
79
+ TOGGLE_THEME: () => void;
80
+ SET_THEME_COLOR: (color: string) => void;
81
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
82
+ }), replace: true, action?: (string | {
83
+ [x: string]: unknown;
84
+ [x: number]: unknown;
85
+ [x: symbol]: unknown;
86
+ type: string;
87
+ }) | undefined): void;
88
+ devtools: {
89
+ cleanup: () => void;
90
+ };
91
+ }, "setState" | "persist"> & {
92
+ setState(partial: (Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
93
+ SET_STATE: (data: Update) => unknown;
94
+ SET_THEME: (theme: ThemeMode) => void;
95
+ TOGGLE_THEME: () => void;
96
+ SET_THEME_COLOR: (color: string) => void;
97
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
98
+ }) | Partial<Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
99
+ SET_STATE: (data: Update) => unknown;
100
+ SET_THEME: (theme: ThemeMode) => void;
101
+ TOGGLE_THEME: () => void;
102
+ SET_THEME_COLOR: (color: string) => void;
103
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
104
+ }> | ((state: Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
105
+ SET_STATE: (data: Update) => unknown;
106
+ SET_THEME: (theme: ThemeMode) => void;
107
+ TOGGLE_THEME: () => void;
108
+ SET_THEME_COLOR: (color: string) => void;
109
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
110
+ }) => (Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
111
+ SET_STATE: (data: Update) => unknown;
112
+ SET_THEME: (theme: ThemeMode) => void;
113
+ TOGGLE_THEME: () => void;
114
+ SET_THEME_COLOR: (color: string) => void;
115
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
116
+ }) | Partial<Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
117
+ SET_STATE: (data: Update) => unknown;
118
+ SET_THEME: (theme: ThemeMode) => void;
119
+ TOGGLE_THEME: () => void;
120
+ SET_THEME_COLOR: (color: string) => void;
121
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
122
+ }>), replace?: false | undefined, action?: (string | {
123
+ [x: string]: unknown;
124
+ [x: number]: unknown;
125
+ [x: symbol]: unknown;
126
+ type: string;
127
+ }) | undefined): unknown;
128
+ setState(state: (Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
129
+ SET_STATE: (data: Update) => unknown;
130
+ SET_THEME: (theme: ThemeMode) => void;
131
+ TOGGLE_THEME: () => void;
132
+ SET_THEME_COLOR: (color: string) => void;
133
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
134
+ }) | ((state: Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
135
+ SET_STATE: (data: Update) => unknown;
136
+ SET_THEME: (theme: ThemeMode) => void;
137
+ TOGGLE_THEME: () => void;
138
+ SET_THEME_COLOR: (color: string) => void;
139
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
140
+ }) => Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
141
+ SET_STATE: (data: Update) => unknown;
142
+ SET_THEME: (theme: ThemeMode) => void;
143
+ TOGGLE_THEME: () => void;
144
+ SET_THEME_COLOR: (color: string) => void;
145
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
146
+ }), replace: true, action?: (string | {
147
+ [x: string]: unknown;
148
+ [x: number]: unknown;
149
+ [x: symbol]: unknown;
150
+ type: string;
151
+ }) | undefined): unknown;
152
+ persist: {
153
+ setOptions: (options: Partial<import('zustand/middleware').PersistOptions<Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
154
+ SET_STATE: (data: Update) => unknown;
155
+ SET_THEME: (theme: ThemeMode) => void;
156
+ TOGGLE_THEME: () => void;
157
+ SET_THEME_COLOR: (color: string) => void;
158
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
159
+ }, unknown, unknown>>) => void;
160
+ clearStorage: () => void;
161
+ rehydrate: () => Promise<void> | void;
162
+ hasHydrated: () => boolean;
163
+ onHydrate: (fn: (state: Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
164
+ SET_STATE: (data: Update) => unknown;
165
+ SET_THEME: (theme: ThemeMode) => void;
166
+ TOGGLE_THEME: () => void;
167
+ SET_THEME_COLOR: (color: string) => void;
168
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
169
+ }) => void) => () => void;
170
+ onFinishHydration: (fn: (state: Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
171
+ SET_STATE: (data: Update) => unknown;
172
+ SET_THEME: (theme: ThemeMode) => void;
173
+ TOGGLE_THEME: () => void;
174
+ SET_THEME_COLOR: (color: string) => void;
175
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
176
+ }) => void) => () => void;
177
+ getOptions: () => Partial<import('zustand/middleware').PersistOptions<Omit<ThemeStore, "SET_STATE" | "SET_THEME" | "TOGGLE_THEME" | "SET_THEME_COLOR" | "SET_IS_CUSTOM_THEME_COLOR"> & {
178
+ SET_STATE: (data: Update) => unknown;
179
+ SET_THEME: (theme: ThemeMode) => void;
180
+ TOGGLE_THEME: () => void;
181
+ SET_THEME_COLOR: (color: string) => void;
182
+ SET_IS_CUSTOM_THEME_COLOR: (isCustom: boolean) => void;
183
+ }, unknown, unknown>>;
184
+ };
185
+ }>;
186
+ export {};
@@ -0,0 +1,14 @@
1
+ import { ComponentType } from 'react';
2
+ /**
3
+ * 根据图标名称获取图标组件
4
+ * @param iconName 图标名称,如 'HomeOutlined'
5
+ * @returns 图标组件
6
+ */
7
+ export declare function getIcon(iconName?: string): ComponentType<any> | null;
8
+ /**
9
+ * 渲染图标
10
+ * @param iconName 图标名称
11
+ * @param props 图标属性
12
+ * @returns JSX元素
13
+ */
14
+ export declare function renderIcon(iconName?: string, props?: any): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,2 @@
1
+ export * from './icon';
2
+ export * from './theme';
@@ -0,0 +1,43 @@
1
+ import { ThemeMode } from '../store';
2
+ /**
3
+ * 获取当前主题(实际显示的 light/dark)
4
+ * @param mode 主题模式 (light/dark/system)
5
+ * @returns 实际主题 (light/dark)
6
+ */
7
+ export declare function getRealTheme(mode: ThemeMode): 'light' | 'dark';
8
+ /**
9
+ * 应用主题到 DOM
10
+ * @param theme 主题模式
11
+ */
12
+ export declare function applyTheme(theme: ThemeMode): void;
13
+ /**
14
+ * 获取当前主题
15
+ * @returns 当前主题模式
16
+ */
17
+ export declare function getTheme(): ThemeMode;
18
+ /**
19
+ * 监听系统主题变化
20
+ */
21
+ export declare function listenSystemTheme(): void;
22
+ /**
23
+ * 初始化主题
24
+ */
25
+ export declare function initTheme(): ThemeMode;
26
+ /**
27
+ * 切换主题
28
+ * @param currentTheme 当前主题
29
+ * @returns 新主题
30
+ */
31
+ export declare function toggleTheme(currentTheme: ThemeMode): ThemeMode;
32
+ /**
33
+ * 应用主题色到 DOM
34
+ * @param color 主题色
35
+ */
36
+ export declare function applyThemeColor(color: string): void;
37
+ /**
38
+ * 从指定位置开始应用主题过渡效果
39
+ * @param theme 新主题模式
40
+ * @param x 点击位置的 x 坐标
41
+ * @param y 点击位置的 y 坐标
42
+ */
43
+ export declare function applyThemeWithTransition(theme: ThemeMode, x: number, y: number): Promise<void>;
@@ -0,0 +1,13 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import * as c from "@ant-design/icons";
3
+ function e(n) {
4
+ return n && c[n] || null;
5
+ }
6
+ function l(n, o) {
7
+ const t = e(n);
8
+ return t ? /* @__PURE__ */ r(t, { ...o }) : null;
9
+ }
10
+ export {
11
+ e as getIcon,
12
+ l as renderIcon
13
+ };
@@ -0,0 +1,100 @@
1
+ import "../store/modules/layout-config.store.js";
2
+ import { useThemeStore as u } from "../store/modules/theme.store.js";
3
+ const p = "data-theme";
4
+ function w(e) {
5
+ return e === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : e;
6
+ }
7
+ function r(e) {
8
+ const t = document.documentElement, n = w(e);
9
+ t.setAttribute(p, n), t.classList.toggle("dark", n === "dark");
10
+ }
11
+ function T() {
12
+ const t = document.documentElement.getAttribute(p);
13
+ if (t && (t === "light" || t === "dark"))
14
+ return t;
15
+ const { theme: n } = u.getState();
16
+ return n && (n === "light" || n === "dark") ? n : window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
17
+ }
18
+ function k() {
19
+ const e = window.matchMedia("(prefers-color-scheme: dark)"), t = (n) => {
20
+ const { theme: a } = u.getState();
21
+ if (a === "system") {
22
+ const s = n.matches ? "dark" : "light";
23
+ document.documentElement.classList.toggle("dark", s === "dark");
24
+ }
25
+ };
26
+ e.addEventListener("change", t);
27
+ }
28
+ function v() {
29
+ const e = T();
30
+ return r(e), k(), e;
31
+ }
32
+ function M(e) {
33
+ let t;
34
+ return e === "system" ? t = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "dark" : t = e === "light" ? "dark" : "light", r(t), t;
35
+ }
36
+ function $(e) {
37
+ document.documentElement && document.documentElement.style.setProperty("--color-primary", e);
38
+ }
39
+ function P(e, t, n) {
40
+ return document.startViewTransition ? new Promise((a) => {
41
+ const s = window.innerWidth, f = window.innerHeight, o = t, i = n, g = Math.hypot(
42
+ Math.max(o, s - o),
43
+ Math.max(i, f - i)
44
+ ), m = w(e) === "dark", c = document.createElement("style");
45
+ c.innerHTML = `
46
+ ::view-transition-old(root),
47
+ ::view-transition-new(root) {
48
+ animation: none;
49
+ mix-blend-mode: normal;
50
+ display: block;
51
+ }
52
+ ${m ? `
53
+ ::view-transition-old(root) { z-index: 9999; }
54
+ ::view-transition-new(root) { z-index: 1; }
55
+ ` : ""}
56
+ `, document.head.appendChild(c);
57
+ const d = document.startViewTransition(() => {
58
+ r(e), a();
59
+ });
60
+ d.ready.then(() => {
61
+ const l = [
62
+ `circle(0px at ${o}px ${i}px)`,
63
+ `circle(${g}px at ${o}px ${i}px)`
64
+ ], h = {
65
+ duration: 500,
66
+ easing: "ease-in-out",
67
+ fill: "forwards"
68
+ };
69
+ m ? document.documentElement.animate(
70
+ {
71
+ clipPath: [...l].reverse()
72
+ },
73
+ {
74
+ ...h,
75
+ pseudoElement: "::view-transition-old(root)"
76
+ }
77
+ ) : document.documentElement.animate(
78
+ {
79
+ clipPath: l
80
+ },
81
+ {
82
+ ...h,
83
+ pseudoElement: "::view-transition-new(root)"
84
+ }
85
+ );
86
+ }), d.finished.then(() => {
87
+ document.head.removeChild(c);
88
+ });
89
+ }) : (r(e), Promise.resolve());
90
+ }
91
+ export {
92
+ r as applyTheme,
93
+ $ as applyThemeColor,
94
+ P as applyThemeWithTransition,
95
+ w as getRealTheme,
96
+ T as getTheme,
97
+ v as initTheme,
98
+ k as listenSystemTheme,
99
+ M as toggleTheme
100
+ };
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@spacego/fe-components",
3
+ "version": "0.0.1-alpha.1",
4
+ "description": "🚀 A component library for fe to use.",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "module": "lib/index.js",
8
+ "typings": "lib/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/types/index.d.ts",
12
+ "import": "./lib/index.js",
13
+ "require": "./lib/index.js"
14
+ },
15
+ "./*": {
16
+ "types": "./lib/types/*.d.ts",
17
+ "import": "./lib/*.js",
18
+ "require": "./lib/*.js"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "build": "vite build"
23
+ },
24
+ "keywords": [
25
+ "components",
26
+ "react",
27
+ "spacego",
28
+ "fe"
29
+ ],
30
+ "publishConfig": {
31
+ "registry": "https://registry.npmjs.org/",
32
+ "access": "public"
33
+ },
34
+ "author": "dshuais",
35
+ "license": "MIT",
36
+ "packageManager": "pnpm@10.8.0",
37
+ "devDependencies": {
38
+ "@ant-design/icons": "^6.1.0",
39
+ "@spacego/turbo-utils": "workspace:^",
40
+ "@spacego/zustand": "workspace:^",
41
+ "@vitejs/plugin-react-swc": "3.5.0",
42
+ "antd": "^6.2.1",
43
+ "axios": "^1.13.4",
44
+ "nprogress": "^0.2.0",
45
+ "react": "^18.2.0",
46
+ "@types/react": "^18.2.66",
47
+ "react-dom": "^18.2.0",
48
+ "react-icons": "^5.5.0",
49
+ "react-router-dom": "^7.12.0",
50
+ "rollup-plugin-clear": "^2.0.7",
51
+ "sass": "^1.97.3",
52
+ "tailwindcss": "^4.1.18",
53
+ "typescript": "^5.8.3",
54
+ "vite": "^6.3.3",
55
+ "vite-plugin-dts": "^4.5.3",
56
+ "vite-plugin-svgr": "^4.5.0",
57
+ "zustand": "^5.0.10",
58
+ "@tailwindcss/vite": "^4.1.18"
59
+ }
60
+ }
@@ -0,0 +1,62 @@
1
+ @keyframes enter-x-animation {
2
+ 100% {
3
+ opacity: 1;
4
+ transform: translate(0);
5
+ }
6
+ }
7
+
8
+ @keyframes float {
9
+ 0% {
10
+ transform: translateY(0);
11
+ }
12
+
13
+ 50% {
14
+ transform: translateY(-20px);
15
+ }
16
+
17
+ 100% {
18
+ transform: translateY(0);
19
+ }
20
+ }
21
+
22
+ @keyframes slide-right {
23
+ 0% {
24
+ opacity: 0;
25
+ transform: translate(50px);
26
+ }
27
+
28
+ 100% {
29
+ opacity: 1;
30
+ transform: translate(0);
31
+ }
32
+ }
33
+
34
+ @keyframes exit-x-animation {
35
+ 0% {
36
+ opacity: 1;
37
+ transform: translate(0);
38
+ }
39
+
40
+ 100% {
41
+ opacity: 0;
42
+ transform: translate(50px);
43
+ }
44
+ }
45
+
46
+ @keyframes scale-pulse {
47
+ 0% {
48
+ transform: scale(1);
49
+ }
50
+
51
+ 50% {
52
+ transform: scale(0.9);
53
+ }
54
+
55
+ 100% {
56
+ transform: scale(1);
57
+ }
58
+ }
59
+
60
+ .hover-scale-animation:hover {
61
+ animation: scale-pulse 0.3s cubic-bezier(0.4, 0, 0.2, 1);
62
+ }
@@ -0,0 +1,49 @@
1
+ @import "./animate.css";
2
+
3
+ /* 配置 Tailwind CSS dark 模式为 class 模式,而不是跟随系统 */
4
+ /* 这样 dark: 前缀会基于 html.dark 类,而不是系统主题 */
5
+ @custom-variant dark (&:where(.dark, .dark *));
6
+
7
+ :root {
8
+ --color-primary: #006BE6;
9
+ --global-background-color: white;
10
+ --border-color: #e4e4e7;
11
+ --text-color: #323639;
12
+ }
13
+
14
+ [data-theme='dark'] {
15
+ --global-background-color: #1a1c1f;
16
+ --border-color: #36363a;
17
+ --text-color: #f2f2f2;
18
+ }
19
+
20
+ html {
21
+ background-color: var(--global-background-color);
22
+ --hover-primary-color: color-mix(in srgb, var(--color-primary) 80%, transparent);
23
+ }
24
+
25
+ #root,
26
+ body,
27
+ html {
28
+ height: 100%;
29
+ width: 100%;
30
+ }
31
+
32
+ body {
33
+ min-height: 100vh;
34
+ }
35
+
36
+ /* Spin 遮罩样式,确保在当前容器内撑满 */
37
+ .spin-wrapper-full {
38
+ width: 100%;
39
+ height: 100%;
40
+
41
+ .ant-spin-container {
42
+ width: 100%;
43
+ height: 100%;
44
+ }
45
+
46
+ .ant-spin {
47
+ max-height: 100% !important;
48
+ }
49
+ }
@@ -0,0 +1 @@
1
+ <svg data-v-f1ce25ed="" class="tabs-chrome__background-after absolute bottom-0 right-[-7px] fill-transparent transition-all duration-500 group-[.is-active]:fill-(--background-primary-light)" height="7" width="7"><path data-v-f1ce25ed="" d="M 0 0 A 7 7 0 0 0 7 7 L 0 7 Z"></path></svg>
@@ -0,0 +1 @@
1
+ <svg data-v-f1ce25ed="" class="tabs-chrome__background-before absolute bottom-0 left-[-7px] fill-transparent transition-all duration-500 group-[.is-active]:fill-(--background-primary-light)" height="7" width="7"><path data-v-f1ce25ed="" d="M 0 7 A 7 7 0 0 0 7 0 L 7 7 Z"></path></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-right-icon lucide-chevron-right"><path d="m9 18 6-6-6-6"></path></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide size-4 lucide-bell-icon lucide-bell size-4"><path d="M10.268 21a2 2 0 0 0 3.464 0"></path><path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"></path></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide z-1 absolute size-5 opacity-60"><path d="M2 21a8 8 0 0 1 10.821-7.487"></path><path d="M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z"></path><circle cx="10" cy="8" r="5"></circle></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide mx-9 size-5 lucide-sun-moon-icon lucide-sun-moon mx-9 size-5"><path d="M12 2v2"></path><path d="M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715"></path><path d="M16 12a4 4 0 0 0-4-4"></path><path d="m19 5-1.256 1.256"></path><path d="M20 12h2"></path></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide size-4 lucide-settings-icon lucide-settings size-4"><path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"></path><circle cx="12" cy="12" r="3"></circle></svg>
@@ -0,0 +1,13 @@
1
+ <svg width="24" height="24" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className="spin-animation">
2
+ <g clipPath="url(#clip0_324_2488)">
3
+ <path d="M15 0H10C9.44772 0 9 0.447715 9 1V6C9 6.55228 9.44772 7 10 7H15C15.5523 7 16 6.55228 16 6V1C16 0.447715 15.5523 0 15 0Z" fill="var(--color-primary)" />
4
+ <path opacity="0.5" d="M15 9H10C9.44772 9 9 9.44772 9 10V15C9 15.5523 9.44772 16 10 16H15C15.5523 16 16 15.5523 16 15V10C16 9.44772 15.5523 9 15 9Z" fill="var(--color-primary)" />
5
+ <path opacity="0.1" d="M6 9H1C0.447715 9 0 9.44772 0 10V15C0 15.5523 0.447715 16 1 16H6C6.55228 16 7 15.5523 7 15V10C7 9.44772 6.55228 9 6 9Z" fill="var(--color-primary)" />
6
+ <path opacity="0.2" d="M6 0H1C0.447715 0 0 0.447715 0 1V6C0 6.55228 0.447715 7 1 7H6C6.55228 7 7 6.55228 7 6V1C7 0.447715 6.55228 0 6 0Z" fill="var(--color-primary)" />
7
+ </g>
8
+ <defs>
9
+ <clipPath id="clip0_324_2488">
10
+ <rect width="16" height="16" fill="white" />
11
+ </clipPath>
12
+ </defs>
13
+ </svg>