uitheme-web 1.0.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/LICENSE +21 -0
- package/README.md +226 -0
- package/dist/constants-n21pnuRC.d.cts +106 -0
- package/dist/constants-n21pnuRC.d.ts +106 -0
- package/dist/core/index.cjs +272 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +33 -0
- package/dist/core/index.d.ts +33 -0
- package/dist/core/index.js +248 -0
- package/dist/core/index.js.map +1 -0
- package/dist/react/index.cjs +1793 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +637 -0
- package/dist/react/index.d.ts +637 -0
- package/dist/react/index.js +1732 -0
- package/dist/react/index.js.map +1 -0
- package/dist/tanstack/index.cjs +32 -0
- package/dist/tanstack/index.cjs.map +1 -0
- package/dist/tanstack/index.d.cts +36 -0
- package/dist/tanstack/index.d.ts +36 -0
- package/dist/tanstack/index.js +27 -0
- package/dist/tanstack/index.js.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
import { a as ThemeAnimationType, T as Theme, C as ColorTheme, S as SlideDirection } from '../constants-n21pnuRC.cjs';
|
|
2
|
+
export { A as AnimationConfig, l as COLOR_STORAGE_KEY, m as COLOR_THEME_PREFIX, o as DEFAULT_BLUR_AMOUNT, D as DEFAULT_DURATION, n as DEFAULT_EASING, q as DEFAULT_STYLE_ID, G as GLOBAL_CLASS_NAME, k as STORAGE_KEY, b as ThemeConfig, c as ThemeState, g as getSystemTheme, i as injectBaseStyles, p as prefersReducedMotion, r as resolveTheme, t as resolveThemeForServer, s as supportsViewTransitions } from '../constants-n21pnuRC.cjs';
|
|
3
|
+
import * as React$1 from 'react';
|
|
4
|
+
import React__default, { RefObject, ReactNode } from 'react';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
7
|
+
|
|
8
|
+
/** System theme resolution mode */
|
|
9
|
+
type SystemThemeMode = 'css' | 'js';
|
|
10
|
+
/**
|
|
11
|
+
* Props for the useTheme hook
|
|
12
|
+
*/
|
|
13
|
+
interface UseThemeProps {
|
|
14
|
+
/** Animation duration in milliseconds */
|
|
15
|
+
duration?: number;
|
|
16
|
+
/** CSS easing function */
|
|
17
|
+
easing?: string;
|
|
18
|
+
/** Type of animation to use */
|
|
19
|
+
animationType?: ThemeAnimationType;
|
|
20
|
+
/** Blur amount for blur circle animation */
|
|
21
|
+
blurAmount?: number;
|
|
22
|
+
/** ID for injected style element */
|
|
23
|
+
styleId?: string;
|
|
24
|
+
/** Available themes */
|
|
25
|
+
themes?: Theme[];
|
|
26
|
+
/** Available color themes */
|
|
27
|
+
colorThemes?: ColorTheme[];
|
|
28
|
+
/** Default theme on first load */
|
|
29
|
+
defaultTheme?: Theme;
|
|
30
|
+
/** Default color theme on first load */
|
|
31
|
+
defaultColorTheme?: ColorTheme;
|
|
32
|
+
/** Class name for dark mode */
|
|
33
|
+
globalClassName?: string;
|
|
34
|
+
/** Prefix for color theme classes */
|
|
35
|
+
colorThemePrefix?: string;
|
|
36
|
+
/** Storage key for theme */
|
|
37
|
+
storageKey?: string;
|
|
38
|
+
/** Storage key for color theme */
|
|
39
|
+
colorStorageKey?: string;
|
|
40
|
+
/** Controlled theme value */
|
|
41
|
+
theme?: Theme;
|
|
42
|
+
/** Controlled color theme value */
|
|
43
|
+
colorTheme?: ColorTheme;
|
|
44
|
+
/** Callback when theme changes */
|
|
45
|
+
onThemeChange?: (theme: Theme) => void;
|
|
46
|
+
/** Callback when color theme changes */
|
|
47
|
+
onColorThemeChange?: (colorTheme: ColorTheme) => void;
|
|
48
|
+
/** Direction for slide animation */
|
|
49
|
+
slideDirection?: SlideDirection;
|
|
50
|
+
/** Custom X start position for slide */
|
|
51
|
+
slideFromX?: number;
|
|
52
|
+
/** Custom Y start position for slide */
|
|
53
|
+
slideFromY?: number;
|
|
54
|
+
/** X end position for slide */
|
|
55
|
+
slideToX?: number;
|
|
56
|
+
/** Y end position for slide */
|
|
57
|
+
slideToY?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Server-provided initial theme (from cookie).
|
|
60
|
+
* When set, used as the initial useState value instead of reading localStorage.
|
|
61
|
+
*/
|
|
62
|
+
initialTheme?: Theme;
|
|
63
|
+
/**
|
|
64
|
+
* Server-provided initial color theme (from cookie).
|
|
65
|
+
* When set, used as the initial useState value instead of reading localStorage.
|
|
66
|
+
*/
|
|
67
|
+
initialColorTheme?: ColorTheme;
|
|
68
|
+
/**
|
|
69
|
+
* How to handle 'system' theme resolution.
|
|
70
|
+
* - 'css': Apply 'system' class on <html>, let CSS @media queries handle dark mode
|
|
71
|
+
* - 'js': Resolve via matchMedia in JS (current behavior)
|
|
72
|
+
* @default 'js'
|
|
73
|
+
*/
|
|
74
|
+
systemThemeMode?: SystemThemeMode;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Return type for the useTheme hook
|
|
78
|
+
*/
|
|
79
|
+
interface UseThemeReturn {
|
|
80
|
+
/** Ref to attach to the trigger button */
|
|
81
|
+
ref: RefObject<HTMLButtonElement | null>;
|
|
82
|
+
/** Current theme value */
|
|
83
|
+
theme: Theme;
|
|
84
|
+
/** Current color theme value */
|
|
85
|
+
colorTheme: ColorTheme;
|
|
86
|
+
/** Resolved theme (light or dark) */
|
|
87
|
+
resolvedTheme: 'light' | 'dark';
|
|
88
|
+
/** Set theme without animation */
|
|
89
|
+
setTheme: (theme: Theme) => void;
|
|
90
|
+
/** Set color theme */
|
|
91
|
+
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
92
|
+
/** Switch theme with animation */
|
|
93
|
+
switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>;
|
|
94
|
+
/** Switch color theme */
|
|
95
|
+
switchColorTheme: (colorTheme: string) => void;
|
|
96
|
+
/** Toggle between light and dark */
|
|
97
|
+
toggleTheme: (animationOff?: boolean) => Promise<void>;
|
|
98
|
+
/** Switch to light theme with animation */
|
|
99
|
+
toggleLightTheme: (animationOff?: boolean) => Promise<void>;
|
|
100
|
+
/** Switch to dark theme with animation */
|
|
101
|
+
toggleDarkTheme: (animationOff?: boolean) => Promise<void>;
|
|
102
|
+
/** Cycle through color themes */
|
|
103
|
+
toggleColorTheme: () => void;
|
|
104
|
+
/** Create a toggle function for a specific color theme */
|
|
105
|
+
createColorThemeToggle: (targetColorTheme: string) => () => void;
|
|
106
|
+
/** Check if a color theme is active */
|
|
107
|
+
isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Props for UIThemeSwitcher component
|
|
111
|
+
*/
|
|
112
|
+
interface UIThemeSwitcherProps {
|
|
113
|
+
/** Available themes */
|
|
114
|
+
themes?: Theme[];
|
|
115
|
+
/** Current theme (controlled) */
|
|
116
|
+
currentTheme?: Theme;
|
|
117
|
+
/** Callback when theme changes */
|
|
118
|
+
onThemeChange?: (theme: Theme) => void;
|
|
119
|
+
/** Animation type */
|
|
120
|
+
animationType?: ThemeAnimationType;
|
|
121
|
+
/** Animation duration */
|
|
122
|
+
duration?: number;
|
|
123
|
+
/** Additional CSS class */
|
|
124
|
+
className?: string;
|
|
125
|
+
/** Button size */
|
|
126
|
+
size?: 'sm' | 'md' | 'lg';
|
|
127
|
+
/** Button variant */
|
|
128
|
+
variant?: 'default' | 'outline' | 'ghost';
|
|
129
|
+
/** Custom icons for themes */
|
|
130
|
+
icons?: {
|
|
131
|
+
light?: React.ReactNode;
|
|
132
|
+
dark?: React.ReactNode;
|
|
133
|
+
system?: React.ReactNode;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Props for UIThemeSelector component
|
|
138
|
+
*/
|
|
139
|
+
interface UIThemeSelectorProps {
|
|
140
|
+
/** Available themes */
|
|
141
|
+
themes?: Theme[];
|
|
142
|
+
/** Available color themes */
|
|
143
|
+
colorThemes?: ColorTheme[];
|
|
144
|
+
/** Current theme (controlled) */
|
|
145
|
+
currentTheme?: Theme;
|
|
146
|
+
/** Current color theme (controlled) */
|
|
147
|
+
currentColorTheme?: ColorTheme;
|
|
148
|
+
/** Callback when theme changes */
|
|
149
|
+
onThemeChange?: (theme: Theme) => void;
|
|
150
|
+
/** Callback when color theme changes */
|
|
151
|
+
onColorThemeChange?: (colorTheme: ColorTheme) => void;
|
|
152
|
+
/** Animation type */
|
|
153
|
+
animationType?: ThemeAnimationType;
|
|
154
|
+
/** Animation duration */
|
|
155
|
+
duration?: number;
|
|
156
|
+
/** Additional CSS class */
|
|
157
|
+
className?: string;
|
|
158
|
+
/** Placeholder text */
|
|
159
|
+
placeholder?: string;
|
|
160
|
+
/** Label for theme selector */
|
|
161
|
+
themeLabel?: string;
|
|
162
|
+
/** Label for color theme selector */
|
|
163
|
+
colorThemeLabel?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* React hook for theme switching with View Transitions API animations
|
|
168
|
+
* @param props - Configuration options for the theme animation
|
|
169
|
+
* @returns Theme state and control functions
|
|
170
|
+
*/
|
|
171
|
+
declare const useTheme: (props?: UseThemeProps) => UseThemeReturn;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Context type for the Next.js UI Theme Provider
|
|
175
|
+
*/
|
|
176
|
+
interface NextUIThemeContextType {
|
|
177
|
+
/** Ref to attach to the trigger button */
|
|
178
|
+
ref: React__default.RefObject<HTMLButtonElement | null>;
|
|
179
|
+
/** Current theme value */
|
|
180
|
+
theme: Theme;
|
|
181
|
+
/** Current color theme value */
|
|
182
|
+
colorTheme: ColorTheme;
|
|
183
|
+
/** Resolved theme (light or dark) */
|
|
184
|
+
resolvedTheme: 'light' | 'dark';
|
|
185
|
+
/** System theme preference */
|
|
186
|
+
systemTheme: 'light' | 'dark';
|
|
187
|
+
/** Set theme without animation */
|
|
188
|
+
setTheme: (theme: Theme) => void;
|
|
189
|
+
/** Set color theme */
|
|
190
|
+
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
191
|
+
/** Switch theme with animation */
|
|
192
|
+
switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>;
|
|
193
|
+
/** Switch color theme */
|
|
194
|
+
switchColorTheme: (colorTheme: string) => void;
|
|
195
|
+
/** Toggle between light and dark */
|
|
196
|
+
toggleTheme: (animationOff?: boolean) => Promise<void>;
|
|
197
|
+
/** Switch to light theme with animation */
|
|
198
|
+
toggleLightTheme: (animationOff?: boolean) => Promise<void>;
|
|
199
|
+
/** Switch to dark theme with animation */
|
|
200
|
+
toggleDarkTheme: (animationOff?: boolean) => Promise<void>;
|
|
201
|
+
/** Cycle through color themes */
|
|
202
|
+
toggleColorTheme: () => void;
|
|
203
|
+
/** Create a toggle function for a specific color theme */
|
|
204
|
+
createColorThemeToggle: (targetColorTheme: string) => () => void;
|
|
205
|
+
/** Check if a color theme is active */
|
|
206
|
+
isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
207
|
+
/** Switch theme from a specific element (for animation origin) */
|
|
208
|
+
switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Props for the Next.js UI Theme Provider
|
|
212
|
+
*/
|
|
213
|
+
interface NextUIThemeProviderProps {
|
|
214
|
+
/** React children to wrap with theme context */
|
|
215
|
+
children: ReactNode;
|
|
216
|
+
/** Available theme options */
|
|
217
|
+
themes?: Theme[];
|
|
218
|
+
/** Available color theme options */
|
|
219
|
+
colorThemes?: ColorTheme[];
|
|
220
|
+
/** Default theme to use */
|
|
221
|
+
defaultTheme?: Theme;
|
|
222
|
+
/** Default color theme to use */
|
|
223
|
+
defaultColorTheme?: ColorTheme;
|
|
224
|
+
/** Animation type for theme transitions */
|
|
225
|
+
animationType?: ThemeAnimationType;
|
|
226
|
+
/** Animation duration in milliseconds */
|
|
227
|
+
duration?: number;
|
|
228
|
+
/** Storage key for theme preference */
|
|
229
|
+
storageKey?: string;
|
|
230
|
+
/** Storage key for color theme preference */
|
|
231
|
+
colorStorageKey?: string;
|
|
232
|
+
/** HTML attribute to use for theme ('class' or 'data-theme') */
|
|
233
|
+
attribute?: 'class' | 'data-theme';
|
|
234
|
+
/** Class name for dark theme (when using 'class' attribute) */
|
|
235
|
+
globalClassName?: string;
|
|
236
|
+
/** Prefix for color theme classes */
|
|
237
|
+
colorThemePrefix?: string;
|
|
238
|
+
/** CSP nonce for inline script (SSR apps) */
|
|
239
|
+
nonce?: string;
|
|
240
|
+
/** Skip animation during initial hydration */
|
|
241
|
+
disableAnimationOnInit?: boolean;
|
|
242
|
+
/** Disable flash prevention script (for SPAs without SSR) */
|
|
243
|
+
disablePreHydrationScript?: boolean;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Next.js UI Theme Provider - Universal React theme management with animations
|
|
247
|
+
*
|
|
248
|
+
* This provider works with Next.js and provides flash prevention
|
|
249
|
+
* via pre-hydration script injection.
|
|
250
|
+
*
|
|
251
|
+
* Features:
|
|
252
|
+
* - Pre-hydration script for flash prevention (SSR apps)
|
|
253
|
+
* - Animated theme transitions via View Transitions API
|
|
254
|
+
* - Multi-dimensional theming (theme + colorTheme)
|
|
255
|
+
* - System theme detection
|
|
256
|
+
* - CSP support via nonce prop
|
|
257
|
+
*
|
|
258
|
+
* @param props - Provider configuration options
|
|
259
|
+
*/
|
|
260
|
+
declare const NextUIThemeProvider: React__default.FC<NextUIThemeProviderProps>;
|
|
261
|
+
/**
|
|
262
|
+
* Hook to consume the Next.js UI Theme context
|
|
263
|
+
*
|
|
264
|
+
* @returns Theme context value with all theme state and methods
|
|
265
|
+
* @throws Error if used outside of NextUIThemeProvider
|
|
266
|
+
*/
|
|
267
|
+
declare const useNextUITheme: () => NextUIThemeContextType;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Context type for the TanStack Start UI Theme Provider
|
|
271
|
+
*/
|
|
272
|
+
interface TanStackUIThemeContextType {
|
|
273
|
+
/** Ref to attach to the trigger button */
|
|
274
|
+
ref: React__default.RefObject<HTMLButtonElement | null>;
|
|
275
|
+
/** Current theme value */
|
|
276
|
+
theme: Theme;
|
|
277
|
+
/** Current color theme value */
|
|
278
|
+
colorTheme: ColorTheme;
|
|
279
|
+
/** Resolved theme (light or dark) */
|
|
280
|
+
resolvedTheme: 'light' | 'dark';
|
|
281
|
+
/** System theme preference */
|
|
282
|
+
systemTheme: 'light' | 'dark';
|
|
283
|
+
/** Whether the component is hydrated */
|
|
284
|
+
isHydrated: boolean;
|
|
285
|
+
/** Set theme without animation */
|
|
286
|
+
setTheme: (theme: Theme) => void;
|
|
287
|
+
/** Set color theme */
|
|
288
|
+
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
289
|
+
/** Switch theme with animation */
|
|
290
|
+
switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>;
|
|
291
|
+
/** Switch color theme */
|
|
292
|
+
switchColorTheme: (colorTheme: string) => void;
|
|
293
|
+
/** Toggle between light and dark */
|
|
294
|
+
toggleTheme: (animationOff?: boolean) => Promise<void>;
|
|
295
|
+
/** Switch to light theme with animation */
|
|
296
|
+
toggleLightTheme: (animationOff?: boolean) => Promise<void>;
|
|
297
|
+
/** Switch to dark theme with animation */
|
|
298
|
+
toggleDarkTheme: (animationOff?: boolean) => Promise<void>;
|
|
299
|
+
/** Cycle through color themes */
|
|
300
|
+
toggleColorTheme: () => void;
|
|
301
|
+
/** Create a toggle function for a specific color theme */
|
|
302
|
+
createColorThemeToggle: (targetColorTheme: string) => () => void;
|
|
303
|
+
/** Check if a color theme is active */
|
|
304
|
+
isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
305
|
+
/** Switch theme from a specific element (for animation origin) */
|
|
306
|
+
switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Props for the TanStack Start UI Theme Provider
|
|
310
|
+
*/
|
|
311
|
+
interface TanStackUIThemeProviderProps {
|
|
312
|
+
/** React children to wrap with theme context */
|
|
313
|
+
children: ReactNode;
|
|
314
|
+
/** Available theme options */
|
|
315
|
+
themes?: Theme[];
|
|
316
|
+
/** Available color theme options */
|
|
317
|
+
colorThemes?: ColorTheme[];
|
|
318
|
+
/** Default theme to use */
|
|
319
|
+
defaultTheme?: Theme;
|
|
320
|
+
/** Default color theme to use */
|
|
321
|
+
defaultColorTheme?: ColorTheme;
|
|
322
|
+
/** Animation type for theme transitions */
|
|
323
|
+
animationType?: ThemeAnimationType;
|
|
324
|
+
/** Animation duration in milliseconds */
|
|
325
|
+
duration?: number;
|
|
326
|
+
/** Storage key for theme preference */
|
|
327
|
+
storageKey?: string;
|
|
328
|
+
/** Storage key for color theme preference */
|
|
329
|
+
colorStorageKey?: string;
|
|
330
|
+
/** Class name for dark theme */
|
|
331
|
+
globalClassName?: string;
|
|
332
|
+
/** Prefix for color theme classes */
|
|
333
|
+
colorThemePrefix?: string;
|
|
334
|
+
/**
|
|
335
|
+
* Server-resolved theme class from cookie (e.g., 'light', 'dark', 'system').
|
|
336
|
+
* When provided, prevents flash by using this as the initial value during SSR.
|
|
337
|
+
* Typically obtained via `getThemeServerFn()` in `beforeLoad`.
|
|
338
|
+
*/
|
|
339
|
+
serverTheme?: 'light' | 'dark' | 'system';
|
|
340
|
+
/**
|
|
341
|
+
* Server-resolved color theme from cookie.
|
|
342
|
+
* When provided, prevents color theme flash during SSR.
|
|
343
|
+
*/
|
|
344
|
+
serverColorTheme?: string;
|
|
345
|
+
/**
|
|
346
|
+
* How to handle 'system' theme resolution.
|
|
347
|
+
* - 'css': Apply 'system' class on <html>, let CSS @media queries handle it (zero flash, requires CSS setup)
|
|
348
|
+
* - 'js': Resolve via matchMedia in JS (works with existing CSS, may flash briefly)
|
|
349
|
+
* @default 'css'
|
|
350
|
+
*/
|
|
351
|
+
systemThemeMode?: SystemThemeMode;
|
|
352
|
+
/**
|
|
353
|
+
* Callback to persist theme to server (cookie).
|
|
354
|
+
* Called alongside localStorage updates when user changes theme.
|
|
355
|
+
* Typically `setThemeServerFn` from `createThemeServerFns()`.
|
|
356
|
+
*/
|
|
357
|
+
onServerThemeChange?: (theme: Theme) => Promise<void> | void;
|
|
358
|
+
/**
|
|
359
|
+
* Callback to persist color theme to server (cookie).
|
|
360
|
+
* Called alongside localStorage updates when user changes color theme.
|
|
361
|
+
* Typically `setColorThemeServerFn` from `createThemeServerFns()`.
|
|
362
|
+
*/
|
|
363
|
+
onServerColorThemeChange?: (colorTheme: string) => Promise<void> | void;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Props for the TanStackStartThemeScript component
|
|
367
|
+
*/
|
|
368
|
+
interface TanStackStartThemeScriptProps {
|
|
369
|
+
/** Storage key for theme preference in localStorage */
|
|
370
|
+
storageKey?: string;
|
|
371
|
+
/** Storage key for color theme preference in localStorage */
|
|
372
|
+
colorStorageKey?: string;
|
|
373
|
+
/** Default theme when nothing is stored */
|
|
374
|
+
defaultTheme?: Theme;
|
|
375
|
+
/** Default color theme when nothing is stored */
|
|
376
|
+
defaultColorTheme?: ColorTheme;
|
|
377
|
+
/** Class name for dark theme */
|
|
378
|
+
globalClassName?: string;
|
|
379
|
+
/** Prefix for color theme classes */
|
|
380
|
+
colorThemePrefix?: string;
|
|
381
|
+
/** CSP nonce for the inline script */
|
|
382
|
+
nonce?: string;
|
|
383
|
+
/**
|
|
384
|
+
* How to handle 'system' theme.
|
|
385
|
+
* - 'css': Apply 'system' class (let CSS handle dark via media query)
|
|
386
|
+
* - 'js': Resolve via matchMedia and apply 'dark' or remove class
|
|
387
|
+
* @default 'js'
|
|
388
|
+
*/
|
|
389
|
+
systemThemeMode?: SystemThemeMode;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Pre-hydration script for TanStack Start applications.
|
|
393
|
+
*
|
|
394
|
+
* Place this in the `<head>` of your `shellComponent` to prevent theme flash
|
|
395
|
+
* when not using the cookie-based approach.
|
|
396
|
+
*
|
|
397
|
+
* Reads the theme preference from localStorage and applies the correct classes
|
|
398
|
+
* and colorScheme to `<html>` before React hydrates.
|
|
399
|
+
*
|
|
400
|
+
* @example
|
|
401
|
+
* ```tsx
|
|
402
|
+
* function RootDocument({ children }: { children: React.ReactNode }) {
|
|
403
|
+
* return (
|
|
404
|
+
* <html lang="en" suppressHydrationWarning>
|
|
405
|
+
* <head>
|
|
406
|
+
* <TanStackStartThemeScript />
|
|
407
|
+
* <HeadContent />
|
|
408
|
+
* </head>
|
|
409
|
+
* <body>{children}<Scripts /></body>
|
|
410
|
+
* </html>
|
|
411
|
+
* );
|
|
412
|
+
* }
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
declare const TanStackStartThemeScript: React__default.FC<TanStackStartThemeScriptProps>;
|
|
416
|
+
/**
|
|
417
|
+
* TanStack Start UI Theme Provider - Flash-free dark mode for TanStack Start
|
|
418
|
+
*
|
|
419
|
+
* Supports two approaches for preventing theme flash:
|
|
420
|
+
*
|
|
421
|
+
* **Option A — Cookie-based (recommended, zero flash):**
|
|
422
|
+
* Pass `serverTheme` and `serverColorTheme` from route context (obtained via
|
|
423
|
+
* `getThemeServerFn()` in `beforeLoad`). The server renders the correct classes
|
|
424
|
+
* on `<html>`, and this provider syncs localStorage on the client.
|
|
425
|
+
*
|
|
426
|
+
* **Option B — Pre-hydration script:**
|
|
427
|
+
* Use `<TanStackStartThemeScript>` in your shellComponent's `<head>`.
|
|
428
|
+
* Reads from localStorage before React hydrates.
|
|
429
|
+
*
|
|
430
|
+
* Both approaches support `systemThemeMode`:
|
|
431
|
+
* - `'css'`: Applies 'system' class, CSS media queries handle dark mode
|
|
432
|
+
* - `'js'`: Resolves system theme via matchMedia in JS
|
|
433
|
+
*
|
|
434
|
+
* @param props - Provider configuration options
|
|
435
|
+
*/
|
|
436
|
+
declare const TanStackUIThemeProvider: React__default.FC<TanStackUIThemeProviderProps>;
|
|
437
|
+
/**
|
|
438
|
+
* Hook to consume the TanStack UI Theme context
|
|
439
|
+
*
|
|
440
|
+
* @returns Theme context value with all theme state and methods
|
|
441
|
+
* @throws Error if used outside of TanStackUIThemeProvider
|
|
442
|
+
*/
|
|
443
|
+
declare const useTanStackUITheme: () => TanStackUIThemeContextType;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Context type for the Vite UI Theme Provider
|
|
447
|
+
*/
|
|
448
|
+
interface ViteUIThemeContextType {
|
|
449
|
+
/** Ref to attach to the trigger button */
|
|
450
|
+
ref: React__default.RefObject<HTMLButtonElement | null>;
|
|
451
|
+
/** Current theme value */
|
|
452
|
+
theme: Theme;
|
|
453
|
+
/** Current color theme value */
|
|
454
|
+
colorTheme: ColorTheme;
|
|
455
|
+
/** Resolved theme (light or dark) */
|
|
456
|
+
resolvedTheme: 'light' | 'dark';
|
|
457
|
+
/** System theme preference */
|
|
458
|
+
systemTheme: 'light' | 'dark';
|
|
459
|
+
/** Set theme without animation */
|
|
460
|
+
setTheme: (theme: Theme) => void;
|
|
461
|
+
/** Set color theme */
|
|
462
|
+
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
463
|
+
/** Switch theme with animation */
|
|
464
|
+
switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>;
|
|
465
|
+
/** Switch color theme */
|
|
466
|
+
switchColorTheme: (colorTheme: string) => void;
|
|
467
|
+
/** Toggle between light and dark */
|
|
468
|
+
toggleTheme: (animationOff?: boolean) => Promise<void>;
|
|
469
|
+
/** Switch to light theme with animation */
|
|
470
|
+
toggleLightTheme: (animationOff?: boolean) => Promise<void>;
|
|
471
|
+
/** Switch to dark theme with animation */
|
|
472
|
+
toggleDarkTheme: (animationOff?: boolean) => Promise<void>;
|
|
473
|
+
/** Cycle through color themes */
|
|
474
|
+
toggleColorTheme: () => void;
|
|
475
|
+
/** Create a toggle function for a specific color theme */
|
|
476
|
+
createColorThemeToggle: (targetColorTheme: string) => () => void;
|
|
477
|
+
/** Check if a color theme is active */
|
|
478
|
+
isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
479
|
+
/** Switch theme from a specific element (for animation origin) */
|
|
480
|
+
switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Props for the Vite UI Theme Provider
|
|
484
|
+
*/
|
|
485
|
+
interface ViteUIThemeProviderProps {
|
|
486
|
+
/** React children to wrap with theme context */
|
|
487
|
+
children: ReactNode;
|
|
488
|
+
/** Available theme options */
|
|
489
|
+
themes?: Theme[];
|
|
490
|
+
/** Available color theme options */
|
|
491
|
+
colorThemes?: ColorTheme[];
|
|
492
|
+
/** Default theme to use */
|
|
493
|
+
defaultTheme?: Theme;
|
|
494
|
+
/** Default color theme to use */
|
|
495
|
+
defaultColorTheme?: ColorTheme;
|
|
496
|
+
/** Animation type for theme transitions */
|
|
497
|
+
animationType?: ThemeAnimationType;
|
|
498
|
+
/** Animation duration in milliseconds */
|
|
499
|
+
duration?: number;
|
|
500
|
+
/** Attribute to use for theme ('class' or 'data-theme') */
|
|
501
|
+
attribute?: 'class' | 'data-theme';
|
|
502
|
+
/** Disable transitions during theme change */
|
|
503
|
+
disableTransitionOnChange?: boolean;
|
|
504
|
+
/** Storage key for theme */
|
|
505
|
+
storageKey?: string;
|
|
506
|
+
/** Storage key for color theme */
|
|
507
|
+
colorStorageKey?: string;
|
|
508
|
+
/** Class name for dark mode */
|
|
509
|
+
globalClassName?: string;
|
|
510
|
+
/** Prefix for color theme classes */
|
|
511
|
+
colorThemePrefix?: string;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Vite UI Theme Provider - Theme provider optimized for Vite/SPA applications
|
|
515
|
+
*
|
|
516
|
+
* This provider includes additional features like transition disabling
|
|
517
|
+
* and system theme tracking that are useful in client-side applications.
|
|
518
|
+
*
|
|
519
|
+
* Note: For flash prevention on initial load, add a script to your index.html
|
|
520
|
+
* or inject it via Vite plugin to apply theme before React loads.
|
|
521
|
+
*
|
|
522
|
+
* @param props - Provider configuration options
|
|
523
|
+
*/
|
|
524
|
+
declare const ViteUIThemeProvider: React__default.FC<ViteUIThemeProviderProps>;
|
|
525
|
+
/**
|
|
526
|
+
* Hook to consume the Vite UI Theme context
|
|
527
|
+
*
|
|
528
|
+
* @returns Theme context value with all theme state and methods
|
|
529
|
+
* @throws Error if used outside of ViteUIThemeProvider
|
|
530
|
+
*/
|
|
531
|
+
declare const useViteUITheme: () => ViteUIThemeContextType;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Context type for the UI Theme Provider
|
|
535
|
+
*/
|
|
536
|
+
interface UIThemeContextType {
|
|
537
|
+
/** Ref to attach to the trigger button */
|
|
538
|
+
ref: React__default.RefObject<HTMLButtonElement | null>;
|
|
539
|
+
/** Current theme value */
|
|
540
|
+
theme: Theme;
|
|
541
|
+
/** Current color theme value */
|
|
542
|
+
colorTheme: ColorTheme;
|
|
543
|
+
/** Resolved theme (light or dark) */
|
|
544
|
+
resolvedTheme: 'light' | 'dark';
|
|
545
|
+
/** Set theme without animation */
|
|
546
|
+
setTheme: (theme: Theme) => void;
|
|
547
|
+
/** Set color theme */
|
|
548
|
+
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
549
|
+
/** Switch theme with animation */
|
|
550
|
+
switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>;
|
|
551
|
+
/** Switch color theme */
|
|
552
|
+
switchColorTheme: (colorTheme: string) => void;
|
|
553
|
+
/** Toggle between light and dark */
|
|
554
|
+
toggleTheme: (animationOff?: boolean) => Promise<void>;
|
|
555
|
+
/** Switch to light theme with animation */
|
|
556
|
+
toggleLightTheme: (animationOff?: boolean) => Promise<void>;
|
|
557
|
+
/** Switch to dark theme with animation */
|
|
558
|
+
toggleDarkTheme: (animationOff?: boolean) => Promise<void>;
|
|
559
|
+
/** Cycle through color themes */
|
|
560
|
+
toggleColorTheme: () => void;
|
|
561
|
+
/** Create a toggle function for a specific color theme */
|
|
562
|
+
createColorThemeToggle: (targetColorTheme: string) => () => void;
|
|
563
|
+
/** Check if a color theme is active */
|
|
564
|
+
isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
565
|
+
/** Switch theme from a specific element (for animation origin) */
|
|
566
|
+
switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Props for the UI Theme Provider
|
|
570
|
+
*/
|
|
571
|
+
interface UIThemeProviderProps {
|
|
572
|
+
/** React children to wrap with theme context */
|
|
573
|
+
children: ReactNode;
|
|
574
|
+
/** Available theme options */
|
|
575
|
+
themes?: Theme[];
|
|
576
|
+
/** Available color theme options */
|
|
577
|
+
colorThemes?: ColorTheme[];
|
|
578
|
+
/** Default theme to use */
|
|
579
|
+
defaultTheme?: Theme;
|
|
580
|
+
/** Default color theme to use */
|
|
581
|
+
defaultColorTheme?: ColorTheme;
|
|
582
|
+
/** Animation type for theme transitions */
|
|
583
|
+
animationType?: ThemeAnimationType;
|
|
584
|
+
/** Animation duration in milliseconds */
|
|
585
|
+
duration?: number;
|
|
586
|
+
/** Storage key for theme */
|
|
587
|
+
storageKey?: string;
|
|
588
|
+
/** Storage key for color theme */
|
|
589
|
+
colorStorageKey?: string;
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* UI Theme Provider - Provides centralized theme state management
|
|
593
|
+
*
|
|
594
|
+
* This provider creates a single source of truth for theme state using the useTheme hook.
|
|
595
|
+
* All theme-related components should consume from this context to ensure synchronization.
|
|
596
|
+
*
|
|
597
|
+
* @param props - Provider configuration options
|
|
598
|
+
*/
|
|
599
|
+
declare const UIThemeProvider: React__default.FC<UIThemeProviderProps>;
|
|
600
|
+
/**
|
|
601
|
+
* Hook to consume the UI Theme context
|
|
602
|
+
*
|
|
603
|
+
* @returns Theme context value with all theme state and methods
|
|
604
|
+
* @throws Error if used outside of UIThemeProvider
|
|
605
|
+
*/
|
|
606
|
+
declare const useUITheme: () => UIThemeContextType;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* UI Theme Switcher - A button group for switching between themes
|
|
610
|
+
*
|
|
611
|
+
* Can work both with UIThemeProvider context or standalone.
|
|
612
|
+
* When used with UIThemeProvider, it automatically syncs theme state.
|
|
613
|
+
*/
|
|
614
|
+
declare const UIThemeSwitcher: React__default.FC<UIThemeSwitcherProps>;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* UI Theme Selector - A dropdown selector for color themes
|
|
618
|
+
*
|
|
619
|
+
* Can work both with UIThemeProvider context or standalone.
|
|
620
|
+
* When used with UIThemeProvider, it automatically syncs theme state.
|
|
621
|
+
*/
|
|
622
|
+
declare const UIThemeSelector: React__default.FC<UIThemeSelectorProps>;
|
|
623
|
+
|
|
624
|
+
declare function UISelect({ ...props }: React$1.ComponentProps<typeof SelectPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
625
|
+
declare function UISelectGroup({ ...props }: React$1.ComponentProps<typeof SelectPrimitive.Group>): react_jsx_runtime.JSX.Element;
|
|
626
|
+
declare function UISelectValue({ ...props }: React$1.ComponentProps<typeof SelectPrimitive.Value>): react_jsx_runtime.JSX.Element;
|
|
627
|
+
declare function UISelectTrigger({ className, size, children, ...props }: React$1.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
|
628
|
+
size?: 'sm' | 'default';
|
|
629
|
+
}): react_jsx_runtime.JSX.Element;
|
|
630
|
+
declare function UISelectContent({ className, children, position, ...props }: React$1.ComponentProps<typeof SelectPrimitive.Content>): react_jsx_runtime.JSX.Element;
|
|
631
|
+
declare function UISelectLabel({ className, ...props }: React$1.ComponentProps<typeof SelectPrimitive.Label>): react_jsx_runtime.JSX.Element;
|
|
632
|
+
declare function UISelectItem({ className, children, ...props }: React$1.ComponentProps<typeof SelectPrimitive.Item>): react_jsx_runtime.JSX.Element;
|
|
633
|
+
declare function UISelectSeparator({ className, ...props }: React$1.ComponentProps<typeof SelectPrimitive.Separator>): react_jsx_runtime.JSX.Element;
|
|
634
|
+
declare function UISelectScrollUpButton({ className, ...props }: React$1.ComponentProps<typeof SelectPrimitive.ScrollUpButton>): react_jsx_runtime.JSX.Element;
|
|
635
|
+
declare function UISelectScrollDownButton({ className, ...props }: React$1.ComponentProps<typeof SelectPrimitive.ScrollDownButton>): react_jsx_runtime.JSX.Element;
|
|
636
|
+
|
|
637
|
+
export { ColorTheme, type NextUIThemeContextType, NextUIThemeProvider, type NextUIThemeProviderProps, SlideDirection, type SystemThemeMode, TanStackStartThemeScript, type TanStackStartThemeScriptProps, type TanStackUIThemeContextType, TanStackUIThemeProvider, type TanStackUIThemeProviderProps, Theme, ThemeAnimationType, UISelect, UISelectContent, UISelectGroup, UISelectItem, UISelectLabel, UISelectScrollDownButton, UISelectScrollUpButton, UISelectSeparator, UISelectTrigger, UISelectValue, type UIThemeContextType, UIThemeProvider, type UIThemeProviderProps, UIThemeSelector, type UIThemeSelectorProps, UIThemeSwitcher, type UIThemeSwitcherProps, type UseThemeProps, type UseThemeReturn, type ViteUIThemeContextType, ViteUIThemeProvider, type ViteUIThemeProviderProps, useNextUITheme, useTanStackUITheme, useTheme, useUITheme, useViteUITheme };
|