uitheme-web 1.2.0 → 2.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/README.md +56 -314
- package/dist/chunk-4UXANDJ5.cjs +26 -0
- package/dist/chunk-C4YNAGUP.js +26 -0
- package/dist/chunk-CTNYTI5Q.js +1 -0
- package/dist/{chunk-WFG34KG5.js → chunk-CY5E6WU4.js} +3 -3
- package/dist/chunk-CYGYUQUK.cjs +1 -0
- package/dist/chunk-EKVKQZNN.js +12 -0
- package/dist/chunk-EQPK72XK.js +14 -0
- package/dist/{chunk-W4YFUPGE.cjs → chunk-I5GA5T23.cjs} +3 -3
- package/dist/chunk-KQSBORXP.cjs +12 -0
- package/dist/chunk-NDNCNR4X.js +1 -0
- package/dist/chunk-SO3CO44A.js +1 -0
- package/dist/{constants-DmZ7yAIL.d.cts → constants-9M8X-rnX.d.cts} +2 -68
- package/dist/{constants-DmZ7yAIL.d.ts → constants-PAa1nGZ0.d.ts} +2 -68
- package/dist/controller-83zmHd-p.d.cts +76 -0
- package/dist/controller-DnMwV2nl.d.ts +76 -0
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +7 -5
- package/dist/core/index.d.ts +7 -5
- package/dist/core/index.js +1 -1
- package/dist/index-Dn3XRBX1.d.ts +106 -0
- package/dist/index-DqlTGyMr.d.cts +106 -0
- package/dist/next/index.cjs +2 -0
- package/dist/next/index.d.cts +4 -0
- package/dist/next/index.d.ts +4 -0
- package/dist/next/index.js +2 -0
- package/dist/nuxt.d.ts +10 -0
- package/dist/nuxt.js +34 -0
- package/dist/react/index.cjs +11 -89
- package/dist/react/index.d.cts +23 -279
- package/dist/react/index.d.ts +23 -279
- package/dist/react/index.js +11 -89
- package/dist/server/index.cjs +14 -0
- package/dist/server/index.d.cts +11 -0
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +14 -0
- package/dist/tanstack/index.cjs +1 -1
- package/dist/tanstack/index.d.cts +5 -3
- package/dist/tanstack/index.d.ts +5 -3
- package/dist/tanstack/index.js +1 -1
- package/dist/types-CrR56NLm.d.cts +79 -0
- package/dist/types-CrR56NLm.d.ts +79 -0
- package/dist/types-Dd4EU8V9.d.ts +96 -0
- package/dist/vue/bootstrap.d.ts +13 -0
- package/dist/vue/bootstrap.js +1 -0
- package/dist/vue/index.d.ts +39 -0
- package/dist/vue/index.js +1 -0
- package/package.json +68 -17
- package/dist/chunk-DFJEYTIW.js +0 -12
- package/dist/chunk-V3LMT5IJ.cjs +0 -12
- package/dist/cli/index.js +0 -39
package/dist/react/index.d.ts
CHANGED
|
@@ -1,255 +1,15 @@
|
|
|
1
1
|
export { p as preloadThemeLogo } from '../logo-DtwtRv4y.js';
|
|
2
|
-
import {
|
|
3
|
-
export { A as AnimationConfig,
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
2
|
+
import { c as Theme, C as ColorTheme, T as ThemeAnimationOptions, a as ThemeAnimationType } from '../types-CrR56NLm.js';
|
|
3
|
+
export { A as AnimationConfig, e as AnimationPosition, S as SlideDirection, f as TRANSITION_DIRECTIONS, d as ThemeConfig, g as ThemeControlTransitionProps, h as ThemeLogoOptions, b as ThemeState, i as TransitionDirection } from '../types-CrR56NLm.js';
|
|
4
|
+
export { C as COLOR_STORAGE_KEY, a as COLOR_THEME_PREFIX, D as DEFAULT_BLUR_AMOUNT, b as DEFAULT_DURATION, c as DEFAULT_EASING, d as DEFAULT_STYLE_ID, G as GLOBAL_CLASS_NAME, S as STORAGE_KEY, o as getSystemTheme, p as injectBaseStyles, q as prefersReducedMotion, s as resolveTheme, r as resolveThemeForServer, t as supportsViewTransitions } from '../constants-PAa1nGZ0.js';
|
|
5
|
+
import { U as UseThemeProps, a as UseThemeReturn } from '../index-Dn3XRBX1.js';
|
|
6
|
+
export { N as NextUIThemeContextType, b as NextUIThemeProvider, c as NextUIThemeProviderProps, u as useNextUITheme } from '../index-Dn3XRBX1.js';
|
|
7
|
+
import React, { ReactNode } from 'react';
|
|
8
|
+
import { S as SystemThemeMode } from '../controller-DnMwV2nl.js';
|
|
9
|
+
export { C as ColorThemeToggle, f as ThemeTransitionInput, g as ThemeTransitionOptions } from '../controller-DnMwV2nl.js';
|
|
7
10
|
|
|
8
|
-
/** System theme resolution mode */
|
|
9
|
-
type SystemThemeMode = 'css' | 'js';
|
|
10
|
-
/**
|
|
11
|
-
* Props for the useTheme hook
|
|
12
|
-
*/
|
|
13
|
-
type UseThemeProps = ThemeAnimationOptions & {
|
|
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
|
-
/** Reveal edge feather in CSS pixels, capped at 20 (0 uses a sharp circle). */
|
|
21
|
-
blurAmount?: number;
|
|
22
|
-
/** Legacy style ID, retained for compatibility with the native animation path. */
|
|
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
|
-
/** Per-call animation controls shared by all providers. */
|
|
77
|
-
interface ThemeTransitionOptions {
|
|
78
|
-
/** Skip the view transition (also automatically skipped for reduced motion). */
|
|
79
|
-
animationOff?: boolean;
|
|
80
|
-
/** Trigger element; its viewport rectangle is read synchronously. */
|
|
81
|
-
element?: Element | null;
|
|
82
|
-
/** Viewport-relative CSS pixels. Never multiply these coordinates by DPR. */
|
|
83
|
-
origin?: {
|
|
84
|
-
x: number;
|
|
85
|
-
y: number;
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
/** Boolean arguments remain supported for backward compatibility. */
|
|
89
|
-
type ThemeTransitionInput = boolean | ThemeTransitionOptions;
|
|
90
|
-
type ColorThemeToggle = (options?: ThemeTransitionInput | Pick<React.MouseEvent<HTMLElement>, 'currentTarget' | 'detail'>) => Promise<void>;
|
|
91
|
-
interface UseThemeReturn {
|
|
92
|
-
/** Ref to attach to the trigger button */
|
|
93
|
-
ref: RefObject<HTMLButtonElement | null>;
|
|
94
|
-
/** Current theme value */
|
|
95
|
-
theme: Theme;
|
|
96
|
-
/** Current color theme value */
|
|
97
|
-
colorTheme: ColorTheme;
|
|
98
|
-
/** Resolved theme (light or dark) */
|
|
99
|
-
resolvedTheme: 'light' | 'dark';
|
|
100
|
-
/** Set theme without animation */
|
|
101
|
-
setTheme: (theme: Theme) => void;
|
|
102
|
-
/** Set color theme without animation */
|
|
103
|
-
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
104
|
-
/** Switch theme with animation */
|
|
105
|
-
switchTheme: (theme: Theme, options?: ThemeTransitionInput) => Promise<void>;
|
|
106
|
-
/** Switch color theme with animation */
|
|
107
|
-
switchColorTheme: (colorTheme: string, options?: ThemeTransitionInput) => Promise<void>;
|
|
108
|
-
/** Toggle between light and dark */
|
|
109
|
-
toggleTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
110
|
-
/** Switch to light theme with animation */
|
|
111
|
-
toggleLightTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
112
|
-
/** Switch to dark theme with animation */
|
|
113
|
-
toggleDarkTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
114
|
-
/** Cycle through color themes */
|
|
115
|
-
toggleColorTheme: ColorThemeToggle;
|
|
116
|
-
/** Create a toggle function for a specific color theme */
|
|
117
|
-
createColorThemeToggle: (targetColorTheme: string) => ColorThemeToggle;
|
|
118
|
-
/** Check if a color theme is active */
|
|
119
|
-
isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Props for UIThemeSwitcher component
|
|
123
|
-
*/
|
|
124
|
-
type UIThemeSwitcherProps = ThemeAnimationOptions & {
|
|
125
|
-
/** Available themes */
|
|
126
|
-
themes?: Theme[];
|
|
127
|
-
/** Current theme (controlled) */
|
|
128
|
-
currentTheme?: Theme;
|
|
129
|
-
/** Callback when theme changes */
|
|
130
|
-
onThemeChange?: (theme: Theme) => void;
|
|
131
|
-
/** Animation type */
|
|
132
|
-
animationType?: ThemeAnimationType;
|
|
133
|
-
/** Animation duration */
|
|
134
|
-
duration?: number;
|
|
135
|
-
/** Additional CSS class */
|
|
136
|
-
className?: string;
|
|
137
|
-
/** Button size */
|
|
138
|
-
size?: 'sm' | 'md' | 'lg';
|
|
139
|
-
/** Button variant */
|
|
140
|
-
variant?: 'default' | 'outline' | 'ghost';
|
|
141
|
-
/** Custom icons for themes */
|
|
142
|
-
icons?: {
|
|
143
|
-
light?: React.ReactNode;
|
|
144
|
-
dark?: React.ReactNode;
|
|
145
|
-
system?: React.ReactNode;
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* Props for UIThemeSelector component
|
|
150
|
-
*/
|
|
151
|
-
type UIThemeSelectorProps = ThemeAnimationOptions & {
|
|
152
|
-
/** Available themes */
|
|
153
|
-
themes?: Theme[];
|
|
154
|
-
/** Available color themes */
|
|
155
|
-
colorThemes?: ColorTheme[];
|
|
156
|
-
/** Current theme (controlled) */
|
|
157
|
-
currentTheme?: Theme;
|
|
158
|
-
/** Current color theme (controlled) */
|
|
159
|
-
currentColorTheme?: ColorTheme;
|
|
160
|
-
/** Callback when theme changes */
|
|
161
|
-
onThemeChange?: (theme: Theme) => void;
|
|
162
|
-
/** Callback when color theme changes */
|
|
163
|
-
onColorThemeChange?: (colorTheme: ColorTheme) => void;
|
|
164
|
-
/** Animation type */
|
|
165
|
-
animationType?: ThemeAnimationType;
|
|
166
|
-
/** Animation duration */
|
|
167
|
-
duration?: number;
|
|
168
|
-
/** Additional CSS class */
|
|
169
|
-
className?: string;
|
|
170
|
-
/** Placeholder text */
|
|
171
|
-
placeholder?: string;
|
|
172
|
-
/** Label for theme selector */
|
|
173
|
-
themeLabel?: string;
|
|
174
|
-
/** Label for color theme selector */
|
|
175
|
-
colorThemeLabel?: string;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* React hook for theme switching with View Transitions API animations
|
|
180
|
-
* @param props - Configuration options for the theme animation
|
|
181
|
-
* @returns Theme state and control functions
|
|
182
|
-
*/
|
|
183
11
|
declare const useTheme: (props?: UseThemeProps) => UseThemeReturn;
|
|
184
12
|
|
|
185
|
-
/**
|
|
186
|
-
* Context type for the Next.js UI Theme Provider
|
|
187
|
-
*/
|
|
188
|
-
interface NextUIThemeContextType extends UseThemeReturn {
|
|
189
|
-
/** System theme preference */
|
|
190
|
-
systemTheme: 'light' | 'dark';
|
|
191
|
-
/** Legacy convenience wrapper; does not mutate the shared ref. */
|
|
192
|
-
switchThemeFromElement: (theme: Theme, element: Element) => Promise<void>;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Props for the Next.js UI Theme Provider
|
|
196
|
-
*/
|
|
197
|
-
type NextUIThemeProviderProps = ThemeAnimationOptions & {
|
|
198
|
-
/** React children to wrap with theme context */
|
|
199
|
-
children: ReactNode;
|
|
200
|
-
/** Available theme options */
|
|
201
|
-
themes?: Theme[];
|
|
202
|
-
/** Available color theme options */
|
|
203
|
-
colorThemes?: ColorTheme[];
|
|
204
|
-
/** Default theme to use */
|
|
205
|
-
defaultTheme?: Theme;
|
|
206
|
-
/** Default color theme to use */
|
|
207
|
-
defaultColorTheme?: ColorTheme;
|
|
208
|
-
/** Animation type for theme transitions */
|
|
209
|
-
animationType?: ThemeAnimationType;
|
|
210
|
-
/** Animation duration in milliseconds */
|
|
211
|
-
duration?: number;
|
|
212
|
-
/** Storage key for theme preference */
|
|
213
|
-
storageKey?: string;
|
|
214
|
-
/** Storage key for color theme preference */
|
|
215
|
-
colorStorageKey?: string;
|
|
216
|
-
/** HTML attribute to use for theme ('class' or 'data-theme') */
|
|
217
|
-
attribute?: 'class' | 'data-theme';
|
|
218
|
-
/** Class name for dark theme (when using 'class' attribute) */
|
|
219
|
-
globalClassName?: string;
|
|
220
|
-
/** Prefix for color theme classes */
|
|
221
|
-
colorThemePrefix?: string;
|
|
222
|
-
/** CSP nonce for inline script (SSR apps) */
|
|
223
|
-
nonce?: string;
|
|
224
|
-
/** Skip animation during initial hydration */
|
|
225
|
-
disableAnimationOnInit?: boolean;
|
|
226
|
-
/** Disable flash prevention script (for SPAs without SSR) */
|
|
227
|
-
disablePreHydrationScript?: boolean;
|
|
228
|
-
};
|
|
229
|
-
/**
|
|
230
|
-
* Next.js UI Theme Provider - Universal React theme management with animations
|
|
231
|
-
*
|
|
232
|
-
* This provider works with Next.js and provides flash prevention
|
|
233
|
-
* via pre-hydration script injection.
|
|
234
|
-
*
|
|
235
|
-
* Features:
|
|
236
|
-
* - Pre-hydration script for flash prevention (SSR apps)
|
|
237
|
-
* - Animated theme transitions via View Transitions API
|
|
238
|
-
* - Multi-dimensional theming (theme + colorTheme)
|
|
239
|
-
* - System theme detection
|
|
240
|
-
* - CSP support via nonce prop
|
|
241
|
-
*
|
|
242
|
-
* @param props - Provider configuration options
|
|
243
|
-
*/
|
|
244
|
-
declare const NextUIThemeProvider: React__default.FC<NextUIThemeProviderProps>;
|
|
245
|
-
/**
|
|
246
|
-
* Hook to consume the Next.js UI Theme context
|
|
247
|
-
*
|
|
248
|
-
* @returns Theme context value with all theme state and methods
|
|
249
|
-
* @throws Error if used outside of NextUIThemeProvider
|
|
250
|
-
*/
|
|
251
|
-
declare const useNextUITheme: () => NextUIThemeContextType;
|
|
252
|
-
|
|
253
13
|
/**
|
|
254
14
|
* Context type for the TanStack Start UI Theme Provider
|
|
255
15
|
*/
|
|
@@ -268,15 +28,15 @@ type TanStackUIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
268
28
|
/** React children to wrap with theme context */
|
|
269
29
|
children: ReactNode;
|
|
270
30
|
/** Available theme options */
|
|
271
|
-
themes?: Theme[];
|
|
31
|
+
themes?: readonly Theme[];
|
|
272
32
|
/** Available color theme options */
|
|
273
|
-
colorThemes?: ColorTheme[];
|
|
33
|
+
colorThemes?: readonly ColorTheme[];
|
|
274
34
|
/** Default theme to use */
|
|
275
35
|
defaultTheme?: Theme;
|
|
276
36
|
/** Default color theme to use */
|
|
277
37
|
defaultColorTheme?: ColorTheme;
|
|
278
38
|
/** Animation type for theme transitions */
|
|
279
|
-
animationType?: ThemeAnimationType
|
|
39
|
+
animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
|
|
280
40
|
/** Animation duration in milliseconds */
|
|
281
41
|
duration?: number;
|
|
282
42
|
/** Storage key for theme preference */
|
|
@@ -370,7 +130,7 @@ interface TanStackStartThemeScriptProps {
|
|
|
370
130
|
* }
|
|
371
131
|
* ```
|
|
372
132
|
*/
|
|
373
|
-
declare const TanStackStartThemeScript:
|
|
133
|
+
declare const TanStackStartThemeScript: React.FC<TanStackStartThemeScriptProps>;
|
|
374
134
|
/**
|
|
375
135
|
* Custom hook to detect hydration state
|
|
376
136
|
* Compatible with TanStack Start's isomorphic model
|
|
@@ -395,7 +155,7 @@ declare const TanStackStartThemeScript: React__default.FC<TanStackStartThemeScri
|
|
|
395
155
|
*
|
|
396
156
|
* @param props - Provider configuration options
|
|
397
157
|
*/
|
|
398
|
-
declare const TanStackUIThemeProvider:
|
|
158
|
+
declare const TanStackUIThemeProvider: React.FC<TanStackUIThemeProviderProps>;
|
|
399
159
|
/**
|
|
400
160
|
* Hook to consume the TanStack UI Theme context
|
|
401
161
|
*
|
|
@@ -420,15 +180,15 @@ type ViteUIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
420
180
|
/** React children to wrap with theme context */
|
|
421
181
|
children: ReactNode;
|
|
422
182
|
/** Available theme options */
|
|
423
|
-
themes?: Theme[];
|
|
183
|
+
themes?: readonly Theme[];
|
|
424
184
|
/** Available color theme options */
|
|
425
|
-
colorThemes?: ColorTheme[];
|
|
185
|
+
colorThemes?: readonly ColorTheme[];
|
|
426
186
|
/** Default theme to use */
|
|
427
187
|
defaultTheme?: Theme;
|
|
428
188
|
/** Default color theme to use */
|
|
429
189
|
defaultColorTheme?: ColorTheme;
|
|
430
190
|
/** Animation type for theme transitions */
|
|
431
|
-
animationType?: ThemeAnimationType
|
|
191
|
+
animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
|
|
432
192
|
/** Animation duration in milliseconds */
|
|
433
193
|
duration?: number;
|
|
434
194
|
/** Attribute to use for theme ('class' or 'data-theme') */
|
|
@@ -455,7 +215,7 @@ type ViteUIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
455
215
|
*
|
|
456
216
|
* @param props - Provider configuration options
|
|
457
217
|
*/
|
|
458
|
-
declare const ViteUIThemeProvider:
|
|
218
|
+
declare const ViteUIThemeProvider: React.FC<ViteUIThemeProviderProps>;
|
|
459
219
|
/**
|
|
460
220
|
* Hook to consume the Vite UI Theme context
|
|
461
221
|
*
|
|
@@ -478,15 +238,15 @@ type UIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
478
238
|
/** React children to wrap with theme context */
|
|
479
239
|
children: ReactNode;
|
|
480
240
|
/** Available theme options */
|
|
481
|
-
themes?: Theme[];
|
|
241
|
+
themes?: readonly Theme[];
|
|
482
242
|
/** Available color theme options */
|
|
483
|
-
colorThemes?: ColorTheme[];
|
|
243
|
+
colorThemes?: readonly ColorTheme[];
|
|
484
244
|
/** Default theme to use */
|
|
485
245
|
defaultTheme?: Theme;
|
|
486
246
|
/** Default color theme to use */
|
|
487
247
|
defaultColorTheme?: ColorTheme;
|
|
488
248
|
/** Animation type for theme transitions */
|
|
489
|
-
animationType?: ThemeAnimationType
|
|
249
|
+
animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
|
|
490
250
|
/** Animation duration in milliseconds */
|
|
491
251
|
duration?: number;
|
|
492
252
|
/** Storage key for theme */
|
|
@@ -502,7 +262,7 @@ type UIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
502
262
|
*
|
|
503
263
|
* @param props - Provider configuration options
|
|
504
264
|
*/
|
|
505
|
-
declare const UIThemeProvider:
|
|
265
|
+
declare const UIThemeProvider: React.FC<UIThemeProviderProps>;
|
|
506
266
|
/**
|
|
507
267
|
* Hook to consume the UI Theme context
|
|
508
268
|
*
|
|
@@ -511,23 +271,7 @@ declare const UIThemeProvider: React__default.FC<UIThemeProviderProps>;
|
|
|
511
271
|
*/
|
|
512
272
|
declare const useUITheme: () => UIThemeContextType;
|
|
513
273
|
|
|
514
|
-
declare const UIThemeSwitcher: (props: UIThemeSwitcherProps) => JSX.Element;
|
|
515
|
-
|
|
516
|
-
declare const UIThemeSelector: (props: UIThemeSelectorProps) => React$1.JSX.Element;
|
|
517
|
-
|
|
518
|
-
declare function UISelect({ ...props }: React$1.ComponentProps<typeof SelectPrimitive.Root>): React$1.JSX.Element;
|
|
519
|
-
declare function UISelectGroup({ ...props }: React$1.ComponentProps<typeof SelectPrimitive.Group>): React$1.JSX.Element;
|
|
520
|
-
declare function UISelectValue({ ...props }: React$1.ComponentProps<typeof SelectPrimitive.Value>): React$1.JSX.Element;
|
|
521
|
-
declare const UISelectTrigger: React$1.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectTriggerProps & React$1.RefAttributes<HTMLButtonElement>, "ref"> & {
|
|
522
|
-
size?: "sm" | "default";
|
|
523
|
-
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
524
|
-
declare function UISelectContent({ className, children, position, ...props }: React$1.ComponentProps<typeof SelectPrimitive.Content>): React$1.JSX.Element;
|
|
525
|
-
declare function UISelectLabel({ className, ...props }: React$1.ComponentProps<typeof SelectPrimitive.Label>): React$1.JSX.Element;
|
|
526
|
-
declare function UISelectItem({ className, children, ...props }: React$1.ComponentProps<typeof SelectPrimitive.Item>): React$1.JSX.Element;
|
|
527
|
-
declare function UISelectSeparator({ className, ...props }: React$1.ComponentProps<typeof SelectPrimitive.Separator>): React$1.JSX.Element;
|
|
528
|
-
declare function UISelectScrollUpButton({ className, ...props }: React$1.ComponentProps<typeof SelectPrimitive.ScrollUpButton>): React$1.JSX.Element;
|
|
529
|
-
declare function UISelectScrollDownButton({ className, ...props }: React$1.ComponentProps<typeof SelectPrimitive.ScrollDownButton>): React$1.JSX.Element;
|
|
530
|
-
|
|
531
274
|
declare const useHydrated: () => boolean;
|
|
532
275
|
|
|
533
|
-
export { ColorTheme,
|
|
276
|
+
export { ColorTheme, SystemThemeMode, TanStackStartThemeScript, TanStackUIThemeProvider, Theme, ThemeAnimationOptions, ThemeAnimationType, UIThemeProvider, UseThemeProps, UseThemeReturn, ViteUIThemeProvider, useHydrated, useTanStackUITheme, useTheme, useUITheme, useViteUITheme };
|
|
277
|
+
export type { TanStackStartThemeScriptProps, TanStackUIThemeContextType, TanStackUIThemeProviderProps, UIThemeContextType, UIThemeProviderProps, ViteUIThemeContextType, ViteUIThemeProviderProps };
|
package/dist/react/index.js
CHANGED
|
@@ -1,39 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import {b as b$1,d as d$1,a as a$1,c as c$2}from'../chunk-C4YNAGUP.js';export{e as NextUIThemeProvider,d as useHydrated,f as useNextUITheme,a as useTheme}from'../chunk-C4YNAGUP.js';import {c as c$1,g,i}from'../chunk-EKVKQZNN.js';export{b as TRANSITION_DIRECTIONS,a as ThemeAnimationType,d as preloadThemeLogo}from'../chunk-EKVKQZNN.js';import {c as c$3}from'../chunk-CY5E6WU4.js';export{c as getSystemTheme,a as injectBaseStyles,g as prefersReducedMotion,d as resolveTheme,e as resolveThemeForServer,f as supportsViewTransitions}from'../chunk-CY5E6WU4.js';import {a,b,c,d}from'../chunk-NDNCNR4X.js';export{b as COLOR_STORAGE_KEY,d as COLOR_THEME_PREFIX,g as DEFAULT_BLUR_AMOUNT,e as DEFAULT_DURATION,f as DEFAULT_EASING,h as DEFAULT_STYLE_ID,c as GLOBAL_CLASS_NAME,a as STORAGE_KEY}from'../chunk-NDNCNR4X.js';import Pe,{createContext,useRef,useEffect,useContext,useCallback}from'react';import {jsx}from'react/jsx-runtime';var J=async(t,h,o)=>{try{await t?.(h);}catch(i){let r=i instanceof Error?i:new Error(String(i));try{o?o(r):console.error("Theme server notification failed:",r);}catch(c){console.error("Theme server error handler failed:",c);}}};var Q=createContext(void 0),Le=(t,h,o,i,r,c,u)=>`
|
|
3
3
|
(function() {
|
|
4
4
|
try {
|
|
5
|
-
var theme = localStorage.getItem(${
|
|
6
|
-
var colorTheme = localStorage.getItem(${
|
|
7
|
-
var resolved = theme === 'system'
|
|
8
|
-
? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
|
|
9
|
-
: theme;
|
|
10
|
-
|
|
11
|
-
if (${I(i)} === 'class') {
|
|
12
|
-
if (resolved === 'dark') {
|
|
13
|
-
document.documentElement.classList.add(${I(a)});
|
|
14
|
-
} else {
|
|
15
|
-
document.documentElement.classList.remove(${I(a)});
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
document.documentElement.setAttribute('data-theme', resolved);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
document.documentElement.style.colorScheme = resolved;
|
|
22
|
-
document.documentElement.classList.add(${I(l)} + colorTheme);
|
|
23
|
-
} catch (e) {
|
|
24
|
-
console.warn('Theme pre-hydration script failed:', e);
|
|
25
|
-
}
|
|
26
|
-
})();
|
|
27
|
-
`,Ve=_t__default.memo(({storageKey:e,colorStorageKey:o,defaultTheme:n,defaultColorTheme:r,attribute:i,globalClassName:a,colorThemePrefix:l,nonce:g})=>{let u=Ht(e,o,n,r,i,a,l);return jsx("script",{nonce:g,suppressHydrationWarning:true,dangerouslySetInnerHTML:{__html:u}})});Ve.displayName="ThemePreHydrationScript";var Ft=({children:e,themes:o=["light","dark","system"],colorThemes:n=["default"],defaultTheme:r$1="system",defaultColorTheme:i="default",animationType:a="circle",clipPathDirection:l,animationPosition:g,logo:u,logoLight:y,logoDark:b,logoWidth:U,logoHeight:V,gradientWidth:p,duration:R=400,storageKey:v=q,colorStorageKey:N=r,attribute:G="class",globalClassName:c$1=s,colorThemePrefix:w=t,nonce:k,disableAnimationOnInit:s$1=true,disablePreHydrationScript:C=false})=>{let z=W(),T=F({themes:o,colorThemes:n,defaultTheme:r$1,defaultColorTheme:i,animationType:a,clipPathDirection:l,animationPosition:g,...c({logo:u,logoLight:y,logoDark:b}),logoWidth:U,logoHeight:V,gradientWidth:p,duration:R,storageKey:v,colorStorageKey:N,globalClassName:G==="class"?c$1:void 0,colorThemePrefix:w}),_=useCallback(async(A,L=false)=>{!z&&s$1?T.setTheme(A):await T.switchTheme(A,L);},[z,s$1,T]),K=useCallback((A,L)=>_(A,{element:L}),[_]),M=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(!z){let A={ref:{current:null},theme:r$1,colorTheme:i,resolvedTheme:r$1==="dark"?"dark":"light",systemTheme:"light",setTheme:()=>{},setColorTheme:()=>{},switchTheme:async()=>{},switchThemeFromElement:async()=>{},switchColorTheme:async()=>{},toggleTheme:async()=>{},toggleLightTheme:async()=>{},toggleDarkTheme:async()=>{},toggleColorTheme:async()=>{},createColorThemeToggle:()=>async()=>{},isColorThemeActive:()=>false};return jsx(Fe.Provider,{value:A,children:jsxs(B.Provider,{value:A,children:[!C&&jsx(Ve,{storageKey:v,colorStorageKey:N,defaultTheme:r$1,defaultColorTheme:i,attribute:G,globalClassName:c$1,colorThemePrefix:w,nonce:k}),e]})})}let d={ref:T.ref,theme:T.theme,colorTheme:T.colorTheme,resolvedTheme:T.resolvedTheme,systemTheme:M,setTheme:T.setTheme,setColorTheme:T.setColorTheme,switchTheme:_,switchThemeFromElement:K,switchColorTheme:T.switchColorTheme,toggleTheme:T.toggleTheme,toggleLightTheme:T.toggleLightTheme,toggleDarkTheme:T.toggleDarkTheme,toggleColorTheme:T.toggleColorTheme,createColorThemeToggle:T.createColorThemeToggle,isColorThemeActive:T.isColorThemeActive};return jsx(Fe.Provider,{value:d,children:jsxs(B.Provider,{value:d,children:[!C&&jsx(Ve,{storageKey:v,colorStorageKey:N,defaultTheme:r$1,defaultColorTheme:i,attribute:G,globalClassName:c$1,colorThemePrefix:w,nonce:k}),e]})})},Vt=()=>{let e=useContext(Fe);if(e===void 0)throw new Error("useNextUITheme must be used within a NextUIThemeProvider");return e};var $e=async(e,o,n)=>{try{await e?.(o);}catch(r){let i=r instanceof Error?r:new Error(String(r));try{n?n(i):console.error("Theme server notification failed:",i);}catch(a){console.error("Theme server error handler failed:",a);}}};var Be=createContext(void 0),Wt=(e,o,n,r,i,a,l)=>`
|
|
28
|
-
(function() {
|
|
29
|
-
try {
|
|
30
|
-
var theme = localStorage.getItem(${I(e)}) || ${I(n)};
|
|
31
|
-
var colorTheme = localStorage.getItem(${I(o)}) || ${I(r)};
|
|
5
|
+
var theme = localStorage.getItem(${b$1(t)}) || ${b$1(o)};
|
|
6
|
+
var colorTheme = localStorage.getItem(${b$1(h)}) || ${b$1(i)};
|
|
32
7
|
var el = document.documentElement;
|
|
33
8
|
var resolved;
|
|
34
9
|
if (theme === 'system') {
|
|
35
|
-
if (${
|
|
36
|
-
el.classList.remove(${
|
|
10
|
+
if (${b$1(u)} === 'css') {
|
|
11
|
+
el.classList.remove(${b$1(r)});
|
|
37
12
|
el.classList.remove('auto');
|
|
38
13
|
el.classList.remove('system');
|
|
39
14
|
el.classList.add('system');
|
|
@@ -41,9 +16,9 @@ import {c,d,f,h,g,i,e}from'../chunk-DFJEYTIW.js';export{b as TRANSITION_DIRECTIO
|
|
|
41
16
|
} else {
|
|
42
17
|
resolved = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
43
18
|
if (resolved === 'dark') {
|
|
44
|
-
el.classList.add(${
|
|
19
|
+
el.classList.add(${b$1(r)});
|
|
45
20
|
} else {
|
|
46
|
-
el.classList.remove(${
|
|
21
|
+
el.classList.remove(${b$1(r)});
|
|
47
22
|
}
|
|
48
23
|
el.classList.remove('system');
|
|
49
24
|
el.classList.remove('auto');
|
|
@@ -54,70 +29,17 @@ import {c,d,f,h,g,i,e}from'../chunk-DFJEYTIW.js';export{b as TRANSITION_DIRECTIO
|
|
|
54
29
|
el.classList.remove('system');
|
|
55
30
|
el.classList.remove('auto');
|
|
56
31
|
if (resolved === 'dark') {
|
|
57
|
-
el.classList.add(${
|
|
32
|
+
el.classList.add(${b$1(r)});
|
|
58
33
|
} else {
|
|
59
|
-
el.classList.remove(${
|
|
34
|
+
el.classList.remove(${b$1(r)});
|
|
60
35
|
}
|
|
61
36
|
el.style.colorScheme = resolved;
|
|
62
37
|
}
|
|
63
38
|
if (colorTheme && colorTheme !== 'default') {
|
|
64
|
-
el.classList.add(${
|
|
39
|
+
el.classList.add(${b$1(c)} + colorTheme);
|
|
65
40
|
}
|
|
66
41
|
} catch (e) {
|
|
67
42
|
console.warn('Theme pre-hydration script failed:', e);
|
|
68
43
|
}
|
|
69
44
|
})();
|
|
70
|
-
`,
|
|
71
|
-
relative flex h-9 w-12 cursor-pointer items-center justify-center
|
|
72
|
-
text-muted-foreground hover:text-foreground
|
|
73
|
-
${n?"text-foreground font-medium":""}
|
|
74
|
-
`,role:"radio","aria-checked":n,"aria-label":`Switch to ${o} theme`,onClick:u=>i(o,u),onMouseEnter:a,onMouseLeave:l,style:{borderRadius:"var(--radius)"},children:[r&&jsx("div",{className:"absolute inset-0 bg-muted",style:{borderRadius:"var(--radius)"}}),jsx("div",{className:"relative z-10 flex items-center justify-center",children:jsx("div",{className:"[&_svg]:size-4",children:e})}),n&&jsx("div",{className:"absolute bottom-0 left-1/2 h-0.5 w-6 -translate-x-1/2 rounded-full",style:{backgroundColor:"hsl(var(--primary))"}})]}),ao=[{icon:jsx(so,{}),value:"system"},{icon:jsx(no,{}),value:"light"},{icon:jsx(io,{}),value:"dark"}],lt=({state:e,isControlled:o,themes:n=["light","dark","system"],onThemeChange:r,className:i})=>{let{ref:a,theme:l,switchTheme:g}=e,u=W(),[y,b]=useState(null),U=async(p,R)=>{o&&R?(await g(p,{element:R.currentTarget,animationOff:R.detail===0}),r&&r(p)):await g(p,R?{element:R.currentTarget,animationOff:R.detail===0}:void 0);},V=ao.filter(p=>n.includes(p.value));return jsx("div",{className:`
|
|
75
|
-
inline-flex h-9 items-center overflow-hidden bg-background shadow-sm border border-border
|
|
76
|
-
${u?"opacity-100":"opacity-0"}
|
|
77
|
-
${i||""}
|
|
78
|
-
`,style:{borderRadius:"var(--radius)",backgroundColor:"hsl(var(--background))"},role:"radiogroup",onMouseLeave:()=>b(null),children:V.map(p=>jsx(mo,{icon:p.icon,value:p.value,isActive:l===p.value,isHovered:y===p.value,onClick:U,onMouseEnter:()=>b(p.value),onMouseLeave:()=>{},buttonRef:l===p.value?a:void 0},p.value))})},lo=e=>{let o=F({...e,theme:e.currentTheme});return jsx(lt,{...e,state:o,isControlled:false})},co=e=>{let o=we();return o?jsx(lt,{...e,state:o,isControlled:true}):jsx(lo,{...e})};var ht=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})}),ho=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m18 15-6-6-6 6"})}),To=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})});function Ke({...e}){return jsx(m.Root,{"data-slot":"ui-select",...e})}function uo({...e}){return jsx(m.Group,{"data-slot":"ui-select-group",...e})}function We({...e}){return jsx(m.Value,{"data-slot":"ui-select-value",...e})}var Ye=_t.forwardRef(function({className:o,size:n="default",children:r,...i},a){return jsxs(m.Trigger,{ref:a,"data-slot":"ui-select-trigger","data-size":n,className:`
|
|
79
|
-
border-input data-[placeholder]:text-muted-foreground
|
|
80
|
-
[&_svg:not([class*='text-'])]:text-muted-foreground
|
|
81
|
-
focus-visible:border-ring focus-visible:ring-ring/50
|
|
82
|
-
aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40
|
|
83
|
-
aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50
|
|
84
|
-
flex w-fit items-center justify-between gap-2 rounded-md border
|
|
85
|
-
bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs
|
|
86
|
-
transition-[color,box-shadow] outline-none focus-visible:ring-[3px]
|
|
87
|
-
disabled:cursor-not-allowed disabled:opacity-50
|
|
88
|
-
data-[size=default]:h-9 data-[size=sm]:h-8
|
|
89
|
-
*:data-[slot=ui-select-value]:line-clamp-1
|
|
90
|
-
*:data-[slot=ui-select-value]:flex
|
|
91
|
-
*:data-[slot=ui-select-value]:items-center
|
|
92
|
-
*:data-[slot=ui-select-value]:gap-2
|
|
93
|
-
[&_svg]:pointer-events-none [&_svg]:shrink-0
|
|
94
|
-
[&_svg:not([class*='size-'])]:size-4
|
|
95
|
-
${o||""}
|
|
96
|
-
`,...i,children:[r,jsx(m.Icon,{asChild:true,children:jsx(ht,{})})]})});function je({className:e,children:o,position:n="popper",...r}){return jsx(m.Portal,{children:jsx(m.Content,{"data-slot":"ui-select-content",className:`
|
|
97
|
-
bg-popover text-popover-foreground
|
|
98
|
-
data-[state=open]:animate-in data-[state=closed]:animate-out
|
|
99
|
-
data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0
|
|
100
|
-
data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95
|
|
101
|
-
data-[side=bottom]:slide-in-from-top-2
|
|
102
|
-
data-[side=left]:slide-in-from-right-2
|
|
103
|
-
data-[side=right]:slide-in-from-left-2
|
|
104
|
-
data-[side=top]:slide-in-from-bottom-2
|
|
105
|
-
relative z-50 max-h-[var(--radix-select-content-available-height)]
|
|
106
|
-
min-w-[8rem] origin-[var(--radix-select-content-transform-origin)]
|
|
107
|
-
overflow-x-hidden overflow-y-auto rounded-md border shadow-md
|
|
108
|
-
${n==="popper"?"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1":""}
|
|
109
|
-
${e||""}
|
|
110
|
-
`,position:n,...r,children:jsx(m.Viewport,{className:`
|
|
111
|
-
p-1
|
|
112
|
-
${n==="popper"?"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]":""}
|
|
113
|
-
`,children:o})})})}function po({className:e,...o}){return jsx(m.Label,{"data-slot":"ui-select-label",className:`py-1.5 pl-8 pr-2 text-sm font-semibold ${e||""}`,...o})}function Xe({className:e,children:o,...n}){return jsxs(m.Item,{"data-slot":"ui-select-item",className:`
|
|
114
|
-
focus:bg-accent focus:text-accent-foreground
|
|
115
|
-
[&_svg:not([class*='text-'])]:text-muted-foreground
|
|
116
|
-
relative flex w-full cursor-default items-center gap-2
|
|
117
|
-
rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none
|
|
118
|
-
data-[disabled]:pointer-events-none data-[disabled]:opacity-50
|
|
119
|
-
[&_svg]:pointer-events-none [&_svg]:shrink-0
|
|
120
|
-
[&_svg:not([class*='size-'])]:size-4
|
|
121
|
-
*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2
|
|
122
|
-
${e||""}
|
|
123
|
-
`,...n,children:[jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(m.ItemIndicator,{children:jsx(To,{})})}),jsx(m.ItemText,{children:o})]})}function go({className:e,...o}){return jsx(m.Separator,{"data-slot":"ui-select-separator",className:`-mx-1 my-1 h-px bg-muted ${e||""}`,...o})}function fo({className:e,...o}){return jsx(m.ScrollUpButton,{"data-slot":"ui-select-scroll-up-button",className:`flex cursor-default items-center justify-center py-1 ${e||""}`,...o,children:jsx(ho,{})})}function vo({className:e,...o}){return jsx(m.ScrollDownButton,{"data-slot":"ui-select-scroll-down-button",className:`flex cursor-default items-center justify-center py-1 ${e||""}`,...o,children:jsx(ht,{})})}var ut=({state:e,isControlled:o,colorThemes:n=["default"],onColorThemeChange:r,className:i,placeholder:a="Choose a color theme"})=>{let{colorTheme:l,switchColorTheme:g}=e,u=useRef(null),y=useRef(false),b=U=>{g(U,{element:u.current,animationOff:y.current}),o&&r?.(U);};return n.length<=1?null:jsx("div",{className:`flex flex-col gap-2 ${i||""}`,onKeyDownCapture:()=>{y.current=true;},onPointerDownCapture:()=>{y.current=false;},children:jsxs(Ke,{value:l,onValueChange:b,children:[jsx(Ye,{ref:u,className:"capitalize",children:jsx(We,{placeholder:a})}),jsx(je,{onKeyDownCapture:()=>{y.current=true;},onPointerDownCapture:()=>{y.current=false;},children:n.map(U=>jsx(Xe,{className:"capitalize",value:U,children:U},U))})]})})},yo=e=>{let o=F({...e,colorTheme:e.currentColorTheme});return jsx(ut,{...e,state:o,isControlled:false})},Co=e=>{let o=we();return o?jsx(ut,{...e,state:o,isControlled:true}):jsx(yo,{...e})};export{Ft as NextUIThemeProvider,st as TanStackStartThemeScript,Yt as TanStackUIThemeProvider,Ke as UISelect,je as UISelectContent,uo as UISelectGroup,Xe as UISelectItem,po as UISelectLabel,vo as UISelectScrollDownButton,fo as UISelectScrollUpButton,go as UISelectSeparator,Ye as UISelectTrigger,We as UISelectValue,to as UIThemeProvider,Co as UIThemeSelector,co as UIThemeSwitcher,qt as ViteUIThemeProvider,W as useHydrated,Vt as useNextUITheme,jt as useTanStackUITheme,F as useTheme,oo as useUITheme,Qt as useViteUITheme};
|
|
45
|
+
`,ne=Pe.memo(({storageKey:t=a,colorStorageKey:h=b,defaultTheme:o="system",defaultColorTheme:i="default",globalClassName:r=c,colorThemePrefix:c$1=d,nonce:u,systemThemeMode:v="js"})=>{let S=Le(t,h,o,i,r,c$1,v);return jsx("script",{nonce:u,suppressHydrationWarning:true,dangerouslySetInnerHTML:{__html:S}})});ne.displayName="TanStackStartThemeScript";var Re=({children:t,themes:h=["light","dark","system"],colorThemes:o=["default"],defaultTheme:i$1="system",defaultColorTheme:r=o[0]??"default",animationType:c$3="circle",clipPathDirection:u,animationPosition:v,logo:S,logoLight:L,logoDark:R,logoWidth:O,logoHeight:_,gradientWidth:D,duration:F=400,storageKey:I=a,colorStorageKey:C=b,globalClassName:V=c,colorThemePrefix:P=d,serverTheme:g$1,serverColorTheme:d$2,systemThemeMode:n="css",onServerThemeChange:a$2,onServerColorThemeChange:X,onServerError:N})=>{let w=d$1(),k=g$1!==void 0,x=k?g$1==="system"?"system":g$1:void 0,T=a$1({themes:h,colorThemes:o,defaultTheme:i$1,defaultColorTheme:r,animationType:c$3,clipPathDirection:u,animationPosition:v,...c$1({logo:S,logoLight:L,logoDark:R}),logoWidth:O,logoHeight:_,gradientWidth:D,duration:F,storageKey:I,colorStorageKey:C,globalClassName:V,colorThemePrefix:P,systemThemeMode:n,initialTheme:x,initialColorTheme:d$2,onThemeChange:e=>{J(a$2,e,N);},onColorThemeChange:e=>{J(X,e,N);}}),$=useRef(false);useEffect(()=>{if(!(!k||!w||$.current)){$.current=true;try{x&&g(x,I),d$2&&i(d$2,C);}catch(e){console.warn("Unable to persist the initial server theme:",e);}}},[k,w,x,d$2,I,C]);let p=T.setTheme,m=T.setColorTheme,s=(e=false)=>w?e:e===true||e===false?true:{...e,animationOff:true},K=(e,y)=>T.switchTheme(e,s(y)),he=e=>T.toggleTheme(s(e)),ae=e=>T.toggleLightTheme(s(e)),Te=e=>T.toggleDarkTheme(s(e)),Z=(e,y)=>T.switchColorTheme(e,s(y)),le=(e,y)=>K(e,{element:y}),j=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",ee=k?g$1==="dark"?"dark":g$1==="system"?j:"light":i$1==="dark"?"dark":"light";if(!w){let e={themes:h,colorThemes:o,mounted:false,ref:{current:null},theme:x??i$1,colorTheme:d$2??r,resolvedTheme:ee,systemTheme:"light",isHydrated:false,setTheme:p,setColorTheme:m,switchTheme:async y=>p(y),switchThemeFromElement:async y=>p(y),switchColorTheme:Z,toggleTheme:async()=>{p(ee==="dark"?"light":"dark");},toggleLightTheme:async()=>p("light"),toggleDarkTheme:async()=>p("dark"),toggleColorTheme:T.toggleColorTheme,createColorThemeToggle:T.createColorThemeToggle,isColorThemeActive:T.isColorThemeActive};return jsx(Q.Provider,{value:e,children:jsx(c$2.Provider,{value:e,children:t})})}let te={...T,systemTheme:j,isHydrated:true,setTheme:p,setColorTheme:m,switchTheme:K,switchThemeFromElement:le,switchColorTheme:Z,toggleTheme:he,toggleLightTheme:ae,toggleDarkTheme:Te};return jsx(Q.Provider,{value:te,children:jsx(c$2.Provider,{value:te,children:t})})},Oe=()=>{let t=useContext(Q);if(t===void 0)throw new Error("useTanStackUITheme must be used within a TanStackUIThemeProvider");return t};var ie=createContext(void 0),Fe=({children:t,themes:h=["light","dark","system"],colorThemes:o=["default"],defaultTheme:i="system",defaultColorTheme:r=o[0]??"default",animationType:c="circle",clipPathDirection:u,animationPosition:v,logo:S,logoLight:L,logoDark:R,logoWidth:O,logoHeight:_,gradientWidth:D,duration:F=400,attribute:I="class",disableTransitionOnChange:C=false,storageKey:V="ui-theme",colorStorageKey:P="ui-color-theme",globalClassName:g="dark",colorThemePrefix:d="theme-"})=>{let n=a$1({themes:h,colorThemes:o,defaultTheme:i,defaultColorTheme:r,animationType:c,clipPathDirection:u,animationPosition:v,...c$1({logo:S,logoLight:L,logoDark:R}),logoWidth:O,logoHeight:_,gradientWidth:D,duration:F,storageKey:V,colorStorageKey:P,globalClassName:I==="class"?g:void 0,colorThemePrefix:d}),a=useCallback(()=>{if(!C)return ()=>{};let m=document.createElement("style");return m.textContent="*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}",document.head.appendChild(m),window.getComputedStyle(document.body),()=>{setTimeout(()=>{document.head.removeChild(m);},1);}},[C]),X=useCallback(m=>{let s=a();n.setTheme(m),s();},[n,a]),N=useCallback(async(m,s=false)=>{let K=a();try{await n.switchTheme(m,s);}finally{K();}},[n,a]),w=useCallback(async(m=false)=>{let s=a();try{await n.toggleTheme(m);}finally{s();}},[n,a]),k=useCallback(async(m=false)=>{let s=a();try{await n.toggleLightTheme(m);}finally{s();}},[n,a]),x=useCallback(async(m=false)=>{let s=a();try{await n.toggleDarkTheme(m);}finally{s();}},[n,a]),T=(m,s)=>N(m,{element:s}),$=c$3(),p={...n,systemTheme:$,setTheme:X,switchTheme:N,switchThemeFromElement:T,toggleTheme:w,toggleLightTheme:k,toggleDarkTheme:x};return jsx(ie.Provider,{value:p,children:jsx(c$2.Provider,{value:p,children:t})})},Ve=()=>{let t=useContext(ie);if(t===void 0)throw new Error("useViteUITheme must be used within a ViteUIThemeProvider");return t};var se=createContext(void 0),Me=({children:t,themes:h=["light","dark","system"],colorThemes:o=["default"],defaultTheme:i="system",defaultColorTheme:r=o[0]??"default",animationType:c="circle",clipPathDirection:u,animationPosition:v,logo:S,logoLight:L,logoDark:R,logoWidth:O,logoHeight:_,gradientWidth:D,duration:F=400,storageKey:I,colorStorageKey:C})=>{let V=d$1(),P=a$1({themes:h,colorThemes:o,defaultTheme:i,defaultColorTheme:r,animationType:c,clipPathDirection:u,animationPosition:v,...c$1({logo:S,logoLight:L,logoDark:R}),logoWidth:O,logoHeight:_,gradientWidth:D,duration:F,storageKey:I,colorStorageKey:C}),g=(n,a)=>P.switchTheme(n,{element:a});if(!V){let n={themes:h,colorThemes:o,mounted:false,systemTheme:"light",ref:{current:null},theme:i,colorTheme:r,resolvedTheme:i==="dark"?"dark":"light",setTheme:()=>{},setColorTheme:()=>{},switchTheme:async()=>{},switchThemeFromElement:async()=>{},switchColorTheme:async()=>{},toggleTheme:async()=>{},toggleLightTheme:async()=>{},toggleDarkTheme:async()=>{},toggleColorTheme:async()=>{},createColorThemeToggle:()=>async()=>{},isColorThemeActive:()=>false};return jsx(se.Provider,{value:n,children:jsx(c$2.Provider,{value:n,children:t})})}let d={...P,switchThemeFromElement:g};return jsx(se.Provider,{value:d,children:jsx(c$2.Provider,{value:d,children:t})})},be=()=>{let t=useContext(c$2);if(t===null)throw new Error("useUITheme must be used within a UIThemeProvider");return {...t,switchThemeFromElement:(h,o)=>t.switchTheme(h,{element:o})}};export{ne as TanStackStartThemeScript,Re as TanStackUIThemeProvider,Me as UIThemeProvider,Fe as ViteUIThemeProvider,Oe as useTanStackUITheme,be as useUITheme,Ve as useViteUITheme};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';var chunkCYGYUQUK_cjs=require('../chunk-CYGYUQUK.cjs');function u(e={}){let t=e.themes??["light","dark","system"],r=e.colorThemes??["default"],a=e.defaultTheme??"system",l=e.defaultColorTheme??r[0],s=e.globalClassName??chunkCYGYUQUK_cjs.c,c=e.colorThemePrefix??chunkCYGYUQUK_cjs.d;if(!t.length||!t.every(o=>["light","dark","system"].includes(o))||!t.includes(a))throw new Error("themes must include defaultTheme and contain light, dark, or system.");if(!l||!r.includes(l)||![s,...r.map(o=>`${c}${o}`)].every(o=>o.length>0&&!/\s/.test(o)))throw new Error("Color themes and class names must be valid CSS class tokens.");return `(() => {
|
|
2
|
+
const config = ${JSON.stringify({themes:t,colorThemes:r,defaultTheme:a,defaultColorTheme:l,globalClassName:s,colorThemePrefix:c,storageKey:e.storageKey??chunkCYGYUQUK_cjs.a,colorStorageKey:e.colorStorageKey??chunkCYGYUQUK_cjs.b,browserStorage:e.storage===void 0}).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};
|
|
3
|
+
const root = document.documentElement;
|
|
4
|
+
let theme = config.defaultTheme;
|
|
5
|
+
let palette = config.defaultColorTheme;
|
|
6
|
+
if (config.browserStorage) {
|
|
7
|
+
try { const value = localStorage.getItem(config.storageKey); if (config.themes.includes(value)) theme = value; } catch {}
|
|
8
|
+
try { const value = localStorage.getItem(config.colorStorageKey); if (config.colorThemes.includes(value)) palette = value; } catch {}
|
|
9
|
+
}
|
|
10
|
+
const dark = theme === 'dark' || (theme === 'system' && matchMedia('(prefers-color-scheme: dark)').matches);
|
|
11
|
+
root.classList.toggle(config.globalClassName, dark);
|
|
12
|
+
root.style.colorScheme = dark ? 'dark' : 'light';
|
|
13
|
+
for (const value of config.colorThemes) root.classList.toggle(config.colorThemePrefix + value, value === palette);
|
|
14
|
+
})();`}exports.getThemeScript=u;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ThemeConfig, Theme } from '../core/index.cjs';
|
|
2
|
+
|
|
3
|
+
type ThemeBootstrapOptions = Omit<ThemeConfig, 'themes' | 'colorThemes'> & {
|
|
4
|
+
themes?: readonly Theme[];
|
|
5
|
+
colorThemes?: readonly string[];
|
|
6
|
+
storage?: unknown;
|
|
7
|
+
};
|
|
8
|
+
declare function getThemeScript(options?: ThemeBootstrapOptions): string;
|
|
9
|
+
|
|
10
|
+
export { getThemeScript };
|
|
11
|
+
export type { ThemeBootstrapOptions };
|