@space-man/react-theme-animation 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -142
- package/dist/core/index.cjs +74 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/{esm/types/index.d.ts → core/index.d.cts} +26 -8
- package/dist/{cjs/types → core}/index.d.ts +26 -8
- package/dist/core/index.js +66 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.cjs +1756 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1706 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.cjs +1742 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +224 -0
- package/dist/react/index.d.ts +224 -0
- package/dist/react/index.js +1697 -0
- package/dist/react/index.js.map +1 -0
- package/dist/tanstack/index.cjs +34 -0
- package/dist/tanstack/index.cjs.map +1 -0
- package/dist/tanstack/index.d.cts +20 -0
- package/dist/tanstack/index.d.ts +20 -0
- package/dist/tanstack/index.js +27 -0
- package/dist/tanstack/index.js.map +1 -0
- package/package.json +66 -37
- package/dist/cjs/components/NextThemeProvider.d.ts +0 -81
- package/dist/cjs/components/NextThemeProvider.js +0 -223
- package/dist/cjs/components/SpacemanThemeProvider.d.ts +0 -57
- package/dist/cjs/components/SpacemanThemeProvider.js +0 -113
- package/dist/cjs/components/TanStackThemeProvider.d.ts +0 -68
- package/dist/cjs/components/TanStackThemeProvider.js +0 -183
- package/dist/cjs/components/ThemeSelector.d.ts +0 -3
- package/dist/cjs/components/ThemeSelector.js +0 -39
- package/dist/cjs/components/ThemeSwitcher.d.ts +0 -3
- package/dist/cjs/components/ThemeSwitcher.js +0 -81
- package/dist/cjs/components/ViteThemeProvider.d.ts +0 -61
- package/dist/cjs/components/ViteThemeProvider.js +0 -140
- package/dist/cjs/components/ui/select.d.ts +0 -15
- package/dist/cjs/components/ui/select.js +0 -83
- package/dist/cjs/hooks/use-theme-animation.d.ts +0 -2
- package/dist/cjs/hooks/use-theme-animation.js +0 -234
- package/dist/cjs/index.d.ts +0 -10
- package/dist/cjs/index.js +0 -30
- package/dist/cjs/types/index.js +0 -9
- package/dist/cjs/utils/animations.d.ts +0 -21
- package/dist/cjs/utils/animations.js +0 -189
- package/dist/esm/components/NextThemeProvider.d.ts +0 -81
- package/dist/esm/components/NextThemeProvider.js +0 -185
- package/dist/esm/components/SpacemanThemeProvider.d.ts +0 -57
- package/dist/esm/components/SpacemanThemeProvider.js +0 -108
- package/dist/esm/components/TanStackThemeProvider.d.ts +0 -68
- package/dist/esm/components/TanStackThemeProvider.js +0 -178
- package/dist/esm/components/ThemeSelector.d.ts +0 -3
- package/dist/esm/components/ThemeSelector.js +0 -35
- package/dist/esm/components/ThemeSwitcher.d.ts +0 -3
- package/dist/esm/components/ThemeSwitcher.js +0 -77
- package/dist/esm/components/ViteThemeProvider.d.ts +0 -61
- package/dist/esm/components/ViteThemeProvider.js +0 -135
- package/dist/esm/components/ui/select.d.ts +0 -15
- package/dist/esm/components/ui/select.js +0 -39
- package/dist/esm/hooks/use-theme-animation.d.ts +0 -2
- package/dist/esm/hooks/use-theme-animation.js +0 -230
- package/dist/esm/index.d.ts +0 -10
- package/dist/esm/index.js +0 -10
- package/dist/esm/types/index.js +0 -6
- package/dist/esm/utils/animations.d.ts +0 -21
- package/dist/esm/utils/animations.js +0 -177
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { UseThemeAnimationProps, UseThemeAnimationReturn, ThemeSwitcherProps, ThemeSelectorProps, Theme, ColorTheme, ThemeAnimationType, SystemThemeMode } from '../core/index.js';
|
|
2
|
+
export { SlideDirection, getSystemTheme, injectBaseStyles, prefersReducedMotion, resolveTheme, resolveThemeForServer, supportsViewTransitions } from '../core/index.js';
|
|
3
|
+
import React, { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
declare const useThemeAnimation: (props?: UseThemeAnimationProps) => UseThemeAnimationReturn;
|
|
6
|
+
|
|
7
|
+
declare const ThemeSwitcher: React.FC<ThemeSwitcherProps>;
|
|
8
|
+
|
|
9
|
+
declare const ThemeSelector: React.FC<ThemeSelectorProps>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Context type for the Spaceman Theme Provider
|
|
13
|
+
*/
|
|
14
|
+
interface SpacemanThemeContextType {
|
|
15
|
+
ref: React.RefObject<HTMLButtonElement | null>;
|
|
16
|
+
theme: Theme;
|
|
17
|
+
colorTheme: ColorTheme;
|
|
18
|
+
resolvedTheme: 'light' | 'dark';
|
|
19
|
+
setTheme: (theme: Theme) => void;
|
|
20
|
+
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
21
|
+
switchTheme: (theme: Theme) => Promise<void>;
|
|
22
|
+
switchColorTheme: (colorTheme: string) => void;
|
|
23
|
+
toggleTheme: () => Promise<void>;
|
|
24
|
+
toggleLightTheme: () => Promise<void>;
|
|
25
|
+
toggleDarkTheme: () => Promise<void>;
|
|
26
|
+
toggleColorTheme: () => void;
|
|
27
|
+
createColorThemeToggle: (targetColorTheme: string) => () => void;
|
|
28
|
+
isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
29
|
+
switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Props for the Spaceman Theme Provider
|
|
33
|
+
*/
|
|
34
|
+
interface SpacemanThemeProviderProps {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
themes?: Theme[];
|
|
37
|
+
colorThemes?: ColorTheme[];
|
|
38
|
+
defaultTheme?: Theme;
|
|
39
|
+
defaultColorTheme?: ColorTheme;
|
|
40
|
+
animationType?: ThemeAnimationType;
|
|
41
|
+
duration?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Spaceman Theme Provider - Provides centralized theme state management
|
|
45
|
+
*
|
|
46
|
+
* This provider creates a single source of truth for theme state using the useThemeAnimation hook.
|
|
47
|
+
* All theme-related components should consume from this context to ensure synchronization.
|
|
48
|
+
*
|
|
49
|
+
* @param children - React children to wrap with theme context
|
|
50
|
+
* @param themes - Available theme options (default: ['light', 'dark', 'system'])
|
|
51
|
+
* @param colorThemes - Available color theme options (default: ['default'])
|
|
52
|
+
* @param defaultTheme - Default theme to use (default: 'system')
|
|
53
|
+
* @param defaultColorTheme - Default color theme to use (default: 'default')
|
|
54
|
+
* @param animationType - Animation type for theme transitions (default: CIRCLE)
|
|
55
|
+
* @param duration - Animation duration in milliseconds (default: 750)
|
|
56
|
+
*/
|
|
57
|
+
declare const SpacemanThemeProvider: React.FC<SpacemanThemeProviderProps>;
|
|
58
|
+
/**
|
|
59
|
+
* Hook to consume the Spaceman Theme context
|
|
60
|
+
*
|
|
61
|
+
* @returns Theme context value with all theme state and methods
|
|
62
|
+
* @throws Error if used outside of SpacemanThemeProvider
|
|
63
|
+
*/
|
|
64
|
+
declare const useSpacemanTheme: () => SpacemanThemeContextType;
|
|
65
|
+
|
|
66
|
+
interface NextThemeContextType {
|
|
67
|
+
ref: React.RefObject<HTMLButtonElement | null>;
|
|
68
|
+
theme: Theme;
|
|
69
|
+
colorTheme: ColorTheme;
|
|
70
|
+
resolvedTheme: 'light' | 'dark';
|
|
71
|
+
systemTheme: 'light' | 'dark';
|
|
72
|
+
setTheme: (theme: Theme) => void;
|
|
73
|
+
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
74
|
+
switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>;
|
|
75
|
+
switchColorTheme: (colorTheme: string) => void;
|
|
76
|
+
toggleTheme: (animationOff?: boolean) => Promise<void>;
|
|
77
|
+
toggleLightTheme: (animationOff?: boolean) => Promise<void>;
|
|
78
|
+
toggleDarkTheme: (animationOff?: boolean) => Promise<void>;
|
|
79
|
+
toggleColorTheme: () => void;
|
|
80
|
+
createColorThemeToggle: (targetColorTheme: string) => () => void;
|
|
81
|
+
isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
82
|
+
switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
83
|
+
}
|
|
84
|
+
interface NextThemeProviderProps {
|
|
85
|
+
children: React.ReactNode;
|
|
86
|
+
themes?: Theme[];
|
|
87
|
+
colorThemes?: ColorTheme[];
|
|
88
|
+
defaultTheme?: Theme;
|
|
89
|
+
defaultColorTheme?: ColorTheme;
|
|
90
|
+
animationType?: ThemeAnimationType;
|
|
91
|
+
duration?: number;
|
|
92
|
+
storageKey?: string;
|
|
93
|
+
colorStorageKey?: string;
|
|
94
|
+
attribute?: 'class' | 'data-theme';
|
|
95
|
+
value?: Record<string, string>;
|
|
96
|
+
enableSystem?: boolean;
|
|
97
|
+
enableColorScheme?: boolean;
|
|
98
|
+
disableTransitionOnChange?: boolean;
|
|
99
|
+
forcedTheme?: Theme;
|
|
100
|
+
nonce?: string;
|
|
101
|
+
scriptProps?: Omit<React.ScriptHTMLAttributes<HTMLScriptElement>, 'dangerouslySetInnerHTML' | 'nonce'>;
|
|
102
|
+
colorThemePrefix?: string;
|
|
103
|
+
globalClassName?: string;
|
|
104
|
+
disableAnimationOnInit?: boolean;
|
|
105
|
+
disablePreHydrationScript?: boolean;
|
|
106
|
+
onThemeChange?: (theme: Theme) => void;
|
|
107
|
+
onColorThemeChange?: (colorTheme: ColorTheme) => void;
|
|
108
|
+
}
|
|
109
|
+
declare const NextThemeProvider: React.FC<NextThemeProviderProps>;
|
|
110
|
+
declare const ThemeProvider: React.FC<NextThemeProviderProps>;
|
|
111
|
+
declare const useNextTheme: () => NextThemeContextType;
|
|
112
|
+
declare const useTheme: () => NextThemeContextType;
|
|
113
|
+
|
|
114
|
+
interface TanStackThemeContextType {
|
|
115
|
+
ref: React.RefObject<HTMLButtonElement | null>;
|
|
116
|
+
theme: Theme;
|
|
117
|
+
colorTheme: ColorTheme;
|
|
118
|
+
resolvedTheme: 'light' | 'dark';
|
|
119
|
+
systemTheme: 'light' | 'dark';
|
|
120
|
+
isHydrated: boolean;
|
|
121
|
+
setTheme: (theme: Theme) => void;
|
|
122
|
+
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
123
|
+
switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>;
|
|
124
|
+
switchColorTheme: (colorTheme: string) => void;
|
|
125
|
+
toggleTheme: (animationOff?: boolean) => Promise<void>;
|
|
126
|
+
toggleLightTheme: (animationOff?: boolean) => Promise<void>;
|
|
127
|
+
toggleDarkTheme: (animationOff?: boolean) => Promise<void>;
|
|
128
|
+
toggleColorTheme: () => void;
|
|
129
|
+
createColorThemeToggle: (targetColorTheme: string) => () => void;
|
|
130
|
+
isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
131
|
+
switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
interface TanStackThemeProviderProps {
|
|
134
|
+
children: ReactNode;
|
|
135
|
+
themes?: Theme[];
|
|
136
|
+
colorThemes?: ColorTheme[];
|
|
137
|
+
defaultTheme?: Theme;
|
|
138
|
+
defaultColorTheme?: ColorTheme;
|
|
139
|
+
animationType?: ThemeAnimationType;
|
|
140
|
+
duration?: number;
|
|
141
|
+
storageKey?: string;
|
|
142
|
+
colorStorageKey?: string;
|
|
143
|
+
globalClassName?: string;
|
|
144
|
+
colorThemePrefix?: string;
|
|
145
|
+
serverTheme?: 'light' | 'dark' | 'system';
|
|
146
|
+
serverColorTheme?: ColorTheme;
|
|
147
|
+
systemThemeMode?: SystemThemeMode;
|
|
148
|
+
onServerThemeChange?: (theme: Theme) => Promise<void> | void;
|
|
149
|
+
onServerColorThemeChange?: (colorTheme: ColorTheme) => Promise<void> | void;
|
|
150
|
+
}
|
|
151
|
+
interface TanStackStartThemeScriptProps {
|
|
152
|
+
storageKey?: string;
|
|
153
|
+
colorStorageKey?: string;
|
|
154
|
+
defaultTheme?: Theme;
|
|
155
|
+
defaultColorTheme?: ColorTheme;
|
|
156
|
+
globalClassName?: string;
|
|
157
|
+
colorThemePrefix?: string;
|
|
158
|
+
nonce?: string;
|
|
159
|
+
systemThemeMode?: SystemThemeMode;
|
|
160
|
+
}
|
|
161
|
+
declare const TanStackStartThemeScript: React.FC<TanStackStartThemeScriptProps>;
|
|
162
|
+
declare const TanStackThemeProvider: React.FC<TanStackThemeProviderProps>;
|
|
163
|
+
declare const useTanStackTheme: () => TanStackThemeContextType;
|
|
164
|
+
|
|
165
|
+
interface ViteThemeContextType {
|
|
166
|
+
ref: React.RefObject<HTMLButtonElement | null>;
|
|
167
|
+
theme: Theme;
|
|
168
|
+
colorTheme: ColorTheme;
|
|
169
|
+
resolvedTheme: 'light' | 'dark';
|
|
170
|
+
systemTheme: 'light' | 'dark';
|
|
171
|
+
setTheme: (theme: Theme) => void;
|
|
172
|
+
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
173
|
+
switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>;
|
|
174
|
+
switchColorTheme: (colorTheme: string) => void;
|
|
175
|
+
toggleTheme: (animationOff?: boolean) => Promise<void>;
|
|
176
|
+
toggleLightTheme: (animationOff?: boolean) => Promise<void>;
|
|
177
|
+
toggleDarkTheme: (animationOff?: boolean) => Promise<void>;
|
|
178
|
+
toggleColorTheme: () => void;
|
|
179
|
+
createColorThemeToggle: (targetColorTheme: string) => () => void;
|
|
180
|
+
isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
181
|
+
switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
182
|
+
}
|
|
183
|
+
interface ViteThemeProviderProps {
|
|
184
|
+
children: ReactNode;
|
|
185
|
+
themes?: Theme[];
|
|
186
|
+
colorThemes?: ColorTheme[];
|
|
187
|
+
defaultTheme?: Theme;
|
|
188
|
+
defaultColorTheme?: ColorTheme;
|
|
189
|
+
animationType?: ThemeAnimationType;
|
|
190
|
+
duration?: number;
|
|
191
|
+
attribute?: 'class' | 'data-theme';
|
|
192
|
+
disableTransitionOnChange?: boolean;
|
|
193
|
+
storageKey?: string;
|
|
194
|
+
colorStorageKey?: string;
|
|
195
|
+
globalClassName?: string;
|
|
196
|
+
colorThemePrefix?: string;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Vite Theme Provider - Optimized for Vite SPA applications
|
|
200
|
+
*
|
|
201
|
+
* This provider is designed for Vite-based single-page applications with optional
|
|
202
|
+
* transition disabling to prevent flash during theme switches.
|
|
203
|
+
*
|
|
204
|
+
* Note: For flash prevention on initial load, add a script to your index.html
|
|
205
|
+
* or inject it via Vite plugin to apply theme before React loads.
|
|
206
|
+
*
|
|
207
|
+
* @param children - React children to wrap with theme context
|
|
208
|
+
* @param themes - Available theme options
|
|
209
|
+
* @param colorThemes - Available color theme options
|
|
210
|
+
* @param defaultTheme - Default theme to use
|
|
211
|
+
* @param defaultColorTheme - Default color theme to use
|
|
212
|
+
* @param animationType - Animation type for theme transitions
|
|
213
|
+
* @param duration - Animation duration in milliseconds
|
|
214
|
+
* @param attribute - HTML attribute to use for theme ('class' or 'data-theme')
|
|
215
|
+
* @param disableTransitionOnChange - Temporarily disable CSS transitions during theme switch
|
|
216
|
+
* @param storageKey - LocalStorage key for theme preference
|
|
217
|
+
* @param colorStorageKey - LocalStorage key for color theme preference
|
|
218
|
+
* @param globalClassName - Class name for dark theme (when using 'class' attribute)
|
|
219
|
+
* @param colorThemePrefix - Prefix for color theme classes
|
|
220
|
+
*/
|
|
221
|
+
declare const ViteThemeProvider: React.FC<ViteThemeProviderProps>;
|
|
222
|
+
declare const useViteTheme: () => ViteThemeContextType;
|
|
223
|
+
|
|
224
|
+
export { ColorTheme, NextThemeProvider, SpacemanThemeProvider, SystemThemeMode, TanStackStartThemeScript, TanStackThemeProvider, Theme, ThemeAnimationType, ThemeProvider, ThemeSelector, ThemeSelectorProps, ThemeSwitcher, ThemeSwitcherProps, UseThemeAnimationProps, UseThemeAnimationReturn, ViteThemeProvider, useNextTheme, useSpacemanTheme, useTanStackTheme, useTheme, useThemeAnimation, useViteTheme };
|