@agions/taroviz 1.11.1 → 2.0.3

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 (164) hide show
  1. package/CHANGELOG.md +245 -0
  2. package/README.md +104 -302
  3. package/dist/cjs/index.js +1 -1
  4. package/dist/cjs/vendors.js +1 -0
  5. package/dist/cjs/vendors~echarts.js +1 -0
  6. package/dist/esm/index.js +1 -58151
  7. package/dist/esm/vendors.js +1 -0
  8. package/dist/esm/vendors~echarts.js +1 -0
  9. package/package.json +19 -25
  10. package/src/adapters/MiniAppAdapter.ts +136 -0
  11. package/src/adapters/__tests__/index.test.ts +1 -1
  12. package/src/adapters/h5/__tests__/index.test.ts +4 -2
  13. package/src/adapters/h5/index.ts +63 -64
  14. package/src/adapters/harmony/index.ts +23 -245
  15. package/src/adapters/index.ts +49 -45
  16. package/src/adapters/swan/index.ts +6 -69
  17. package/src/adapters/tt/index.ts +7 -70
  18. package/src/adapters/types.ts +25 -58
  19. package/src/adapters/weapp/index.ts +6 -69
  20. package/src/charts/__tests__/testUtils.tsx +87 -0
  21. package/src/charts/boxplot/__tests__/index.test.tsx +49 -103
  22. package/src/charts/boxplot/index.tsx +2 -1
  23. package/src/charts/boxplot/types.ts +17 -16
  24. package/src/charts/common/BaseChartWrapper.tsx +90 -82
  25. package/src/charts/common/__mocks__/BaseChartWrapper.tsx +17 -0
  26. package/src/charts/createChartComponent.tsx +36 -0
  27. package/src/charts/createOptionChartComponent.tsx +32 -0
  28. package/src/charts/funnel/__tests__/index.test.tsx +99 -0
  29. package/src/charts/funnel/index.tsx +60 -10
  30. package/src/charts/funnel/types.ts +6 -0
  31. package/src/charts/graph/__tests__/index.test.tsx +102 -33
  32. package/src/charts/graph/index.tsx +66 -9
  33. package/src/charts/graph/types.ts +6 -0
  34. package/src/charts/heatmap/__tests__/index.test.tsx +139 -0
  35. package/src/charts/heatmap/index.tsx +103 -10
  36. package/src/charts/heatmap/types.ts +6 -0
  37. package/src/charts/index.ts +74 -26
  38. package/src/charts/liquid/__tests__/index.test.tsx +52 -0
  39. package/src/charts/liquid/index.tsx +239 -182
  40. package/src/charts/liquid/types.ts +11 -11
  41. package/src/charts/parallel/__tests__/index.test.tsx +40 -67
  42. package/src/charts/parallel/index.tsx +2 -1
  43. package/src/charts/parallel/types.ts +19 -18
  44. package/src/charts/radar/__tests__/index.test.tsx +210 -0
  45. package/src/charts/radar/index.tsx +143 -10
  46. package/src/charts/radar/types.ts +13 -0
  47. package/src/charts/sankey/__tests__/index.test.tsx +124 -0
  48. package/src/charts/sankey/index.tsx +62 -10
  49. package/src/charts/sankey/types.ts +6 -0
  50. package/src/charts/tree/__tests__/index.test.tsx +71 -0
  51. package/src/charts/tree/index.tsx +5 -2
  52. package/src/charts/tree/types.ts +9 -9
  53. package/src/charts/types.ts +208 -106
  54. package/src/charts/utils.ts +9 -7
  55. package/src/charts/wordcloud/__tests__/index.test.tsx +98 -31
  56. package/src/charts/wordcloud/index.tsx +75 -9
  57. package/src/charts/wordcloud/types.ts +6 -0
  58. package/src/components/DataFilter/index.tsx +32 -10
  59. package/src/core/animation/types.ts +6 -6
  60. package/src/core/components/Annotation.tsx +6 -7
  61. package/src/core/components/BaseChart.tsx +110 -168
  62. package/src/core/components/ErrorBoundary.tsx +17 -4
  63. package/src/core/components/LazyChart.tsx +54 -55
  64. package/src/core/components/hooks/index.ts +6 -2
  65. package/src/core/components/hooks/useChartInit.ts +6 -3
  66. package/src/core/components/hooks/usePerformance.ts +8 -2
  67. package/src/core/components/hooks/useVirtualScroll.ts +2 -1
  68. package/src/core/index.ts +1 -1
  69. package/src/core/themes/ThemeManager.ts +1 -1
  70. package/src/core/types/common.ts +2 -1
  71. package/src/core/types/index.ts +0 -12
  72. package/src/core/types/platform.ts +3 -5
  73. package/src/core/utils/__tests__/deepClone.test.ts +317 -0
  74. package/src/core/utils/__tests__/index.test.ts +2 -1
  75. package/src/core/utils/chartInstances.ts +13 -0
  76. package/src/core/utils/common.ts +20 -29
  77. package/src/core/utils/deepClone.ts +114 -0
  78. package/src/core/utils/download.ts +128 -0
  79. package/src/core/utils/drillDown.ts +34 -353
  80. package/src/core/utils/drillDownHelpers.ts +426 -0
  81. package/src/core/utils/events.ts +12 -0
  82. package/src/core/utils/export/ExportUtils.ts +36 -67
  83. package/src/core/utils/format.ts +44 -0
  84. package/src/core/utils/index.ts +21 -154
  85. package/src/core/utils/merge.ts +25 -0
  86. package/src/core/utils/performance/PerformanceAnalyzer.ts +38 -21
  87. package/src/core/utils/performance/hooks.ts +7 -0
  88. package/src/core/utils/performance/index.ts +2 -0
  89. package/src/{hooks → core/utils/performance}/useAnimation.ts +45 -41
  90. package/src/core/utils/performance/useDataZoom.ts +324 -0
  91. package/src/{hooks → core/utils/performance}/usePerformance.ts +49 -41
  92. package/src/core/utils/performance/usePerformanceHooks.ts +278 -0
  93. package/src/core/utils/performanceUtils.ts +310 -0
  94. package/src/core/utils/runtime.ts +190 -0
  95. package/src/core/utils/setOptionUtils.ts +59 -0
  96. package/src/core/version.ts +14 -0
  97. package/src/editor/EnhancedThemeEditor.tsx +362 -540
  98. package/src/editor/ThemeEditor.tsx +55 -321
  99. package/src/editor/components/ThemeBasicSettings.tsx +113 -0
  100. package/src/editor/components/ThemeColorEditor.tsx +105 -0
  101. package/src/editor/components/ThemeSelector.tsx +70 -0
  102. package/src/editor/hooks/useThemeEditorState.ts +201 -0
  103. package/src/editor/index.ts +10 -2
  104. package/src/hooks/__tests__/index.test.tsx +3 -1
  105. package/src/hooks/chartConnectHelpers.ts +341 -0
  106. package/src/hooks/index.ts +55 -660
  107. package/src/hooks/types.ts +189 -0
  108. package/src/hooks/useChartAutoResize.ts +73 -0
  109. package/src/hooks/useChartConnect.ts +92 -238
  110. package/src/hooks/useChartDownload.ts +25 -27
  111. package/src/hooks/useChartHistory.ts +34 -49
  112. package/src/hooks/useChartInit.ts +59 -0
  113. package/src/hooks/useChartOptions.ts +259 -0
  114. package/src/hooks/useChartPerformance.ts +109 -0
  115. package/src/hooks/useChartSelection.ts +52 -49
  116. package/src/hooks/useChartTheme.ts +51 -0
  117. package/src/hooks/useDataTransform.ts +19 -4
  118. package/src/hooks/utils/chartDownloadUtils.ts +40 -53
  119. package/src/hooks/utils/dataTransformUtils.ts +22 -0
  120. package/src/index.ts +48 -34
  121. package/src/main.tsx +4 -9
  122. package/src/react-dom.d.ts +3 -3
  123. package/src/themes/index.ts +30 -855
  124. package/src/themes/palettes/blue-green.ts +13 -0
  125. package/src/themes/palettes/chalk.ts +13 -0
  126. package/src/themes/palettes/cyber.ts +44 -0
  127. package/src/themes/palettes/dark.ts +52 -0
  128. package/src/themes/palettes/default.ts +52 -0
  129. package/src/themes/palettes/elegant.ts +34 -0
  130. package/src/themes/palettes/forest.ts +13 -0
  131. package/src/themes/palettes/glass.ts +49 -0
  132. package/src/themes/palettes/golden.ts +13 -0
  133. package/src/themes/palettes/neon.ts +43 -0
  134. package/src/themes/palettes/ocean.ts +39 -0
  135. package/src/themes/palettes/pastel.ts +37 -0
  136. package/src/themes/palettes/purple-passion.ts +13 -0
  137. package/src/themes/palettes/retro.ts +33 -0
  138. package/src/themes/palettes/sunset.ts +40 -0
  139. package/src/themes/palettes/walden.ts +13 -0
  140. package/src/themes/registry.ts +184 -0
  141. package/src/themes/types.ts +213 -0
  142. package/src/charts/bar/__tests__/index.test.tsx +0 -113
  143. package/src/charts/bar/index.tsx +0 -14
  144. package/src/charts/candlestick/__tests__/index.test.tsx +0 -40
  145. package/src/charts/candlestick/index.tsx +0 -13
  146. package/src/charts/gauge/index.tsx +0 -14
  147. package/src/charts/line/__tests__/index.test.tsx +0 -107
  148. package/src/charts/line/index.tsx +0 -15
  149. package/src/charts/pie/__tests__/index.test.tsx +0 -112
  150. package/src/charts/pie/index.tsx +0 -14
  151. package/src/charts/scatter/index.tsx +0 -14
  152. package/src/charts/sunburst/index.tsx +0 -18
  153. package/src/charts/treemap/index.tsx +0 -18
  154. package/src/core/utils/codeGenerator/CodeGenerator.ts +0 -669
  155. package/src/core/utils/codeGenerator/index.ts +0 -13
  156. package/src/core/utils/codeGenerator/types.ts +0 -198
  157. package/src/core/utils/configGenerator/ConfigGenerator.ts +0 -583
  158. package/src/core/utils/configGenerator/index.ts +0 -13
  159. package/src/core/utils/configGenerator/types.ts +0 -445
  160. package/src/core/utils/debug/DebugPanel.tsx +0 -637
  161. package/src/core/utils/debug/debugger.ts +0 -322
  162. package/src/core/utils/debug/index.ts +0 -21
  163. package/src/core/utils/debug/types.ts +0 -142
  164. package/src/hooks/useDataZoom.ts +0 -323
@@ -3,863 +3,37 @@
3
3
  * 提供图表主题配置和自定义主题功能
4
4
  */
5
5
 
6
- // ============================================================================
7
6
  // 类型定义
8
- // ============================================================================
7
+ export type {
8
+ BuiltinTheme,
9
+ ThemeMode,
10
+ ThemeGradient,
11
+ ThemeEffects,
12
+ ThemeOptions,
13
+ ChartThemeConfig,
14
+ LegendThemeConfig,
15
+ AxisThemeConfig,
16
+ TooltipThemeConfig,
17
+ TitleThemeConfig,
18
+ GridThemeConfig,
19
+ DataZoomThemeConfig,
20
+ TimelineThemeConfig,
21
+ } from './types';
22
+
23
+ // 内置主题色板
24
+ export { defaultTheme } from './palettes/default';
25
+ export { darkTheme } from './palettes/dark';
26
+ export { neonTheme } from './palettes/neon';
27
+ export { glassTheme } from './palettes/glass';
28
+ export { pastelTheme } from './palettes/pastel';
29
+ export { sunsetTheme } from './palettes/sunset';
30
+ export { oceanTheme } from './palettes/ocean';
31
+ export { cyberTheme } from './palettes/cyber';
32
+ export { retroTheme } from './palettes/retro';
33
+ export { elegantTheme } from './palettes/elegant';
9
34
 
10
- /**
11
- * 内置主题类型
12
- */
13
- export type BuiltinTheme =
14
- | 'default'
15
- | 'light'
16
- | 'dark'
17
- | 'vintage'
18
- | 'macarons'
19
- | 'roma'
20
- | 'shine'
21
- | 'infographic'
22
- | 'westeros'
23
- | 'walden'
24
- | 'chalk'
25
- | 'purple-passion'
26
- | 'blue-green'
27
- | 'golden'
28
- | 'forest'
29
- // 新增主题
30
- | 'neon'
31
- | 'glass'
32
- | 'pastel'
33
- | 'sunset'
34
- | 'ocean'
35
- | 'cyber'
36
- | 'retro'
37
- | 'elegant';
38
-
39
- /**
40
- * 主题模式
41
- */
42
- export type ThemeMode = 'light' | 'dark' | 'auto';
43
-
44
- /**
45
- * 主题渐变类型
46
- */
47
- export interface ThemeGradient {
48
- /** 渐变起始色 */
49
- start: string;
50
- /** 渐变结束色 */
51
- end: string;
52
- /** 渐变角度 */
53
- angle?: number;
54
- }
55
-
56
- /**
57
- * 主题效果配置
58
- */
59
- export interface ThemeEffects {
60
- /** 是否启用阴影 */
61
- shadows?: boolean;
62
- /** 阴影颜色 */
63
- shadowColor?: string;
64
- /** 是否启用渐变 */
65
- gradients?: boolean;
66
- /** 自定义渐变 */
67
- customGradients?: ThemeGradient[];
68
- /** 是否启用玻璃态 */
69
- glassmorphism?: boolean;
70
- /** 玻璃态模糊度 */
71
- blur?: number;
72
- /** 圆角风格 */
73
- borderRadius?: 'none' | 'small' | 'medium' | 'large' | 'pill';
74
- }
75
-
76
- /**
77
- * 主题配置选项
78
- */
79
- export interface ThemeOptions {
80
- /** 主题名称/键名 */
81
- theme?: BuiltinTheme | Record<string, unknown>;
82
-
83
- /** 是否启用深色模式 */
84
- darkMode?: boolean;
85
-
86
- /** 主题模式 */
87
- mode?: ThemeMode;
88
-
89
- /** 颜色列表 */
90
- colors?: string[];
91
-
92
- /** 背景色 */
93
- backgroundColor?: string;
94
-
95
- /** 背景渐变 */
96
- backgroundGradient?: ThemeGradient;
97
-
98
- /** 文本颜色 */
99
- textColor?: string;
100
-
101
- /** 次要文本颜色 */
102
- textColorSecondary?: string;
103
-
104
- /** 边框颜色 */
105
- borderColor?: string;
106
-
107
- /** 分割线颜色 */
108
- dividerColor?: string;
109
-
110
- /** 字体 */
111
- fontFamily?: string;
112
-
113
- /** 标题字体 */
114
- fontFamilyTitle?: string;
115
-
116
- /** 正文字体 */
117
- fontFamilyBody?: string;
118
-
119
- /** 主题名称(显示用) */
120
- name?: string;
121
-
122
- /** 主题描述 */
123
- description?: string;
124
-
125
- /** 主题作者 */
126
- author?: string;
127
-
128
- /** 主题版本 */
129
- version?: string;
130
-
131
- /** 主题类型 */
132
- type?: ThemeMode;
133
-
134
- /** 主题标签 */
135
- tags?: string[];
136
-
137
- /** 效果配置 */
138
- effects?: ThemeEffects;
139
-
140
- /** 图表特定配置 */
141
- chart?: ChartThemeConfig;
142
- }
143
-
144
- /**
145
- * 图表主题配置
146
- */
147
- export interface ChartThemeConfig {
148
- /** 图例配置 */
149
- legend?: LegendThemeConfig;
150
- /** 坐标轴配置 */
151
- axis?: AxisThemeConfig;
152
- /** 提示框配置 */
153
- tooltip?: TooltipThemeConfig;
154
- /** 标题配置 */
155
- title?: TitleThemeConfig;
156
- /** 网格配置 */
157
- grid?: GridThemeConfig;
158
- /** 数据区域缩放配置 */
159
- dataZoom?: DataZoomThemeConfig;
160
- /** 时间线配置 */
161
- timeline?: TimelineThemeConfig;
162
- }
163
-
164
- /** 图例主题配置 */
165
- export interface LegendThemeConfig {
166
- textColor?: string;
167
- backgroundColor?: string;
168
- borderColor?: string;
169
- borderRadius?: number | number[];
170
- padding?: number | number[];
171
- }
172
-
173
- /** 坐标轴主题配置 */
174
- export interface AxisThemeConfig {
175
- textColor?: string;
176
- lineColor?: string;
177
- tickColor?: string;
178
- splitLineColor?: string;
179
- splitAreaColor?: string;
180
- }
181
-
182
- /** 提示框主题配置 */
183
- export interface TooltipThemeConfig {
184
- textColor?: string;
185
- backgroundColor?: string;
186
- borderColor?: string;
187
- borderRadius?: number;
188
- shadowColor?: string;
189
- }
190
-
191
- /** 标题主题配置 */
192
- export interface TitleThemeConfig {
193
- textColor?: string;
194
- subTextColor?: string;
195
- }
196
-
197
- /** 网格主题配置 */
198
- export interface GridThemeConfig {
199
- backgroundColor?: string;
200
- borderColor?: string;
201
- }
202
-
203
- /** 数据区域缩放主题配置 */
204
- export interface DataZoomThemeConfig {
205
- backgroundColor?: string;
206
- fillerColor?: string;
207
- borderColor?: string;
208
- textColor?: string;
209
- }
210
-
211
- /** 时间线主题配置 */
212
- export interface TimelineThemeConfig {
213
- backgroundColor?: string;
214
- borderColor?: string;
215
- textColor?: string;
216
- lineColor?: string;
217
- controlColor?: string;
218
- }
219
-
220
- // ============================================================================
221
- // 主题注册表
222
- // ============================================================================
223
-
224
- const themeRegistry = new Map<string, ThemeOptions>();
225
-
226
- // ============================================================================
227
- // 内置主题定义
228
- // ============================================================================
229
-
230
- /** 默认主题 */
231
- export const defaultTheme: ThemeOptions = {
232
- theme: 'default',
233
- name: 'Default',
234
- description: '简洁现代的默认主题',
235
- type: 'light',
236
- mode: 'light',
237
- darkMode: false,
238
- tags: ['modern', 'clean', 'default'],
239
- colors: [
240
- '#5470c6',
241
- '#91cc75',
242
- '#fac858',
243
- '#ee6666',
244
- '#73c0de',
245
- '#3ba272',
246
- '#fc8452',
247
- '#9a60b4',
248
- '#ea7ccc',
249
- ],
250
- backgroundColor: '#ffffff',
251
- textColor: '#333333',
252
- textColorSecondary: '#666666',
253
- borderColor: '#e8e8e8',
254
- dividerColor: '#f0f0f0',
255
- fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
256
- chart: {
257
- legend: {
258
- textColor: '#333333',
259
- backgroundColor: 'transparent',
260
- borderColor: '#e8e8e8',
261
- },
262
- axis: {
263
- textColor: '#666666',
264
- lineColor: '#e8e8e8',
265
- tickColor: '#e8e8e8',
266
- splitLineColor: '#f0f0f0',
267
- },
268
- tooltip: {
269
- textColor: '#333333',
270
- backgroundColor: 'rgba(255, 255, 255, 0.95)',
271
- borderColor: '#e8e8e8',
272
- borderRadius: 4,
273
- },
274
- title: {
275
- textColor: '#333333',
276
- subTextColor: '#666666',
277
- },
278
- },
279
- };
280
-
281
- /** 深色主题 */
282
- export const darkTheme: ThemeOptions = {
283
- theme: 'dark',
284
- name: 'Dark',
285
- description: '优雅的深色主题,适合夜间使用',
286
- type: 'dark',
287
- mode: 'dark',
288
- darkMode: true,
289
- tags: ['dark', 'night', 'modern'],
290
- colors: [
291
- '#4992ff',
292
- '#7cffb2',
293
- '#fddd60',
294
- '#ff6e76',
295
- '#58d9f9',
296
- '#05c091',
297
- '#ff9f7f',
298
- '#8d48e3',
299
- '#dd79ff',
300
- ],
301
- backgroundColor: '#1a1a2e',
302
- textColor: '#e8e8e8',
303
- textColorSecondary: '#a0a0a0',
304
- borderColor: '#2d2d44',
305
- dividerColor: '#252538',
306
- fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
307
- chart: {
308
- legend: {
309
- textColor: '#e8e8e8',
310
- backgroundColor: 'transparent',
311
- borderColor: '#2d2d44',
312
- },
313
- axis: {
314
- textColor: '#a0a0a0',
315
- lineColor: '#2d2d44',
316
- tickColor: '#2d2d44',
317
- splitLineColor: '#252538',
318
- },
319
- tooltip: {
320
- textColor: '#e8e8e8',
321
- backgroundColor: 'rgba(26, 26, 46, 0.95)',
322
- borderColor: '#2d2d44',
323
- borderRadius: 4,
324
- },
325
- title: {
326
- textColor: '#e8e8e8',
327
- subTextColor: '#a0a0a0',
328
- },
329
- },
330
- };
331
-
332
- /** Neon 霓虹主题 */
333
- export const neonTheme: ThemeOptions = {
334
- theme: 'neon',
335
- name: 'Neon',
336
- description: '赛博朋克霓虹风格,炫酷吸睛',
337
- type: 'dark',
338
- mode: 'dark',
339
- darkMode: true,
340
- tags: ['neon', 'cyberpunk', 'colorful', 'dark'],
341
- colors: [
342
- '#00fff5',
343
- '#ff00ff',
344
- '#ffff00',
345
- '#00ff00',
346
- '#ff6b6b',
347
- '#4ecdc4',
348
- '#ffe66d',
349
- '#95e1d3',
350
- '#f38181',
351
- ],
352
- backgroundColor: '#0d0d1a',
353
- textColor: '#ffffff',
354
- textColorSecondary: '#b0b0b0',
355
- borderColor: '#1a1a2e',
356
- dividerColor: '#1a1a2e',
357
- fontFamily: '"JetBrains Mono", "Fira Code", monospace',
358
- effects: {
359
- shadows: true,
360
- shadowColor: 'rgba(0, 255, 245, 0.3)',
361
- gradients: true,
362
- },
363
- chart: {
364
- tooltip: {
365
- textColor: '#ffffff',
366
- backgroundColor: 'rgba(13, 13, 26, 0.95)',
367
- borderColor: '#00fff5',
368
- borderRadius: 4,
369
- shadowColor: 'rgba(0, 255, 245, 0.3)',
370
- },
371
- },
372
- };
373
-
374
- /** Glass 玻璃态主题 */
375
- export const glassTheme: ThemeOptions = {
376
- theme: 'glass',
377
- name: 'Glass',
378
- description: '现代玻璃态设计,半透明质感',
379
- type: 'light',
380
- mode: 'light',
381
- darkMode: false,
382
- tags: ['glass', 'modern', 'minimal', 'light'],
383
- colors: [
384
- '#667eea',
385
- '#764ba2',
386
- '#f093fb',
387
- '#f5576c',
388
- '#4facfe',
389
- '#00f2fe',
390
- '#43e97b',
391
- '#38f9d7',
392
- '#fa709a',
393
- ],
394
- backgroundColor: 'rgba(255, 255, 255, 0.8)',
395
- backgroundGradient: {
396
- start: '#f5f7fa',
397
- end: '#c3cfe2',
398
- angle: 135,
399
- },
400
- textColor: '#2d3748',
401
- textColorSecondary: '#718096',
402
- borderColor: 'rgba(255, 255, 255, 0.5)',
403
- dividerColor: 'rgba(255, 255, 255, 0.3)',
404
- fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',
405
- effects: {
406
- glassmorphism: true,
407
- blur: 10,
408
- shadows: true,
409
- shadowColor: 'rgba(0, 0, 0, 0.1)',
410
- borderRadius: 'large',
411
- },
412
- chart: {
413
- tooltip: {
414
- textColor: '#2d3748',
415
- backgroundColor: 'rgba(255, 255, 255, 0.9)',
416
- borderColor: 'rgba(255, 255, 255, 0.5)',
417
- borderRadius: 12,
418
- },
419
- },
420
- };
421
-
422
- /** Pastel 粉彩主题 */
423
- export const pastelTheme: ThemeOptions = {
424
- theme: 'pastel',
425
- name: 'Pastel',
426
- description: '柔和粉彩配色,温馨舒适',
427
- type: 'light',
428
- mode: 'light',
429
- darkMode: false,
430
- tags: ['pastel', 'soft', 'gentle', 'light'],
431
- colors: [
432
- '#ffb3ba',
433
- '#ffdfba',
434
- '#ffffba',
435
- '#baffc9',
436
- '#bae1ff',
437
- '#f0b3ff',
438
- '#b3fff0',
439
- '#ffb3d9',
440
- '#d9ffb3',
441
- ],
442
- backgroundColor: '#fff9f5',
443
- textColor: '#5d5d5d',
444
- textColorSecondary: '#8a8a8a',
445
- borderColor: '#f0e6e0',
446
- dividerColor: '#f5f0eb',
447
- fontFamily: 'Nunito, -apple-system, BlinkMacSystemFont, sans-serif',
448
- chart: {
449
- tooltip: {
450
- textColor: '#5d5d5d',
451
- backgroundColor: 'rgba(255, 255, 255, 0.95)',
452
- borderColor: '#f0e6e0',
453
- borderRadius: 8,
454
- },
455
- },
456
- };
457
-
458
- /** Sunset 日落主题 */
459
- export const sunsetTheme: ThemeOptions = {
460
- theme: 'sunset',
461
- name: 'Sunset',
462
- description: '温暖日落渐变,夕阳余晖',
463
- type: 'light',
464
- mode: 'light',
465
- darkMode: false,
466
- tags: ['sunset', 'warm', 'gradient', 'light'],
467
- colors: [
468
- '#ff6b6b',
469
- '#feca57',
470
- '#ff9ff3',
471
- '#54a0ff',
472
- '#5f27cd',
473
- '#ff9f43',
474
- '#ee5a24',
475
- '#009432',
476
- '#f368e0',
477
- ],
478
- backgroundColor: '#fff5f0',
479
- backgroundGradient: {
480
- start: '#ffecd2',
481
- end: '#fcb69f',
482
- angle: 135,
483
- },
484
- textColor: '#4a4a4a',
485
- textColorSecondary: '#7a7a7a',
486
- borderColor: '#ffd5c8',
487
- dividerColor: '#ffebe6',
488
- fontFamily: 'Quicksand, -apple-system, BlinkMacSystemFont, sans-serif',
489
- effects: {
490
- gradients: true,
491
- shadows: true,
492
- shadowColor: 'rgba(255, 107, 107, 0.2)',
493
- borderRadius: 'medium',
494
- },
495
- };
496
-
497
- /** Ocean 海洋主题 */
498
- export const oceanTheme: ThemeOptions = {
499
- theme: 'ocean',
500
- name: 'Ocean',
501
- description: '深邃海洋蓝,宁静清新',
502
- type: 'light',
503
- mode: 'light',
504
- darkMode: false,
505
- tags: ['ocean', 'blue', 'calm', 'light'],
506
- colors: [
507
- '#0077b6',
508
- '#00b4d8',
509
- '#90e0ef',
510
- '#caf0f8',
511
- '#03045e',
512
- '#023e8a',
513
- '#0096c7',
514
- '#48cae4',
515
- '#ade8f4',
516
- ],
517
- backgroundColor: '#f0f8ff',
518
- backgroundGradient: {
519
- start: '#e0f2fe',
520
- end: '#bae6fd',
521
- angle: 180,
522
- },
523
- textColor: '#1e3a5f',
524
- textColorSecondary: '#4a6fa5',
525
- borderColor: '#cce7f5',
526
- dividerColor: '#e1f0f9',
527
- fontFamily: 'Nunito, -apple-system, BlinkMacSystemFont, sans-serif',
528
- effects: {
529
- gradients: true,
530
- shadows: true,
531
- shadowColor: 'rgba(0, 119, 182, 0.15)',
532
- },
533
- };
534
-
535
- /** Cyber 赛博主题 */
536
- export const cyberTheme: ThemeOptions = {
537
- theme: 'cyber',
538
- name: 'Cyber',
539
- description: '未来科技感,赛博朋克',
540
- type: 'dark',
541
- mode: 'dark',
542
- darkMode: true,
543
- tags: ['cyber', 'tech', 'futuristic', 'dark'],
544
- colors: [
545
- '#00f5ff',
546
- '#ff00ff',
547
- '#00ff00',
548
- '#ffff00',
549
- '#ff0080',
550
- '#8000ff',
551
- '#00ff80',
552
- '#ff8000',
553
- '#0080ff',
554
- ],
555
- backgroundColor: '#0a0a12',
556
- textColor: '#e0e0e0',
557
- textColorSecondary: '#808090',
558
- borderColor: '#1a1a2e',
559
- dividerColor: '#12121e',
560
- fontFamily: '"Orbitron", "Rajdhani", "JetBrains Mono", monospace',
561
- effects: {
562
- shadows: true,
563
- shadowColor: 'rgba(0, 245, 255, 0.4)',
564
- gradients: true,
565
- borderRadius: 'none',
566
- },
567
- chart: {
568
- tooltip: {
569
- textColor: '#ffffff',
570
- backgroundColor: 'rgba(10, 10, 18, 0.95)',
571
- borderColor: '#00f5ff',
572
- borderRadius: 0,
573
- shadowColor: 'rgba(0, 245, 255, 0.4)',
574
- },
575
- },
576
- };
577
-
578
- /** Retro 复古主题 */
579
- export const retroTheme: ThemeOptions = {
580
- theme: 'retro',
581
- name: 'Retro',
582
- description: '怀旧复古风格,温馨怀旧',
583
- type: 'light',
584
- mode: 'light',
585
- darkMode: false,
586
- tags: ['retro', 'vintage', 'nostalgic', 'light'],
587
- colors: [
588
- '#d63031',
589
- '#e17055',
590
- '#fdcb6e',
591
- '#00b894',
592
- '#0984e3',
593
- '#6c5ce7',
594
- '#e84393',
595
- '#00cec9',
596
- '#fab1a0',
597
- ],
598
- backgroundColor: '#fdf6e3',
599
- textColor: '#5c4b37',
600
- textColorSecondary: '#8b7355',
601
- borderColor: '#e8dcc8',
602
- dividerColor: '#f0e8d8',
603
- fontFamily: '"Courier Prime", "Courier New", monospace',
604
- effects: {
605
- shadows: false,
606
- borderRadius: 'small',
607
- },
608
- };
609
-
610
- /** Elegant 雅致主题 */
611
- export const elegantTheme: ThemeOptions = {
612
- theme: 'elegant',
613
- name: 'Elegant',
614
- description: '低调雅致风格,精致品味',
615
- type: 'light',
616
- mode: 'light',
617
- darkMode: false,
618
- tags: ['elegant', 'minimal', 'sophisticated', 'light'],
619
- colors: [
620
- '#2c3e50',
621
- '#34495e',
622
- '#7f8c8d',
623
- '#95a5a6',
624
- '#bdc3c7',
625
- '#ecf0f1',
626
- '#1abc9c',
627
- '#16a085',
628
- '#3498db',
629
- ],
630
- backgroundColor: '#fafafa',
631
- textColor: '#2c3e50',
632
- textColorSecondary: '#7f8c8d',
633
- borderColor: '#e8e8e8',
634
- dividerColor: '#f0f0f0',
635
- fontFamily: '"Playfair Display", Georgia, serif',
636
- effects: {
637
- shadows: true,
638
- shadowColor: 'rgba(0, 0, 0, 0.08)',
639
- borderRadius: 'medium',
640
- },
641
- };
642
-
643
- // ============================================================================
644
35
  // 主题管理函数
645
- // ============================================================================
646
-
647
- /**
648
- * 获取主题配置
649
- * @param options 自定义选项
650
- * @returns 合并后的主题配置
651
- */
652
- export function getTheme(options?: Partial<ThemeOptions>): ThemeOptions {
653
- if (!options) {
654
- return defaultTheme;
655
- }
656
-
657
- let baseTheme: ThemeOptions;
658
- if (options.theme && typeof options.theme === 'string') {
659
- const registeredTheme = themeRegistry.get(options.theme);
660
- if (registeredTheme) {
661
- baseTheme = registeredTheme;
662
- } else {
663
- baseTheme = options.darkMode ? darkTheme : defaultTheme;
664
- }
665
- } else {
666
- baseTheme = options.darkMode ? darkTheme : defaultTheme;
667
- }
668
-
669
- return { ...baseTheme, ...options };
670
- }
671
-
672
- /**
673
- * 注册主题
674
- * @param name 主题名称
675
- * @param theme 主题配置
676
- */
677
- export function registerTheme(name: string, theme: ThemeOptions): void {
678
- themeRegistry.set(name, { ...theme, name });
679
- }
680
-
681
- /**
682
- * 获取已注册的主题列表
683
- * @returns 主题列表
684
- */
685
- export function getRegisteredThemes(): ThemeOptions[] {
686
- return Array.from(themeRegistry.values());
687
- }
688
-
689
- /**
690
- * 获取指定主题
691
- * @param name 主题名称
692
- * @returns 主题配置
693
- */
694
- export function getThemeByName(name: string): ThemeOptions | undefined {
695
- return themeRegistry.get(name);
696
- }
697
-
698
- /**
699
- * 删除主题
700
- * @param name 主题名称
701
- */
702
- export function unregisterTheme(name: string): void {
703
- themeRegistry.delete(name);
704
- }
705
-
706
- /**
707
- * 重置主题注册表(清除所有已注册的主题,恢复内置主题)
708
- * 主要用于测试环境
709
- */
710
- export function resetThemeRegistry(): void {
711
- themeRegistry.clear();
712
- // 重新注册所有内置主题
713
- Object.entries(builtinThemes).forEach(([name, theme]) => {
714
- themeRegistry.set(name, theme as ThemeOptions);
715
- });
716
- }
717
-
718
- /**
719
- * 动态切换主题
720
- * @param theme 主题名称或主题配置
721
- * @param callback 切换完成后的回调函数
722
- * @returns 主题配置
723
- */
724
- export function switchTheme(theme: string | ThemeOptions, callback?: () => void): ThemeOptions {
725
- let themeConfig: ThemeOptions;
726
-
727
- if (typeof theme === 'string') {
728
- const registeredTheme = themeRegistry.get(theme);
729
- themeConfig = registeredTheme || defaultTheme;
730
- } else {
731
- themeConfig = theme;
732
- if (theme.name) {
733
- registerTheme(theme.name, theme);
734
- }
735
- }
736
-
737
- // 触发主题切换事件
738
- if (typeof window !== 'undefined') {
739
- window.dispatchEvent(new CustomEvent('themeChange', { detail: themeConfig }));
740
- }
741
-
742
- callback?.();
743
-
744
- return themeConfig;
745
- }
746
-
747
- /**
748
- * 根据标签获取主题
749
- * @param tag 标签
750
- * @returns 主题列表
751
- */
752
- export function getThemesByTag(tag: string): ThemeOptions[] {
753
- return getRegisteredThemes().filter((t) => t.tags?.includes(tag));
754
- }
755
-
756
- /**
757
- * 获取浅色主题
758
- * @returns 浅色主题列表
759
- */
760
- export function getLightThemes(): ThemeOptions[] {
761
- return getRegisteredThemes().filter((t) => !t.darkMode);
762
- }
763
-
764
- /**
765
- * 获取深色主题
766
- * @returns 深色主题列表
767
- */
768
- export function getDarkThemes(): ThemeOptions[] {
769
- return getRegisteredThemes().filter((t) => t.darkMode);
770
- }
771
-
772
- // ============================================================================
773
- // 注册所有内置主题
774
- // ============================================================================
775
-
776
- const builtinThemes = {
777
- default: defaultTheme,
778
- dark: darkTheme,
779
- walden: {
780
- ...defaultTheme,
781
- theme: 'walden',
782
- name: 'Walden',
783
- description: '清新自然风格',
784
- colors: ['#0a437a', '#3a84c4', '#22a783', '#48b591', '#7fcdbb', '#c9e4ca'],
785
- backgroundColor: '#f0f8f5',
786
- textColor: '#2c5042',
787
- },
788
- chalk: {
789
- ...defaultTheme,
790
- theme: 'chalk',
791
- name: 'Chalk',
792
- description: '粉笔风格',
793
- colors: ['#2e8de5', '#f0805a', '#5ab1ef', '#91d5ff', '#faad14'],
794
- backgroundColor: '#ffffff',
795
- textColor: '#000000',
796
- },
797
- 'purple-passion': {
798
- ...defaultTheme,
799
- theme: 'purple-passion',
800
- name: 'Purple Passion',
801
- description: '紫色浪漫',
802
- colors: ['#9c27b0', '#e91e63', '#ff5722', '#ff9800', '#ffc107'],
803
- backgroundColor: '#f5f5f5',
804
- textColor: '#333333',
805
- },
806
- 'blue-green': {
807
- ...defaultTheme,
808
- theme: 'blue-green',
809
- name: 'Blue Green',
810
- description: '蓝绿清新',
811
- colors: ['#00838f', '#00acc1', '#03a9f4', '#29b6f6', '#4fc3f7'],
812
- backgroundColor: '#e0f7fa',
813
- textColor: '#006064',
814
- },
815
- golden: {
816
- ...defaultTheme,
817
- theme: 'golden',
818
- name: 'Golden',
819
- description: '金色奢华',
820
- colors: ['#ffd700', '#ffed4e', '#f9a825', '#ffc107', '#ffb300'],
821
- backgroundColor: '#fff8e1',
822
- textColor: '#ff6f00',
823
- },
824
- forest: {
825
- ...defaultTheme,
826
- theme: 'forest',
827
- name: 'Forest',
828
- description: '森林绿色',
829
- colors: ['#2e7d32', '#388e3c', '#43a047', '#4caf50', '#66bb6a'],
830
- backgroundColor: '#f1f8e9',
831
- textColor: '#1b5e20',
832
- },
833
- neon: neonTheme,
834
- glass: glassTheme,
835
- pastel: pastelTheme,
836
- sunset: sunsetTheme,
837
- ocean: oceanTheme,
838
- cyber: cyberTheme,
839
- retro: retroTheme,
840
- elegant: elegantTheme,
841
- };
842
-
843
- // 注册所有内置主题
844
- Object.entries(builtinThemes).forEach(([name, theme]) => {
845
- themeRegistry.set(name, theme as ThemeOptions);
846
- });
847
-
848
- // ============================================================================
849
- // 导出
850
- // ============================================================================
851
-
852
- export default {
853
- defaultTheme,
854
- darkTheme,
855
- neonTheme,
856
- glassTheme,
857
- pastelTheme,
858
- sunsetTheme,
859
- oceanTheme,
860
- cyberTheme,
861
- retroTheme,
862
- elegantTheme,
36
+ export {
863
37
  getTheme,
864
38
  registerTheme,
865
39
  getRegisteredThemes,
@@ -870,7 +44,8 @@ export default {
870
44
  getThemesByTag,
871
45
  getLightThemes,
872
46
  getDarkThemes,
873
- };
47
+ } from './registry';
874
48
 
49
+ // Auto theme hook
875
50
  export { useAutoTheme } from './useAutoTheme';
876
51
  export type { UseAutoThemeOptions } from './useAutoTheme';