@space-man/react-theme-animation 2.0.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.
Files changed (60) hide show
  1. package/README.md +90 -464
  2. package/dist/core/index.cjs +74 -0
  3. package/dist/core/index.cjs.map +1 -0
  4. package/dist/{esm/types/index.d.ts → core/index.d.cts} +30 -12
  5. package/dist/{cjs/types → core}/index.d.ts +30 -12
  6. package/dist/core/index.js +66 -0
  7. package/dist/core/index.js.map +1 -0
  8. package/dist/index.cjs +1756 -0
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.cts +4 -0
  11. package/dist/index.d.ts +4 -0
  12. package/dist/index.js +1706 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/react/index.cjs +1742 -0
  15. package/dist/react/index.cjs.map +1 -0
  16. package/dist/react/index.d.cts +224 -0
  17. package/dist/react/index.d.ts +224 -0
  18. package/dist/react/index.js +1697 -0
  19. package/dist/react/index.js.map +1 -0
  20. package/dist/tanstack/index.cjs +34 -0
  21. package/dist/tanstack/index.cjs.map +1 -0
  22. package/dist/tanstack/index.d.cts +20 -0
  23. package/dist/tanstack/index.d.ts +20 -0
  24. package/dist/tanstack/index.js +27 -0
  25. package/dist/tanstack/index.js.map +1 -0
  26. package/package.json +66 -37
  27. package/dist/cjs/components/SpacemanThemeProvider.d.ts +0 -57
  28. package/dist/cjs/components/SpacemanThemeProvider.js +0 -113
  29. package/dist/cjs/components/ThemeSelector.d.ts +0 -3
  30. package/dist/cjs/components/ThemeSelector.js +0 -39
  31. package/dist/cjs/components/ThemeSwitcher.d.ts +0 -3
  32. package/dist/cjs/components/ThemeSwitcher.js +0 -81
  33. package/dist/cjs/components/ViteThemeProvider.d.ts +0 -38
  34. package/dist/cjs/components/ViteThemeProvider.js +0 -117
  35. package/dist/cjs/components/ui/select.d.ts +0 -15
  36. package/dist/cjs/components/ui/select.js +0 -83
  37. package/dist/cjs/hooks/use-theme-animation.d.ts +0 -2
  38. package/dist/cjs/hooks/use-theme-animation.js +0 -234
  39. package/dist/cjs/index.d.ts +0 -8
  40. package/dist/cjs/index.js +0 -23
  41. package/dist/cjs/types/index.js +0 -9
  42. package/dist/cjs/utils/animations.d.ts +0 -21
  43. package/dist/cjs/utils/animations.js +0 -189
  44. package/dist/esm/components/SpacemanThemeProvider.d.ts +0 -57
  45. package/dist/esm/components/SpacemanThemeProvider.js +0 -108
  46. package/dist/esm/components/ThemeSelector.d.ts +0 -3
  47. package/dist/esm/components/ThemeSelector.js +0 -35
  48. package/dist/esm/components/ThemeSwitcher.d.ts +0 -3
  49. package/dist/esm/components/ThemeSwitcher.js +0 -77
  50. package/dist/esm/components/ViteThemeProvider.d.ts +0 -38
  51. package/dist/esm/components/ViteThemeProvider.js +0 -112
  52. package/dist/esm/components/ui/select.d.ts +0 -15
  53. package/dist/esm/components/ui/select.js +0 -39
  54. package/dist/esm/hooks/use-theme-animation.d.ts +0 -2
  55. package/dist/esm/hooks/use-theme-animation.js +0 -230
  56. package/dist/esm/index.d.ts +0 -8
  57. package/dist/esm/index.js +0 -7
  58. package/dist/esm/types/index.js +0 -6
  59. package/dist/esm/utils/animations.d.ts +0 -21
  60. package/dist/esm/utils/animations.js +0 -177
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/types/index.ts","../src/core/utils/animations.ts","../src/react/hooks/use-theme-animation.ts","../src/react/components/shared-theme-context.ts","../src/react/components/ThemeSwitcher.tsx","../src/react/components/ui/select.tsx","../src/react/components/ThemeSelector.tsx","../src/react/components/provider-helpers.ts","../src/react/components/SpacemanThemeProvider.tsx","../src/react/components/NextThemeProvider.tsx","../src/react/hooks/use-sync-server-theme-storage.ts","../src/tanstack/helpers.ts","../src/react/components/TanStackThemeProvider.tsx","../src/react/components/ViteThemeProvider.tsx"],"names":["ThemeAnimationType","styleElement","isBrowser","useState","useEffect","jsx","jsxs","clsx","createContext","useContext","React","useCallback"],"mappings":";;;;;;;;;;AAEO,IAAK,kBAA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cesContent":["import { RefObject } from 'react'\n\nexport enum ThemeAnimationType {\n CIRCLE = 'circle',\n BLUR_CIRCLE = 'blur-circle',\n SLIDE = 'slide',\n}\n\nexport type SlideDirection =\n | 'left'\n | 'right'\n | 'top'\n | 'bottom'\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right'\n\nexport type Theme = 'light' | 'dark' | 'system'\nexport type ColorTheme = string\nexport type SystemThemeMode = 'css' | 'js'\n\nexport interface UseThemeAnimationProps {\n duration?: number\n easing?: string\n animationType?: ThemeAnimationType\n blurAmount?: number\n styleId?: string\n\n themes?: Theme[]\n colorThemes?: ColorTheme[]\n defaultTheme?: Theme\n defaultColorTheme?: ColorTheme\n\n globalClassName?: string\n colorThemePrefix?: string\n attribute?: 'class' | 'data-theme'\n value?: Record<string, string>\n enableColorScheme?: boolean\n\n storageKey?: string\n colorStorageKey?: string\n\n theme?: Theme\n colorTheme?: ColorTheme\n\n onThemeChange?: (theme: Theme) => void\n onColorThemeChange?: (colorTheme: ColorTheme) => void\n\n initialTheme?: Theme\n initialColorTheme?: ColorTheme\n systemThemeMode?: SystemThemeMode\n\n // Slide animation options (only valid when animationType is SLIDE)\n slideDirection?: SlideDirection\n slideFromX?: number // custom from translate X (%)\n slideFromY?: number // custom from translate Y (%)\n slideToX?: number // custom to translate X (%)\n slideToY?: number // custom to translate Y (%)\n}\n\nexport interface UseThemeAnimationReturn {\n ref: RefObject<HTMLButtonElement | null>\n\n theme: Theme\n colorTheme: ColorTheme\n resolvedTheme: 'light' | 'dark'\n systemTheme: 'light' | 'dark'\n\n setTheme: (theme: Theme) => void\n setColorTheme: (colorTheme: ColorTheme) => void\n\n switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>\n switchColorTheme: (colorTheme: string) => void\n\n toggleTheme: (animationOff?: boolean) => Promise<void>\n toggleLightTheme: (animationOff?: boolean) => Promise<void>\n toggleDarkTheme: (animationOff?: boolean) => Promise<void>\n toggleColorTheme: () => void\n\n createColorThemeToggle: (targetColorTheme: string) => () => void\n isColorThemeActive: (targetColorTheme: string) => boolean\n}\n\nexport interface ThemeSwitcherProps {\n themes?: Theme[]\n currentTheme?: Theme\n onThemeChange?: (theme: Theme) => void\n\n animationType?: ThemeAnimationType\n duration?: number\n\n className?: string\n size?: 'sm' | 'md' | 'lg'\n variant?: 'default' | 'outline' | 'ghost'\n\n icons?: {\n light?: React.ReactNode\n dark?: React.ReactNode\n system?: React.ReactNode\n }\n}\n\nexport interface ThemeSelectorProps {\n themes?: Theme[]\n colorThemes?: ColorTheme[]\n currentTheme?: Theme\n currentColorTheme?: ColorTheme\n\n onThemeChange?: (theme: Theme) => void\n onColorThemeChange?: (colorTheme: ColorTheme) => void\n\n animationType?: ThemeAnimationType\n duration?: number\n\n className?: string\n placeholder?: string\n\n themeLabel?: string\n colorThemeLabel?: string\n}\n","import { ThemeAnimationType } from '../types'\n\nconst isBrowser = typeof window !== 'undefined'\n\nexport const injectBaseStyles = (): void => {\n if (isBrowser) {\n const styleId = 'spaceman-theme-base-style'\n if (!document.getElementById(styleId)) {\n const style = document.createElement('style')\n style.id = styleId\n const isHighResolution =\n window.innerWidth >= 3000 || window.innerHeight >= 2000\n\n style.textContent = `\n ::view-transition-old(root),\n ::view-transition-new(root) {\n animation: none;\n mix-blend-mode: normal;\n ${isHighResolution ? 'transform: translateZ(0);' : ''}\n }\n \n ${\n isHighResolution\n ? `\n ::view-transition-group(root),\n ::view-transition-image-pair(root),\n ::view-transition-old(root),\n ::view-transition-new(root) {\n backface-visibility: hidden;\n perspective: 1000px;\n transform: translate3d(0, 0, 0);\n }\n `\n : ''\n }\n `\n document.head.appendChild(style)\n }\n }\n}\n\nexport const createBlurCircleMask = (blur: number): string => {\n const isHighResolution =\n isBrowser && (window.innerWidth >= 3000 || window.innerHeight >= 2000)\n\n const blurFilter = `<filter id=\"blur\"><feGaussianBlur stdDeviation=\"${blur}\" /></filter>`\n const circleRadius = isHighResolution ? 20 : 25\n\n return `url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-50 -50 100 100\"><defs>${blurFilter}</defs><circle cx=\"0\" cy=\"0\" r=\"${circleRadius}\" fill=\"white\" filter=\"url(%23blur)\"/></svg>')`\n}\n\nexport const getSystemTheme = (): 'light' | 'dark' => {\n if (!isBrowser) return 'light'\n return window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light'\n}\n\nexport const resolveTheme = (theme: string): 'light' | 'dark' => {\n if (theme === 'system') {\n return getSystemTheme()\n }\n return theme === 'dark' ? 'dark' : 'light'\n}\n\nexport const resolveThemeForServer = (\n theme: string\n): 'light' | 'dark' | 'system' => {\n if (theme === 'system') {\n return 'system'\n }\n return theme === 'dark' ? 'dark' : 'light'\n}\n\nexport const supportsViewTransitions = (): boolean => {\n return isBrowser && 'startViewTransition' in document\n}\n\nexport const prefersReducedMotion = (): boolean => {\n return (\n isBrowser && window.matchMedia('(prefers-reduced-motion: reduce)').matches\n )\n}\n\nexport interface AnimationConfig {\n a?: number\n b?: number\n x: number\n y: number\n duration: number\n easing: string\n animationType: ThemeAnimationType\n blurAmount: number\n styleId: string\n}\n\nexport const createCircleAnimation = (config: AnimationConfig): void => {\n const { x, y, duration, easing } = config\n\n // Calculate the distance to each corner of the viewport\n const topLeft = Math.hypot(x, y)\n const topRight = Math.hypot(window.innerWidth - x, y)\n const bottomLeft = Math.hypot(x, window.innerHeight - y)\n const bottomRight = Math.hypot(window.innerWidth - x, window.innerHeight - y)\n\n // Find the maximum distance to ensure animation covers the entire viewport\n const maxRadius = Math.max(topLeft, topRight, bottomLeft, bottomRight)\n\n document.documentElement.animate(\n {\n clipPath: [\n `circle(0px at ${x}px ${y}px)`,\n `circle(${maxRadius}px at ${x}px ${y}px)`,\n ],\n },\n {\n duration,\n easing,\n pseudoElement: '::view-transition-new(root)',\n }\n )\n}\n\nexport const createSlideAnimation = (config: AnimationConfig): void => {\n const { a = -100, b = 0, x = 0, y = 0, duration, styleId } = config\n\n const styleElement = document.createElement('style')\n styleElement.id = styleId\n\n styleElement.textContent = `\n ::view-transition-old(root) {\n animation-delay: ${duration}ms;\n }\n \n ::view-transition-new(root) {\n animation: move-in ${duration}ms;\n animation-timing-function: cubic-bezier(0.66, 0, 0.34, 1);\n }\n \n @keyframes move-in {\n from {\n translate: ${a}% ${b}%;\n }\n to {\n translate: ${x}% ${y}%;\n }\n }\n `\n\n document.head.appendChild(styleElement)\n\n // Clean up after animation\n setTimeout(() => {\n const styleElement = document.getElementById(styleId)\n if (styleElement) {\n styleElement.remove()\n }\n }, duration)\n}\n\nexport const createBlurCircleAnimation = (config: AnimationConfig): void => {\n const { x, y, duration, easing, blurAmount, styleId } = config\n\n const existingStyle = document.getElementById(styleId)\n if (existingStyle) {\n existingStyle.remove()\n }\n\n const viewportSize = Math.max(window.innerWidth, window.innerHeight) + 200\n const isHighResolution =\n window.innerWidth >= 3000 || window.innerHeight >= 2000\n const scaleFactor = isHighResolution ? 2.5 : 4\n const optimalMaskSize = isHighResolution\n ? Math.min(viewportSize * scaleFactor, 5000)\n : viewportSize * scaleFactor\n\n const topLeft = Math.hypot(x, y)\n const topRight = Math.hypot(window.innerWidth - x, y)\n const bottomLeft = Math.hypot(x, window.innerHeight - y)\n const bottomRight = Math.hypot(window.innerWidth - x, window.innerHeight - y)\n const maxRadius = Math.max(topLeft, topRight, bottomLeft, bottomRight)\n\n const styleElement = document.createElement('style')\n styleElement.id = styleId\n\n const blurFactor = isHighResolution ? 1.5 : 1.2\n const finalMaskSize = Math.max(optimalMaskSize, maxRadius * 2.5)\n\n styleElement.textContent = `\n ::view-transition-group(root) {\n animation-duration: ${duration}ms;\n animation-timing-function: ${\n isHighResolution\n ? 'cubic-bezier(0.2, 0, 0.2, 1)'\n : 'linear(' +\n '0 0%, 0.2342 12.49%, 0.4374 24.99%,' +\n '0.6093 37.49%, 0.6835 43.74%,' +\n '0.7499 49.99%, 0.8086 56.25%,' +\n '0.8593 62.5%, 0.9023 68.75%, 0.9375 75%,' +\n '0.9648 81.25%, 0.9844 87.5%,' +\n '0.9961 93.75%, 1 100%' +\n ')'\n };\n will-change: transform;\n }\n \n ::view-transition-new(root) {\n mask: ${createBlurCircleMask(blurAmount * blurFactor)} 0 0 / 100% 100% no-repeat;\n mask-position: ${x}px ${y}px;\n animation: spaceman-mask-scale ${duration}ms ${easing};\n transform-origin: ${x}px ${y}px;\n will-change: mask-size, mask-position;\n }\n \n ::view-transition-old(root),\n .dark::view-transition-old(root) {\n animation: spaceman-mask-scale ${duration}ms ${easing};\n transform-origin: ${x}px ${y}px;\n z-index: -1;\n will-change: mask-size, mask-position;\n }\n \n @keyframes spaceman-mask-scale {\n 0% {\n mask-size: 0px;\n mask-position: ${x}px ${y}px;\n }\n 100% {\n mask-size: ${finalMaskSize}px;\n mask-position: ${x - finalMaskSize / 2}px ${y - finalMaskSize / 2}px;\n }\n }\n `\n\n document.head.appendChild(styleElement)\n\n setTimeout(() => {\n const styleElement = document.getElementById(styleId)\n if (styleElement) {\n styleElement.remove()\n }\n }, duration)\n}\n","import { useEffect, useRef, useState, useCallback } from 'react'\nimport { flushSync } from 'react-dom'\nimport {\n UseThemeAnimationProps,\n UseThemeAnimationReturn,\n ThemeAnimationType,\n Theme,\n} from '../../core/types'\nimport {\n injectBaseStyles,\n resolveTheme,\n getSystemTheme,\n supportsViewTransitions,\n prefersReducedMotion,\n createCircleAnimation,\n createBlurCircleAnimation,\n createSlideAnimation,\n} from '../../core/utils/animations'\n\nconst isBrowser = typeof window !== 'undefined'\n\nexport const useThemeAnimation = (\n props: UseThemeAnimationProps = {}\n): UseThemeAnimationReturn => {\n const {\n duration: propsDuration = 750,\n easing = 'ease-in-out',\n animationType = ThemeAnimationType.CIRCLE,\n blurAmount = 2,\n styleId = 'spaceman-theme-style',\n\n themes = ['light', 'dark', 'system'],\n colorThemes = ['default'],\n defaultTheme = 'system',\n defaultColorTheme = 'default',\n\n globalClassName = 'dark',\n colorThemePrefix = 'theme-',\n attribute = 'class',\n value,\n enableColorScheme = true,\n\n storageKey = 'theme',\n colorStorageKey = 'color-theme',\n\n theme: externalTheme,\n colorTheme: externalColorTheme,\n\n onThemeChange,\n onColorThemeChange,\n\n initialTheme,\n initialColorTheme,\n systemThemeMode = 'js',\n\n // Slide animation options\n slideDirection = 'left',\n slideFromX,\n slideFromY,\n slideToX = 0,\n slideToY = 0,\n } = props\n\n const isHighResolution =\n isBrowser && (window.innerWidth >= 3000 || window.innerHeight >= 2000)\n const duration = isHighResolution\n ? Math.max(propsDuration * 0.8, 500)\n : propsDuration\n\n const [mounted, setMounted] = useState(false)\n\n // Inject base styles once on mount\n useEffect(() => {\n injectBaseStyles()\n setMounted(true)\n }, [])\n\n const [internalTheme, setInternalTheme] = useState<Theme>(() => {\n if (initialTheme !== undefined) return initialTheme\n if (!isBrowser) return defaultTheme\n const saved = localStorage.getItem(storageKey) as Theme | null\n return saved && themes.indexOf(saved) !== -1 ? saved : defaultTheme\n })\n\n const [internalColorTheme, setInternalColorTheme] = useState(() => {\n if (initialColorTheme !== undefined) return initialColorTheme\n if (!isBrowser) return defaultColorTheme\n const saved = localStorage.getItem(colorStorageKey)\n return saved && colorThemes.indexOf(saved) !== -1\n ? saved\n : defaultColorTheme\n })\n\n const currentTheme = externalTheme ?? internalTheme\n const currentColorTheme = externalColorTheme ?? internalColorTheme\n\n const [, setSystemTheme] = useState<'light' | 'dark'>(() => getSystemTheme())\n const systemTheme = getSystemTheme()\n const resolvedTheme = resolveTheme(currentTheme)\n\n useEffect(() => {\n if (!isBrowser) return\n\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')\n const handleChange = () => setSystemTheme(getSystemTheme())\n\n mediaQuery.addEventListener('change', handleChange)\n return () => mediaQuery.removeEventListener('change', handleChange)\n }, [])\n\n // Apply theme classes to DOM\n useEffect(() => {\n if (!isBrowser || !mounted) return\n\n const element = document.documentElement\n\n const lightValue = value?.light\n const darkValue = value?.dark ?? globalClassName\n const systemValue = value?.system ?? 'system'\n\n if (attribute === 'data-theme') {\n if (systemThemeMode === 'css' && currentTheme === 'system') {\n element.setAttribute('data-theme', systemValue)\n } else {\n element.setAttribute(\n 'data-theme',\n resolvedTheme === 'dark' ? darkValue : (lightValue ?? 'light')\n )\n }\n } else {\n if (lightValue) {\n element.classList.remove(lightValue)\n }\n element.classList.remove(darkValue, systemValue, 'auto')\n\n if (systemThemeMode === 'css' && currentTheme === 'system') {\n element.classList.add(systemValue)\n } else if (resolvedTheme === 'dark') {\n element.classList.add(darkValue)\n } else if (lightValue) {\n element.classList.add(lightValue)\n } else {\n element.classList.remove(darkValue)\n }\n }\n\n if (enableColorScheme) {\n element.style.colorScheme =\n systemThemeMode === 'css' && currentTheme === 'system'\n ? ''\n : resolvedTheme\n } else {\n element.style.removeProperty('color-scheme')\n }\n\n colorThemes.forEach(theme => {\n element.classList.remove(`${colorThemePrefix}${theme}`)\n })\n element.classList.add(`${colorThemePrefix}${currentColorTheme}`)\n }, [\n resolvedTheme,\n currentTheme,\n currentColorTheme,\n globalClassName,\n colorThemePrefix,\n colorThemes,\n attribute,\n value,\n enableColorScheme,\n mounted,\n systemThemeMode,\n ])\n\n const ref = useRef<HTMLButtonElement>(null)\n\n const setTheme = useCallback(\n (newTheme: Theme) => {\n // Always save to localStorage\n if (isBrowser) {\n localStorage.setItem(storageKey, newTheme)\n }\n\n // Update internal state if no external control\n if (externalTheme === undefined) {\n setInternalTheme(newTheme)\n }\n\n // Call external callback if provided\n if (onThemeChange) {\n onThemeChange(newTheme)\n }\n },\n [onThemeChange, externalTheme, storageKey]\n )\n\n const setColorTheme = useCallback(\n (newColorTheme: string) => {\n // Always save to localStorage\n if (isBrowser) {\n localStorage.setItem(colorStorageKey, newColorTheme)\n }\n\n // Update internal state if no external control\n if (externalColorTheme === undefined) {\n setInternalColorTheme(newColorTheme)\n }\n\n // Call external callback if provided\n if (onColorThemeChange) {\n onColorThemeChange(newColorTheme)\n }\n },\n [onColorThemeChange, externalColorTheme, colorStorageKey]\n )\n\n const switchTheme = useCallback(\n async (newTheme: Theme, animationOff: boolean = false) => {\n if (\n !ref.current ||\n !supportsViewTransitions() ||\n prefersReducedMotion() ||\n animationOff\n ) {\n setTheme(newTheme)\n return\n }\n\n // Helper function to convert direction to from coordinates\n const getSlideFromCoords = (direction: string) => {\n switch (direction) {\n case 'left':\n return { a: -100, b: 0 }\n case 'right':\n return { a: 100, b: 0 }\n case 'top':\n return { a: 0, b: -100 }\n case 'bottom':\n return { a: 0, b: 100 }\n case 'top-left':\n return { a: -100, b: -100 }\n case 'top-right':\n return { a: 100, b: -100 }\n case 'bottom-left':\n return { a: -100, b: 100 }\n case 'bottom-right':\n return { a: 100, b: 100 }\n default:\n return { a: -100, b: 0 }\n }\n }\n\n let animationConfig\n\n if (animationType === ThemeAnimationType.SLIDE) {\n // Use custom coordinates if provided, otherwise use direction\n const fromCoords =\n slideFromX !== undefined && slideFromY !== undefined\n ? { a: slideFromX, b: slideFromY }\n : getSlideFromCoords(slideDirection)\n\n animationConfig = {\n a: fromCoords.a,\n b: fromCoords.b,\n x: slideToX,\n y: slideToY,\n duration,\n easing,\n animationType,\n blurAmount,\n styleId,\n }\n } else {\n // For circle and blur circle animations, use button center\n const { top, left, width, height } = ref.current.getBoundingClientRect()\n const x = left + width / 2\n const y = top + height / 2\n\n animationConfig = {\n x,\n y,\n duration,\n easing,\n animationType,\n blurAmount,\n styleId,\n }\n }\n\n if (animationType === ThemeAnimationType.BLUR_CIRCLE) {\n createBlurCircleAnimation(animationConfig)\n }\n\n if (animationType === ThemeAnimationType.SLIDE) {\n createSlideAnimation(animationConfig)\n }\n\n // Start the view transition\n\n await (document as Document).startViewTransition(() => {\n flushSync(() => {\n setTheme(newTheme)\n })\n }).ready\n\n if (animationType === ThemeAnimationType.CIRCLE) {\n createCircleAnimation(animationConfig)\n }\n },\n [\n setTheme,\n duration,\n easing,\n animationType,\n blurAmount,\n styleId,\n slideDirection,\n slideFromX,\n slideFromY,\n slideToX,\n slideToY,\n ]\n )\n\n const switchColorTheme = useCallback(\n (newColorTheme: string) => {\n if (colorThemes.indexOf(newColorTheme) === -1) {\n console.warn(\n `Color theme \"${newColorTheme}\" not found in available themes`\n )\n return\n }\n setColorTheme(newColorTheme)\n },\n [colorThemes, setColorTheme]\n )\n\n const toggleTheme = useCallback(\n async (animationOff: boolean = false) => {\n const newTheme: Theme = resolvedTheme === 'dark' ? 'light' : 'dark'\n await switchTheme(newTheme, animationOff)\n },\n [resolvedTheme, switchTheme]\n )\n\n const toggleLightTheme = useCallback(\n async (animationOff: boolean = false) => {\n if (resolvedTheme === 'light') return\n\n await switchTheme('light', animationOff)\n },\n [resolvedTheme, switchTheme]\n )\n\n const toggleDarkTheme = useCallback(\n async (animationOff: boolean = false) => {\n if (resolvedTheme === 'dark') return\n\n await switchTheme('dark', animationOff)\n },\n [resolvedTheme, switchTheme]\n )\n\n const toggleColorTheme = useCallback(() => {\n const currentIndex = colorThemes.indexOf(currentColorTheme)\n const nextIndex = (currentIndex + 1) % colorThemes.length\n const nextColorTheme = colorThemes[nextIndex]\n setColorTheme(nextColorTheme)\n }, [currentColorTheme, colorThemes, setColorTheme])\n\n const createColorThemeToggle = useCallback(\n (targetColorTheme: string) => {\n return () => {\n if (colorThemes.indexOf(targetColorTheme) === -1) {\n console.warn(\n `Color theme \"${targetColorTheme}\" not found in available themes`\n )\n return\n }\n setColorTheme(targetColorTheme)\n }\n },\n [colorThemes, setColorTheme]\n )\n\n const isColorThemeActive = useCallback(\n (targetColorTheme: string) => {\n return currentColorTheme === targetColorTheme\n },\n [currentColorTheme]\n )\n\n return {\n ref,\n theme: currentTheme,\n colorTheme: currentColorTheme,\n resolvedTheme,\n systemTheme,\n setTheme,\n setColorTheme,\n switchTheme,\n switchColorTheme,\n toggleTheme,\n toggleLightTheme,\n toggleDarkTheme,\n toggleColorTheme,\n createColorThemeToggle,\n isColorThemeActive,\n }\n}\n","import React, { createContext, useContext } from 'react'\nimport { ColorTheme, Theme } from '../../core/types'\n\nexport interface SharedThemeContextValue {\n ref: React.RefObject<HTMLButtonElement | null>\n theme: Theme\n colorTheme: ColorTheme\n setTheme: (theme: Theme) => void\n setColorTheme: (colorTheme: ColorTheme) => void\n switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>\n switchThemeFromElement?: (\n theme: Theme,\n element: HTMLButtonElement\n ) => Promise<void>\n}\n\nexport const SharedThemeContext = createContext<SharedThemeContextValue | null>(\n null\n)\n\nexport const useSharedThemeContext = (): SharedThemeContextValue | null => {\n return useContext(SharedThemeContext)\n}\n","import React, { type JSX, useEffect, useState } from 'react'\nimport { motion } from 'motion/react'\nimport { clsx } from 'clsx'\nimport { ThemeSwitcherProps, Theme } from '../../core/types'\nimport { useThemeAnimation } from '../hooks/use-theme-animation'\nimport {\n SharedThemeContextValue,\n useSharedThemeContext,\n} from './shared-theme-context'\n\nconst SunIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"5\" />\n <path d=\"M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42\" />\n </svg>\n)\n\nconst MoonIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z\" />\n </svg>\n)\n\nconst MonitorIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <rect width=\"20\" height=\"14\" x=\"2\" y=\"3\" rx=\"2\" />\n <line x1=\"8\" x2=\"16\" y1=\"21\" y2=\"21\" />\n <line x1=\"12\" x2=\"12\" y1=\"17\" y2=\"21\" />\n </svg>\n)\n\nconst ThemeOption = ({\n icon,\n value,\n isActive,\n isHovered,\n onClick,\n onMouseEnter,\n onMouseLeave,\n buttonRef,\n}: {\n icon: JSX.Element\n value: string\n isActive?: boolean\n isHovered?: boolean\n onClick: (value: string, event?: React.MouseEvent<HTMLButtonElement>) => void\n onMouseEnter: () => void\n onMouseLeave: () => void\n buttonRef?: React.RefObject<HTMLButtonElement | null>\n}) => {\n return (\n <button\n ref={\n isActive ? (buttonRef as React.RefObject<HTMLButtonElement>) : undefined\n }\n className={clsx(\n 'relative flex h-9 w-12 cursor-pointer items-center justify-center',\n 'text-muted-foreground hover:text-foreground',\n isActive && 'text-foreground font-medium'\n )}\n role=\"radio\"\n aria-checked={isActive}\n aria-label={`Switch to ${value} theme`}\n onClick={event => onClick(value, event)}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n style={{\n borderRadius: 'var(--radius)',\n }}\n >\n {isHovered && (\n <motion.div\n layoutId=\"theme-hover\"\n className=\"absolute inset-0 bg-muted\"\n style={{\n borderRadius: 'var(--radius)',\n }}\n transition={{\n type: 'spring',\n bounce: 0,\n stiffness: 100,\n damping: 10,\n duration: 0.3,\n }}\n />\n )}\n\n <div className=\"relative z-10 flex items-center justify-center\">\n <div className=\"[&_svg]:size-4\">{icon}</div>\n </div>\n\n {isActive && (\n <div\n className=\"absolute bottom-0 left-1/2 h-0.5 w-6 -translate-x-1/2 rounded-full\"\n style={{\n backgroundColor: 'hsl(var(--primary))',\n }}\n />\n )}\n </button>\n )\n}\n\nconst THEME_OPTIONS = [\n {\n icon: <MonitorIcon />,\n value: 'system',\n },\n {\n icon: <SunIcon />,\n value: 'light',\n },\n {\n icon: <MoonIcon />,\n value: 'dark',\n },\n]\n\ninterface ThemeSwitcherViewProps {\n className?: string\n onSwitchTheme: (\n theme: Theme,\n event?: React.MouseEvent<HTMLButtonElement>\n ) => Promise<void>\n theme: Theme\n themes: Theme[]\n themeRef?: React.RefObject<HTMLButtonElement | null>\n}\n\nconst ThemeSwitcherView: React.FC<ThemeSwitcherViewProps> = ({\n className,\n onSwitchTheme,\n theme,\n themes,\n themeRef,\n}) => {\n const [isMounted, setIsMounted] = useState(false)\n const [hoveredTheme, setHoveredTheme] = useState<string | null>(null)\n\n useEffect(() => {\n setIsMounted(true)\n }, [])\n\n const handleThemeChange = async (\n newTheme: string,\n event?: React.MouseEvent<HTMLButtonElement>\n ) => {\n await onSwitchTheme(newTheme as Theme, event)\n }\n\n const filteredOptions = THEME_OPTIONS.filter(option =>\n themes.includes(option.value as Theme)\n )\n\n return (\n <div\n className={clsx(\n 'inline-flex h-9 items-center overflow-hidden bg-background shadow-sm border border-border',\n isMounted ? 'opacity-100' : 'opacity-0',\n className\n )}\n style={{\n borderRadius: 'var(--radius)',\n backgroundColor: 'hsl(var(--background))',\n }}\n role=\"radiogroup\"\n onMouseLeave={() => setHoveredTheme(null)}\n >\n {filteredOptions.map(option => (\n <ThemeOption\n key={option.value}\n icon={option.icon}\n value={option.value}\n isActive={theme === option.value}\n isHovered={hoveredTheme === option.value}\n onClick={handleThemeChange}\n onMouseEnter={() => setHoveredTheme(option.value)}\n onMouseLeave={() => {}}\n buttonRef={theme === option.value ? themeRef : undefined}\n />\n ))}\n </div>\n )\n}\n\nconst ThemeSwitcherWithContext: React.FC<\n Pick<ThemeSwitcherProps, 'className' | 'themes'> & {\n contextTheme: SharedThemeContextValue\n }\n> = ({ className, contextTheme, themes = ['light', 'dark', 'system'] }) => {\n const handleSwitchTheme = async (\n theme: Theme,\n event?: React.MouseEvent<HTMLButtonElement>\n ) => {\n if (contextTheme.switchThemeFromElement && event) {\n await contextTheme.switchThemeFromElement(theme, event.currentTarget)\n return\n }\n\n await contextTheme.switchTheme(theme)\n }\n\n return (\n <ThemeSwitcherView\n className={className}\n onSwitchTheme={handleSwitchTheme}\n theme={contextTheme.theme}\n themes={themes}\n themeRef={contextTheme.ref}\n />\n )\n}\n\nconst ThemeSwitcherStandalone: React.FC<ThemeSwitcherProps> = ({\n themes = ['light', 'dark', 'system'],\n currentTheme,\n onThemeChange,\n animationType,\n duration,\n className,\n}) => {\n const standaloneHook = useThemeAnimation({\n animationType,\n duration,\n themes,\n ...(currentTheme !== undefined && { theme: currentTheme }),\n onThemeChange,\n })\n\n const handleSwitchTheme = async (theme: Theme) => {\n await standaloneHook.switchTheme(theme)\n }\n\n return (\n <ThemeSwitcherView\n className={className}\n onSwitchTheme={handleSwitchTheme}\n theme={standaloneHook.theme}\n themes={themes}\n themeRef={standaloneHook.ref}\n />\n )\n}\n\nexport const ThemeSwitcher: React.FC<ThemeSwitcherProps> = props => {\n const contextTheme = useSharedThemeContext()\n\n if (contextTheme) {\n return <ThemeSwitcherWithContext {...props} contextTheme={contextTheme} />\n }\n\n return <ThemeSwitcherStandalone {...props} />\n}\n","import * as React from 'react'\nimport * as SelectPrimitive from '@radix-ui/react-select'\nimport { clsx } from 'clsx'\n\nfunction Select({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Root>) {\n return <SelectPrimitive.Root data-slot=\"select\" {...props} />\n}\n\nfunction SelectGroup({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Group>) {\n return <SelectPrimitive.Group data-slot=\"select-group\" {...props} />\n}\n\nfunction SelectValue({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Value>) {\n return <SelectPrimitive.Value data-slot=\"select-value\" {...props} />\n}\n\nconst ChevronDownIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n)\n\nconst ChevronUpIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"m18 15-6-6-6 6\" />\n </svg>\n)\n\nconst CheckIcon = () => (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n)\n\nfunction SelectTrigger({\n className,\n size = 'default',\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n size?: 'sm' | 'default'\n}) {\n return (\n <SelectPrimitive.Trigger\n data-slot=\"select-trigger\"\n data-size={size}\n className={clsx(\n \"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronDownIcon />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n )\n}\n\nfunction SelectContent({\n className,\n children,\n position = 'popper',\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Content>) {\n return (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n data-slot=\"select-content\"\n className={clsx(\n 'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md',\n position === 'popper' &&\n 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',\n className\n )}\n position={position}\n {...props}\n >\n <SelectPrimitive.Viewport\n className={clsx(\n 'p-1',\n position === 'popper' &&\n 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Label>) {\n return (\n <SelectPrimitive.Label\n data-slot=\"select-label\"\n className={clsx('py-1.5 pl-8 pr-2 text-sm font-semibold', className)}\n {...props}\n />\n )\n}\n\nfunction SelectItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>) {\n return (\n <SelectPrimitive.Item\n data-slot=\"select-item\"\n className={clsx(\n \"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2\",\n className\n )}\n {...props}\n >\n <span className=\"absolute left-2 flex h-3.5 w-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <CheckIcon />\n </SelectPrimitive.ItemIndicator>\n </span>\n\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n )\n}\n\nfunction SelectSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Separator>) {\n return (\n <SelectPrimitive.Separator\n data-slot=\"select-separator\"\n className={clsx('-mx-1 my-1 h-px bg-muted', className)}\n {...props}\n />\n )\n}\n\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {\n return (\n <SelectPrimitive.ScrollUpButton\n data-slot=\"select-scroll-up-button\"\n className={clsx(\n 'flex cursor-default items-center justify-center py-1',\n className\n )}\n {...props}\n >\n <ChevronUpIcon />\n </SelectPrimitive.ScrollUpButton>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {\n return (\n <SelectPrimitive.ScrollDownButton\n data-slot=\"select-scroll-down-button\"\n className={clsx(\n 'flex cursor-default items-center justify-center py-1',\n className\n )}\n {...props}\n >\n <ChevronDownIcon />\n </SelectPrimitive.ScrollDownButton>\n )\n}\n\nexport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n}\n","import React from 'react'\nimport { ThemeSelectorProps, ColorTheme } from '../../core/types'\nimport { useThemeAnimation } from '../hooks/use-theme-animation'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from './ui/select'\nimport {\n SharedThemeContextValue,\n useSharedThemeContext,\n} from './shared-theme-context'\n\ninterface ThemeSelectorViewProps {\n colorTheme: ColorTheme\n colorThemes: ColorTheme[]\n onSelectColorTheme: (colorTheme: ColorTheme) => void\n}\n\nconst ThemeSelectorView: React.FC<ThemeSelectorViewProps> = ({\n colorTheme,\n colorThemes,\n onSelectColorTheme,\n}) => {\n return (\n <>\n {colorThemes.length > 1 ? (\n <div className=\"flex flex-col gap-2\">\n <Select\n value={colorTheme}\n onValueChange={value => onSelectColorTheme(value as ColorTheme)}\n >\n <SelectTrigger className=\"capitalize\">\n <SelectValue placeholder=\"Choose a color theme\" />\n </SelectTrigger>\n <SelectContent>\n {colorThemes.map(theme => (\n <SelectItem key={theme} className=\"capitalize\" value={theme}>\n {theme}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n ) : null}\n </>\n )\n}\n\nconst ThemeSelectorWithContext: React.FC<\n Pick<ThemeSelectorProps, 'colorThemes'> & {\n contextTheme: SharedThemeContextValue\n }\n> = ({ colorThemes = ['default'], contextTheme }) => {\n return (\n <ThemeSelectorView\n colorTheme={contextTheme.colorTheme}\n colorThemes={colorThemes}\n onSelectColorTheme={contextTheme.setColorTheme}\n />\n )\n}\n\nconst ThemeSelectorStandalone: React.FC<ThemeSelectorProps> = ({\n themes = ['light', 'dark', 'system'],\n colorThemes = ['default'],\n currentColorTheme,\n onColorThemeChange,\n animationType,\n duration,\n}) => {\n const standaloneHook = useThemeAnimation({\n animationType,\n duration,\n themes,\n colorThemes,\n ...(currentColorTheme !== undefined && { colorTheme: currentColorTheme }),\n onColorThemeChange,\n })\n\n return (\n <ThemeSelectorView\n colorTheme={standaloneHook.colorTheme}\n colorThemes={colorThemes}\n onSelectColorTheme={standaloneHook.setColorTheme}\n />\n )\n}\n\nexport const ThemeSelector: React.FC<ThemeSelectorProps> = props => {\n const contextTheme = useSharedThemeContext()\n\n if (contextTheme) {\n return <ThemeSelectorWithContext {...props} contextTheme={contextTheme} />\n }\n\n return <ThemeSelectorStandalone {...props} />\n}\n","import { Theme } from '../../core/types'\n\nexport const withElementAsRef = async (\n ref: React.RefObject<HTMLButtonElement | null>,\n element: HTMLButtonElement,\n run: () => Promise<void>\n) => {\n if (ref.current) {\n const originalRef = ref.current\n Object.defineProperty(ref, 'current', {\n value: element,\n writable: true,\n configurable: true,\n })\n await run()\n Object.defineProperty(ref, 'current', {\n value: originalRef,\n writable: true,\n configurable: true,\n })\n return\n }\n\n Object.defineProperty(ref, 'current', {\n value: element,\n writable: true,\n configurable: true,\n })\n await run()\n}\n\nexport const getBrowserSystemTheme = (): 'light' | 'dark' => {\n return typeof window !== 'undefined' &&\n window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light'\n}\n\nexport const getNextResolvedTheme = (\n resolvedTheme: 'light' | 'dark'\n): Theme => {\n return resolvedTheme === 'dark' ? 'light' : 'dark'\n}\n","import React, {\n createContext,\n useContext,\n ReactNode,\n useState,\n useEffect,\n} from 'react'\nimport { useThemeAnimation } from '../hooks/use-theme-animation'\nimport { Theme, ColorTheme, ThemeAnimationType } from '../../core/types'\nimport { SharedThemeContext } from './shared-theme-context'\nimport { withElementAsRef } from './provider-helpers'\n\n/**\n * Context type for the Spaceman Theme Provider\n */\ninterface SpacemanThemeContextType {\n ref: React.RefObject<HTMLButtonElement | null>\n theme: Theme\n colorTheme: ColorTheme\n resolvedTheme: 'light' | 'dark'\n setTheme: (theme: Theme) => void\n setColorTheme: (colorTheme: ColorTheme) => void\n\n switchTheme: (theme: Theme) => Promise<void>\n switchColorTheme: (colorTheme: string) => void\n\n toggleTheme: () => Promise<void>\n toggleLightTheme: () => Promise<void>\n toggleDarkTheme: () => Promise<void>\n toggleColorTheme: () => void\n\n createColorThemeToggle: (targetColorTheme: string) => () => void\n isColorThemeActive: (targetColorTheme: string) => boolean\n\n switchThemeFromElement: (\n theme: Theme,\n element: HTMLButtonElement\n ) => Promise<void>\n}\n\nconst SpacemanThemeContext = createContext<\n SpacemanThemeContextType | undefined\n>(undefined)\n\n/**\n * Props for the Spaceman Theme Provider\n */\ninterface SpacemanThemeProviderProps {\n children: ReactNode\n themes?: Theme[]\n colorThemes?: ColorTheme[]\n defaultTheme?: Theme\n defaultColorTheme?: ColorTheme\n animationType?: ThemeAnimationType\n duration?: number\n}\n\n/**\n * Spaceman Theme Provider - Provides centralized theme state management\n *\n * This provider creates a single source of truth for theme state using the useThemeAnimation hook.\n * All theme-related components should consume from this context to ensure synchronization.\n *\n * @param children - React children to wrap with theme context\n * @param themes - Available theme options (default: ['light', 'dark', 'system'])\n * @param colorThemes - Available color theme options (default: ['default'])\n * @param defaultTheme - Default theme to use (default: 'system')\n * @param defaultColorTheme - Default color theme to use (default: 'default')\n * @param animationType - Animation type for theme transitions (default: CIRCLE)\n * @param duration - Animation duration in milliseconds (default: 750)\n */\nexport const SpacemanThemeProvider: React.FC<SpacemanThemeProviderProps> = ({\n children,\n themes = ['light', 'dark', 'system'],\n colorThemes = ['default'],\n defaultTheme = 'system',\n defaultColorTheme = 'default',\n animationType = ThemeAnimationType.CIRCLE,\n duration = 750,\n}) => {\n const [mounted, setMounted] = useState(false)\n\n const themeState = useThemeAnimation({\n themes,\n colorThemes,\n defaultTheme,\n defaultColorTheme,\n animationType,\n duration,\n })\n\n useEffect(() => {\n setMounted(true)\n }, [])\n\n const switchThemeFromElement = async (\n theme: Theme,\n element: HTMLButtonElement\n ) => {\n await withElementAsRef(themeState.ref, element, async () => {\n await themeState.switchTheme(theme)\n })\n }\n\n if (!mounted) {\n const loadingContextValue: SpacemanThemeContextType = {\n ref: { current: null },\n theme: defaultTheme,\n colorTheme: defaultColorTheme,\n resolvedTheme: defaultTheme === 'dark' ? 'dark' : 'light',\n setTheme: () => {},\n setColorTheme: () => {},\n\n switchTheme: async () => {},\n switchThemeFromElement: async () => {},\n switchColorTheme: () => {},\n\n toggleTheme: async () => {},\n toggleLightTheme: async () => {},\n toggleDarkTheme: async () => {},\n toggleColorTheme: () => {},\n\n createColorThemeToggle: () => () => {},\n isColorThemeActive: () => false,\n }\n\n return (\n <SpacemanThemeContext.Provider value={loadingContextValue}>\n <SharedThemeContext.Provider value={loadingContextValue}>\n {children}\n </SharedThemeContext.Provider>\n </SpacemanThemeContext.Provider>\n )\n }\n\n const contextValue: SpacemanThemeContextType = {\n ref: themeState.ref,\n theme: themeState.theme,\n colorTheme: themeState.colorTheme,\n resolvedTheme: themeState.resolvedTheme,\n setTheme: themeState.setTheme,\n setColorTheme: themeState.setColorTheme,\n\n switchTheme: themeState.switchTheme,\n switchThemeFromElement,\n switchColorTheme: themeState.switchColorTheme,\n\n toggleTheme: themeState.toggleTheme,\n toggleLightTheme: themeState.toggleLightTheme,\n toggleDarkTheme: themeState.toggleDarkTheme,\n toggleColorTheme: themeState.toggleColorTheme,\n\n createColorThemeToggle: themeState.createColorThemeToggle,\n isColorThemeActive: themeState.isColorThemeActive,\n }\n\n return (\n <SpacemanThemeContext.Provider value={contextValue}>\n <SharedThemeContext.Provider value={contextValue}>\n {children}\n </SharedThemeContext.Provider>\n </SpacemanThemeContext.Provider>\n )\n}\n\n/**\n * Hook to consume the Spaceman Theme context\n *\n * @returns Theme context value with all theme state and methods\n * @throws Error if used outside of SpacemanThemeProvider\n */\nexport const useSpacemanTheme = (): SpacemanThemeContextType => {\n const context = useContext(SpacemanThemeContext)\n if (context === undefined) {\n throw new Error(\n 'useSpacemanTheme must be used within a SpacemanThemeProvider'\n )\n }\n return context\n}\n","'use client'\n\nimport React, {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react'\nimport { useThemeAnimation } from '../hooks/use-theme-animation'\nimport { ColorTheme, Theme, ThemeAnimationType } from '../../core/types'\nimport { SharedThemeContext } from './shared-theme-context'\nimport { getNextResolvedTheme, withElementAsRef } from './provider-helpers'\n\nexport interface NextThemeContextType {\n ref: React.RefObject<HTMLButtonElement | null>\n theme: Theme\n colorTheme: ColorTheme\n resolvedTheme: 'light' | 'dark'\n systemTheme: 'light' | 'dark'\n setTheme: (theme: Theme) => void\n setColorTheme: (colorTheme: ColorTheme) => void\n switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>\n switchColorTheme: (colorTheme: string) => void\n toggleTheme: (animationOff?: boolean) => Promise<void>\n toggleLightTheme: (animationOff?: boolean) => Promise<void>\n toggleDarkTheme: (animationOff?: boolean) => Promise<void>\n toggleColorTheme: () => void\n createColorThemeToggle: (targetColorTheme: string) => () => void\n isColorThemeActive: (targetColorTheme: string) => boolean\n switchThemeFromElement: (\n theme: Theme,\n element: HTMLButtonElement\n ) => Promise<void>\n}\n\nexport interface NextThemeProviderProps {\n children: React.ReactNode\n themes?: Theme[]\n colorThemes?: ColorTheme[]\n defaultTheme?: Theme\n defaultColorTheme?: ColorTheme\n animationType?: ThemeAnimationType\n duration?: number\n storageKey?: string\n colorStorageKey?: string\n attribute?: 'class' | 'data-theme'\n value?: Record<string, string>\n enableSystem?: boolean\n enableColorScheme?: boolean\n disableTransitionOnChange?: boolean\n forcedTheme?: Theme\n nonce?: string\n scriptProps?: Omit<\n React.ScriptHTMLAttributes<HTMLScriptElement>,\n 'dangerouslySetInnerHTML' | 'nonce'\n >\n colorThemePrefix?: string\n globalClassName?: string\n disableAnimationOnInit?: boolean\n disablePreHydrationScript?: boolean\n onThemeChange?: (theme: Theme) => void\n onColorThemeChange?: (colorTheme: ColorTheme) => void\n}\n\nconst NextThemeContext = createContext<NextThemeContextType | undefined>(\n undefined\n)\n\nconst createDisableTransitions = () => {\n const css = document.createElement('style')\n css.textContent =\n '*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}'\n document.head.appendChild(css)\n window.getComputedStyle(document.body)\n\n return () => {\n setTimeout(() => {\n if (css.parentNode) {\n css.parentNode.removeChild(css)\n }\n }, 1)\n }\n}\n\nconst generatePreHydrationScript = ({\n attribute,\n colorStorageKey,\n colorThemePrefix,\n defaultColorTheme,\n defaultTheme,\n enableColorScheme,\n enableSystem,\n globalClassName,\n storageKey,\n value,\n}: {\n attribute: 'class' | 'data-theme'\n colorStorageKey: string\n colorThemePrefix: string\n defaultColorTheme: ColorTheme\n defaultTheme: Theme\n enableColorScheme: boolean\n enableSystem: boolean\n globalClassName: string\n storageKey: string\n value?: Record<string, string>\n}) => {\n const lightValue = value?.light ?? 'light'\n const darkValue = value?.dark ?? globalClassName\n const systemValue = value?.system ?? 'system'\n\n return `(function(){try{var d=document.documentElement;var theme=localStorage.getItem('${storageKey}')||'${defaultTheme}';var colorTheme=localStorage.getItem('${colorStorageKey}')||'${defaultColorTheme}';if(!${JSON.stringify(\n enableSystem\n )}&&theme==='system'){theme='${defaultTheme === 'system' ? 'light' : defaultTheme}';}var resolved=theme==='system'?(window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'):theme;var attr='${attribute}';var lightValue='${lightValue}';var darkValue='${darkValue}';var systemValue='${systemValue}';if(attr==='data-theme'){d.setAttribute('data-theme',theme==='system'?systemValue:(resolved==='dark'?darkValue:lightValue));}else{d.classList.remove(lightValue,darkValue,systemValue,'auto');d.classList.add(theme==='system'?systemValue:(resolved==='dark'?darkValue:lightValue));}if(${JSON.stringify(\n enableColorScheme\n )}){d.style.colorScheme=theme==='system'?'':resolved;}else{d.style.removeProperty('color-scheme');}d.classList.add('${colorThemePrefix}'+colorTheme);}catch(e){console.warn('Theme pre-hydration script failed:',e);}})();`\n}\n\nconst ThemePreHydrationScript = React.memo(\n ({\n attribute,\n colorStorageKey,\n colorThemePrefix,\n defaultColorTheme,\n defaultTheme,\n enableColorScheme,\n enableSystem,\n globalClassName,\n nonce,\n scriptProps,\n storageKey,\n value,\n }: {\n attribute: 'class' | 'data-theme'\n colorStorageKey: string\n colorThemePrefix: string\n defaultColorTheme: ColorTheme\n defaultTheme: Theme\n enableColorScheme: boolean\n enableSystem: boolean\n globalClassName: string\n nonce?: string\n scriptProps?: Omit<\n React.ScriptHTMLAttributes<HTMLScriptElement>,\n 'dangerouslySetInnerHTML' | 'nonce'\n >\n storageKey: string\n value?: Record<string, string>\n }) => (\n <script\n {...scriptProps}\n nonce={nonce}\n suppressHydrationWarning\n dangerouslySetInnerHTML={{\n __html: generatePreHydrationScript({\n attribute,\n colorStorageKey,\n colorThemePrefix,\n defaultColorTheme,\n defaultTheme,\n enableColorScheme,\n enableSystem,\n globalClassName,\n storageKey,\n value,\n }),\n }}\n />\n )\n)\n\nThemePreHydrationScript.displayName = 'ThemePreHydrationScript'\n\nexport const NextThemeProvider: React.FC<NextThemeProviderProps> = ({\n attribute = 'class',\n children,\n colorStorageKey = 'color-theme',\n colorThemePrefix = 'theme-',\n colorThemes = ['default'],\n defaultColorTheme = 'default',\n defaultTheme = 'system',\n disableAnimationOnInit = true,\n disablePreHydrationScript = false,\n disableTransitionOnChange = false,\n duration = 750,\n enableColorScheme = true,\n enableSystem = true,\n forcedTheme,\n globalClassName = 'dark',\n nonce,\n onColorThemeChange,\n onThemeChange,\n scriptProps,\n storageKey = 'theme',\n themes,\n value,\n animationType = ThemeAnimationType.CIRCLE,\n}) => {\n const allowedThemes = useMemo<Theme[]>(() => {\n if (themes && themes.length > 0) {\n return themes\n }\n\n return enableSystem ? ['light', 'dark', 'system'] : ['light', 'dark']\n }, [enableSystem, themes])\n\n const effectiveDefaultTheme = useMemo<Theme>(() => {\n if (defaultTheme === 'system' && !enableSystem) {\n return 'light'\n }\n\n return defaultTheme\n }, [defaultTheme, enableSystem])\n\n const [mounted, setMounted] = useState(false)\n\n const themeState = useThemeAnimation({\n animationType,\n attribute,\n colorStorageKey,\n colorTheme: forcedTheme ? undefined : undefined,\n colorThemePrefix,\n colorThemes,\n defaultColorTheme,\n defaultTheme: effectiveDefaultTheme,\n duration,\n enableColorScheme,\n globalClassName,\n onColorThemeChange,\n onThemeChange,\n storageKey,\n theme: forcedTheme,\n themes: allowedThemes,\n value,\n })\n\n useEffect(() => {\n setMounted(true)\n }, [])\n\n const withTransitionsDisabled = useCallback(\n async <T,>(fn: () => Promise<T> | T) => {\n const cleanup = disableTransitionOnChange\n ? createDisableTransitions()\n : undefined\n\n try {\n return await fn()\n } finally {\n cleanup?.()\n }\n },\n [disableTransitionOnChange]\n )\n\n const setTheme = useCallback(\n (theme: Theme) => {\n void withTransitionsDisabled(async () => {\n themeState.setTheme(theme)\n })\n },\n [themeState, withTransitionsDisabled]\n )\n\n const switchTheme = useCallback(\n async (theme: Theme, animationOff: boolean = false) => {\n await withTransitionsDisabled(async () => {\n if (!mounted && disableAnimationOnInit) {\n themeState.setTheme(theme)\n return\n }\n\n await themeState.switchTheme(theme, animationOff)\n })\n },\n [disableAnimationOnInit, mounted, themeState, withTransitionsDisabled]\n )\n\n const switchThemeFromElement = useCallback(\n async (theme: Theme, element: HTMLButtonElement) => {\n await withTransitionsDisabled(async () => {\n if (!mounted && disableAnimationOnInit) {\n themeState.setTheme(theme)\n return\n }\n\n await withElementAsRef(themeState.ref, element, async () => {\n await themeState.switchTheme(theme)\n })\n })\n },\n [disableAnimationOnInit, mounted, themeState, withTransitionsDisabled]\n )\n\n const contextValue = useMemo<NextThemeContextType>(\n () => ({\n ref: themeState.ref,\n theme: themeState.theme,\n colorTheme: themeState.colorTheme,\n resolvedTheme: themeState.resolvedTheme,\n systemTheme: themeState.systemTheme,\n setTheme,\n setColorTheme: themeState.setColorTheme,\n switchTheme,\n switchColorTheme: themeState.switchColorTheme,\n toggleTheme: async (animationOff = false) =>\n switchTheme(\n getNextResolvedTheme(themeState.resolvedTheme),\n animationOff\n ),\n toggleLightTheme: async (animationOff = false) => {\n if (themeState.resolvedTheme === 'light') return\n await switchTheme('light', animationOff)\n },\n toggleDarkTheme: async (animationOff = false) => {\n if (themeState.resolvedTheme === 'dark') return\n await switchTheme('dark', animationOff)\n },\n toggleColorTheme: themeState.toggleColorTheme,\n createColorThemeToggle: themeState.createColorThemeToggle,\n isColorThemeActive: themeState.isColorThemeActive,\n switchThemeFromElement,\n }),\n [setTheme, switchTheme, switchThemeFromElement, themeState]\n )\n\n return (\n <NextThemeContext.Provider value={contextValue}>\n <SharedThemeContext.Provider value={contextValue}>\n {!disablePreHydrationScript && !forcedTheme ? (\n <ThemePreHydrationScript\n attribute={attribute}\n colorStorageKey={colorStorageKey}\n colorThemePrefix={colorThemePrefix}\n defaultColorTheme={defaultColorTheme}\n defaultTheme={effectiveDefaultTheme}\n enableColorScheme={enableColorScheme}\n enableSystem={enableSystem}\n globalClassName={globalClassName}\n nonce={nonce}\n scriptProps={scriptProps}\n storageKey={storageKey}\n value={value}\n />\n ) : null}\n {children}\n </SharedThemeContext.Provider>\n </NextThemeContext.Provider>\n )\n}\n\nexport const ThemeProvider = NextThemeProvider\n\nexport const useNextTheme = (): NextThemeContextType => {\n const context = useContext(NextThemeContext)\n if (context === undefined) {\n throw new Error('useNextTheme must be used within a NextThemeProvider')\n }\n return context\n}\n\nexport const useTheme = useNextTheme\n","import { useEffect } from 'react'\nimport { ColorTheme, Theme } from '../../core/types'\n\nconst isBrowser = typeof window !== 'undefined'\n\nexport const useSyncServerThemeStorage = ({\n enabled,\n theme,\n colorTheme,\n storageKey,\n colorStorageKey,\n}: {\n enabled: boolean\n theme?: Theme\n colorTheme?: ColorTheme\n storageKey: string\n colorStorageKey: string\n}): void => {\n useEffect(() => {\n if (!enabled || !isBrowser) return\n\n if (theme) {\n localStorage.setItem(storageKey, theme)\n }\n if (colorTheme) {\n localStorage.setItem(colorStorageKey, colorTheme)\n }\n }, [enabled, theme, colorTheme, storageKey, colorStorageKey])\n}\n","import { resolveThemeForServer } from '../core/utils/animations'\nimport { ColorTheme, Theme } from '../core/types'\n\nexport const STORAGE_KEY = 'theme'\nexport const COLOR_STORAGE_KEY = 'color-theme'\nexport const GLOBAL_CLASS_NAME = 'dark'\nexport const COLOR_THEME_PREFIX = 'theme-'\n\nexport type ServerResolvedTheme = 'light' | 'dark' | 'system'\n\nexport interface ServerThemeData {\n theme: ServerResolvedTheme\n themePreference: Theme\n colorTheme: ColorTheme\n}\n\nexport function buildServerThemeData(\n themeCookie: string | undefined,\n colorThemeCookie: string | undefined,\n options: { defaultTheme?: Theme; defaultColorTheme?: ColorTheme } = {}\n): ServerThemeData {\n const { defaultTheme = 'system', defaultColorTheme = 'default' } = options\n const themePreference = (themeCookie as Theme | undefined) ?? defaultTheme\n const colorTheme = colorThemeCookie ?? defaultColorTheme\n\n return {\n theme: resolveThemeForServer(themePreference),\n themePreference,\n colorTheme,\n }\n}\n\nexport { resolveThemeForServer }\n","import React, {\n createContext,\n ReactNode,\n useCallback,\n useContext,\n useSyncExternalStore,\n} from 'react'\nimport { useThemeAnimation } from '../hooks/use-theme-animation'\nimport { useSyncServerThemeStorage } from '../hooks/use-sync-server-theme-storage'\nimport {\n ColorTheme,\n SystemThemeMode,\n Theme,\n ThemeAnimationType,\n} from '../../core/types'\nimport {\n COLOR_STORAGE_KEY,\n COLOR_THEME_PREFIX,\n GLOBAL_CLASS_NAME,\n STORAGE_KEY,\n} from '../../tanstack/helpers'\nimport { SharedThemeContext } from './shared-theme-context'\nimport {\n getBrowserSystemTheme,\n getNextResolvedTheme,\n withElementAsRef,\n} from './provider-helpers'\n\nexport interface TanStackThemeContextType {\n ref: React.RefObject<HTMLButtonElement | null>\n theme: Theme\n colorTheme: ColorTheme\n resolvedTheme: 'light' | 'dark'\n systemTheme: 'light' | 'dark'\n isHydrated: boolean\n setTheme: (theme: Theme) => void\n setColorTheme: (colorTheme: ColorTheme) => void\n\n switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>\n switchColorTheme: (colorTheme: string) => void\n\n toggleTheme: (animationOff?: boolean) => Promise<void>\n toggleLightTheme: (animationOff?: boolean) => Promise<void>\n toggleDarkTheme: (animationOff?: boolean) => Promise<void>\n toggleColorTheme: () => void\n\n createColorThemeToggle: (targetColorTheme: string) => () => void\n isColorThemeActive: (targetColorTheme: string) => boolean\n\n switchThemeFromElement: (\n theme: Theme,\n element: HTMLButtonElement\n ) => Promise<void>\n}\n\nconst TanStackThemeContext = createContext<\n TanStackThemeContextType | undefined\n>(undefined)\n\nexport interface TanStackThemeProviderProps {\n children: ReactNode\n themes?: Theme[]\n colorThemes?: ColorTheme[]\n defaultTheme?: Theme\n defaultColorTheme?: ColorTheme\n animationType?: ThemeAnimationType\n duration?: number\n storageKey?: string\n colorStorageKey?: string\n globalClassName?: string\n colorThemePrefix?: string\n serverTheme?: 'light' | 'dark' | 'system'\n serverColorTheme?: ColorTheme\n systemThemeMode?: SystemThemeMode\n onServerThemeChange?: (theme: Theme) => Promise<void> | void\n onServerColorThemeChange?: (colorTheme: ColorTheme) => Promise<void> | void\n}\n\nexport interface TanStackStartThemeScriptProps {\n storageKey?: string\n colorStorageKey?: string\n defaultTheme?: Theme\n defaultColorTheme?: ColorTheme\n globalClassName?: string\n colorThemePrefix?: string\n nonce?: string\n systemThemeMode?: SystemThemeMode\n}\n\nconst generateTanStackPreHydrationScript = (\n storageKey: string,\n colorStorageKey: string,\n defaultTheme: Theme,\n defaultColorTheme: ColorTheme,\n globalClassName: string,\n colorThemePrefix: string,\n systemThemeMode: SystemThemeMode\n): string => {\n return `\n(function() {\n try {\n var theme = localStorage.getItem('${storageKey}') || '${defaultTheme}';\n var colorTheme = localStorage.getItem('${colorStorageKey}') || '${defaultColorTheme}';\n var el = document.documentElement;\n var resolved;\n if (theme === 'system') {\n if ('${systemThemeMode}' === 'css') {\n el.classList.remove('${globalClassName}');\n el.classList.remove('auto');\n el.classList.remove('system');\n el.classList.add('system');\n el.style.colorScheme = '';\n } else {\n resolved = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n if (resolved === 'dark') {\n el.classList.add('${globalClassName}');\n } else {\n el.classList.remove('${globalClassName}');\n }\n el.classList.remove('system');\n el.classList.remove('auto');\n el.style.colorScheme = resolved;\n }\n } else {\n resolved = theme;\n el.classList.remove('system');\n el.classList.remove('auto');\n if (resolved === 'dark') {\n el.classList.add('${globalClassName}');\n } else {\n el.classList.remove('${globalClassName}');\n }\n el.style.colorScheme = resolved;\n }\n if (colorTheme && colorTheme !== 'default') {\n el.classList.add('${colorThemePrefix}' + colorTheme);\n }\n } catch (e) {\n console.warn('Theme pre-hydration script failed:', e);\n }\n})();\n`\n}\n\nexport const TanStackStartThemeScript: React.FC<TanStackStartThemeScriptProps> =\n React.memo(\n ({\n storageKey = STORAGE_KEY,\n colorStorageKey = COLOR_STORAGE_KEY,\n defaultTheme = 'system',\n defaultColorTheme = 'default',\n globalClassName = GLOBAL_CLASS_NAME,\n colorThemePrefix = COLOR_THEME_PREFIX,\n nonce,\n systemThemeMode = 'js',\n }) => {\n const scriptContent = generateTanStackPreHydrationScript(\n storageKey,\n colorStorageKey,\n defaultTheme,\n defaultColorTheme,\n globalClassName,\n colorThemePrefix,\n systemThemeMode\n )\n\n return (\n <script\n nonce={nonce}\n suppressHydrationWarning\n dangerouslySetInnerHTML={{ __html: scriptContent }}\n />\n )\n }\n )\n\nTanStackStartThemeScript.displayName = 'TanStackStartThemeScript'\n\nconst useHydrated = (): boolean => {\n return useSyncExternalStore(\n () => () => {},\n () => true,\n () => false\n )\n}\n\nconst getNextColorTheme = (\n colorThemes: ColorTheme[],\n currentColorTheme: ColorTheme\n): ColorTheme => {\n if (colorThemes.length === 0) return currentColorTheme\n const currentIndex = colorThemes.indexOf(currentColorTheme)\n const nextIndex =\n currentIndex === -1 ? 0 : (currentIndex + 1) % colorThemes.length\n return colorThemes[nextIndex]\n}\n\nexport const TanStackThemeProvider: React.FC<TanStackThemeProviderProps> = ({\n children,\n themes = ['light', 'dark', 'system'],\n colorThemes = ['default'],\n defaultTheme = 'system',\n defaultColorTheme = 'default',\n animationType = ThemeAnimationType.CIRCLE,\n duration = 750,\n storageKey = STORAGE_KEY,\n colorStorageKey = COLOR_STORAGE_KEY,\n globalClassName = GLOBAL_CLASS_NAME,\n colorThemePrefix = COLOR_THEME_PREFIX,\n serverTheme,\n serverColorTheme,\n systemThemeMode = 'css',\n onServerThemeChange,\n onServerColorThemeChange,\n}) => {\n const isHydrated = useHydrated()\n const hasServerTheme = serverTheme !== undefined\n const initialTheme = hasServerTheme ? serverTheme : undefined\n\n const themeState = useThemeAnimation({\n themes,\n colorThemes,\n defaultTheme,\n defaultColorTheme,\n animationType,\n duration,\n storageKey,\n colorStorageKey,\n globalClassName,\n colorThemePrefix,\n initialTheme,\n initialColorTheme: serverColorTheme,\n systemThemeMode,\n })\n\n useSyncServerThemeStorage({\n enabled: hasServerTheme,\n theme: initialTheme,\n colorTheme: serverColorTheme,\n storageKey,\n colorStorageKey,\n })\n\n const setThemeWithServer = useCallback(\n (newTheme: Theme) => {\n themeState.setTheme(newTheme)\n onServerThemeChange?.(newTheme)\n },\n [themeState, onServerThemeChange]\n )\n\n const setColorThemeWithServer = useCallback(\n (newColorTheme: ColorTheme) => {\n themeState.setColorTheme(newColorTheme)\n onServerColorThemeChange?.(newColorTheme)\n },\n [themeState, onServerColorThemeChange]\n )\n\n const switchThemeWithHydrationAwareness = useCallback(\n async (theme: Theme, animationOff: boolean = false) => {\n if (!isHydrated) {\n setThemeWithServer(theme)\n return\n }\n\n await themeState.switchTheme(theme, animationOff)\n onServerThemeChange?.(theme)\n },\n [isHydrated, themeState, setThemeWithServer, onServerThemeChange]\n )\n\n const toggleThemeWithHydrationAwareness = useCallback(\n async (animationOff: boolean = false) => {\n const nextTheme = getNextResolvedTheme(themeState.resolvedTheme)\n\n if (!isHydrated) {\n setThemeWithServer(nextTheme)\n return\n }\n\n await themeState.toggleTheme(animationOff)\n onServerThemeChange?.(nextTheme)\n },\n [isHydrated, themeState, setThemeWithServer, onServerThemeChange]\n )\n\n const toggleLightThemeWithHydrationAwareness = useCallback(\n async (animationOff: boolean = false) => {\n if (!isHydrated) {\n setThemeWithServer('light')\n return\n }\n\n await themeState.toggleLightTheme(animationOff)\n onServerThemeChange?.('light')\n },\n [isHydrated, themeState, setThemeWithServer, onServerThemeChange]\n )\n\n const toggleDarkThemeWithHydrationAwareness = useCallback(\n async (animationOff: boolean = false) => {\n if (!isHydrated) {\n setThemeWithServer('dark')\n return\n }\n\n await themeState.toggleDarkTheme(animationOff)\n onServerThemeChange?.('dark')\n },\n [isHydrated, themeState, setThemeWithServer, onServerThemeChange]\n )\n\n const switchColorThemeWithServer = useCallback(\n (newColorTheme: ColorTheme) => {\n themeState.switchColorTheme(newColorTheme)\n onServerColorThemeChange?.(newColorTheme)\n },\n [themeState, onServerColorThemeChange]\n )\n\n const toggleColorThemeWithServer = useCallback(() => {\n const nextColorTheme = getNextColorTheme(colorThemes, themeState.colorTheme)\n themeState.toggleColorTheme()\n onServerColorThemeChange?.(nextColorTheme)\n }, [colorThemes, themeState, onServerColorThemeChange])\n\n const createColorThemeToggleWithServer = useCallback(\n (targetColorTheme: ColorTheme) => () => {\n themeState.createColorThemeToggle(targetColorTheme)()\n onServerColorThemeChange?.(targetColorTheme)\n },\n [themeState, onServerColorThemeChange]\n )\n\n const switchThemeFromElement = useCallback(\n async (theme: Theme, element: HTMLButtonElement) => {\n if (!isHydrated) {\n setThemeWithServer(theme)\n return\n }\n\n await withElementAsRef(themeState.ref, element, async () => {\n await themeState.switchTheme(theme)\n })\n\n onServerThemeChange?.(theme)\n },\n [isHydrated, themeState, setThemeWithServer, onServerThemeChange]\n )\n\n const systemTheme = getBrowserSystemTheme()\n\n const serverResolvedTheme: 'light' | 'dark' = (() => {\n if (hasServerTheme) {\n if (serverTheme === 'dark') return 'dark'\n if (serverTheme === 'system') return systemTheme\n return 'light'\n }\n return defaultTheme === 'dark' ? 'dark' : 'light'\n })()\n\n if (!isHydrated) {\n const loadingContextValue: TanStackThemeContextType = {\n ref: { current: null },\n theme: initialTheme ?? defaultTheme,\n colorTheme: serverColorTheme ?? defaultColorTheme,\n resolvedTheme: serverResolvedTheme,\n systemTheme: 'light',\n isHydrated: false,\n setTheme: setThemeWithServer,\n setColorTheme: setColorThemeWithServer,\n switchTheme: async (theme: Theme) => setThemeWithServer(theme),\n switchThemeFromElement: async (theme: Theme) => setThemeWithServer(theme),\n switchColorTheme: switchColorThemeWithServer,\n toggleTheme: async () => {\n const nextTheme = serverResolvedTheme === 'dark' ? 'light' : 'dark'\n setThemeWithServer(nextTheme)\n },\n toggleLightTheme: async () => setThemeWithServer('light'),\n toggleDarkTheme: async () => setThemeWithServer('dark'),\n toggleColorTheme: toggleColorThemeWithServer,\n createColorThemeToggle: createColorThemeToggleWithServer,\n isColorThemeActive: themeState.isColorThemeActive,\n }\n\n return (\n <TanStackThemeContext.Provider value={loadingContextValue}>\n <SharedThemeContext.Provider value={loadingContextValue}>\n {children}\n </SharedThemeContext.Provider>\n </TanStackThemeContext.Provider>\n )\n }\n\n const contextValue: TanStackThemeContextType = {\n ref: themeState.ref,\n theme: themeState.theme,\n colorTheme: themeState.colorTheme,\n resolvedTheme: themeState.resolvedTheme,\n systemTheme,\n isHydrated: true,\n setTheme: setThemeWithServer,\n setColorTheme: setColorThemeWithServer,\n switchTheme: switchThemeWithHydrationAwareness,\n switchThemeFromElement,\n switchColorTheme: switchColorThemeWithServer,\n toggleTheme: toggleThemeWithHydrationAwareness,\n toggleLightTheme: toggleLightThemeWithHydrationAwareness,\n toggleDarkTheme: toggleDarkThemeWithHydrationAwareness,\n toggleColorTheme: toggleColorThemeWithServer,\n createColorThemeToggle: createColorThemeToggleWithServer,\n isColorThemeActive: themeState.isColorThemeActive,\n }\n\n return (\n <TanStackThemeContext.Provider value={contextValue}>\n <SharedThemeContext.Provider value={contextValue}>\n {children}\n </SharedThemeContext.Provider>\n </TanStackThemeContext.Provider>\n )\n}\n\nexport const useTanStackTheme = (): TanStackThemeContextType => {\n const context = useContext(TanStackThemeContext)\n if (context === undefined) {\n throw new Error(\n 'useTanStackTheme must be used within a TanStackThemeProvider'\n )\n }\n return context\n}\n","import React, { createContext, useContext, ReactNode, useCallback } from 'react'\nimport { useThemeAnimation } from '../hooks/use-theme-animation'\nimport { Theme, ColorTheme, ThemeAnimationType } from '../../core/types'\nimport { SharedThemeContext } from './shared-theme-context'\nimport { getBrowserSystemTheme, withElementAsRef } from './provider-helpers'\n\ninterface ViteThemeContextType {\n ref: React.RefObject<HTMLButtonElement | null>\n theme: Theme\n colorTheme: ColorTheme\n resolvedTheme: 'light' | 'dark'\n systemTheme: 'light' | 'dark'\n setTheme: (theme: Theme) => void\n setColorTheme: (colorTheme: ColorTheme) => void\n switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>\n switchColorTheme: (colorTheme: string) => void\n toggleTheme: (animationOff?: boolean) => Promise<void>\n toggleLightTheme: (animationOff?: boolean) => Promise<void>\n toggleDarkTheme: (animationOff?: boolean) => Promise<void>\n toggleColorTheme: () => void\n createColorThemeToggle: (targetColorTheme: string) => () => void\n isColorThemeActive: (targetColorTheme: string) => boolean\n switchThemeFromElement: (\n theme: Theme,\n element: HTMLButtonElement\n ) => Promise<void>\n}\n\nconst ViteThemeContext = createContext<ViteThemeContextType | undefined>(\n undefined\n)\n\ninterface ViteThemeProviderProps {\n children: ReactNode\n themes?: Theme[]\n colorThemes?: ColorTheme[]\n defaultTheme?: Theme\n defaultColorTheme?: ColorTheme\n animationType?: ThemeAnimationType\n duration?: number\n attribute?: 'class' | 'data-theme'\n disableTransitionOnChange?: boolean\n storageKey?: string\n colorStorageKey?: string\n globalClassName?: string\n colorThemePrefix?: string\n}\n\n/**\n * Vite Theme Provider - Optimized for Vite SPA applications\n *\n * This provider is designed for Vite-based single-page applications with optional\n * transition disabling to prevent flash during theme switches.\n *\n * Note: For flash prevention on initial load, add a script to your index.html\n * or inject it via Vite plugin to apply theme before React loads.\n *\n * @param children - React children to wrap with theme context\n * @param themes - Available theme options\n * @param colorThemes - Available color theme options\n * @param defaultTheme - Default theme to use\n * @param defaultColorTheme - Default color theme to use\n * @param animationType - Animation type for theme transitions\n * @param duration - Animation duration in milliseconds\n * @param attribute - HTML attribute to use for theme ('class' or 'data-theme')\n * @param disableTransitionOnChange - Temporarily disable CSS transitions during theme switch\n * @param storageKey - LocalStorage key for theme preference\n * @param colorStorageKey - LocalStorage key for color theme preference\n * @param globalClassName - Class name for dark theme (when using 'class' attribute)\n * @param colorThemePrefix - Prefix for color theme classes\n */\nexport const ViteThemeProvider: React.FC<ViteThemeProviderProps> = ({\n children,\n themes = ['light', 'dark', 'system'],\n colorThemes = ['default'],\n defaultTheme = 'system',\n defaultColorTheme = 'default',\n animationType = ThemeAnimationType.CIRCLE,\n duration = 750,\n attribute = 'class',\n disableTransitionOnChange = false,\n storageKey = 'vite-theme',\n colorStorageKey = 'vite-color-theme',\n globalClassName = 'dark',\n colorThemePrefix = 'theme-',\n}) => {\n const themeState = useThemeAnimation({\n themes,\n colorThemes,\n defaultTheme,\n defaultColorTheme,\n animationType,\n duration,\n storageKey,\n colorStorageKey,\n globalClassName: attribute === 'class' ? globalClassName : undefined,\n colorThemePrefix,\n })\n\n const applyTransitionDisable = useCallback(() => {\n if (!disableTransitionOnChange) return () => {}\n\n const css = document.createElement('style')\n css.textContent = `*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`\n document.head.appendChild(css)\n\n window.getComputedStyle(document.body)\n\n return () => {\n setTimeout(() => {\n document.head.removeChild(css)\n }, 1)\n }\n }, [disableTransitionOnChange])\n\n const wrappedSetTheme = useCallback(\n (theme: Theme) => {\n const cleanup = applyTransitionDisable()\n themeState.setTheme(theme)\n cleanup()\n },\n [themeState.setTheme, applyTransitionDisable]\n )\n\n const wrappedSwitchTheme = useCallback(\n async (theme: Theme, animationOff: boolean = false) => {\n const cleanup = applyTransitionDisable()\n await themeState.switchTheme(theme, animationOff)\n cleanup()\n },\n [themeState.switchTheme, applyTransitionDisable]\n )\n\n const wrappedToggleTheme = useCallback(\n async (animationOff: boolean = false) => {\n const cleanup = applyTransitionDisable()\n await themeState.toggleTheme(animationOff)\n cleanup()\n },\n [themeState.toggleTheme, applyTransitionDisable]\n )\n\n const wrappedToggleLightTheme = useCallback(\n async (animationOff: boolean = false) => {\n const cleanup = applyTransitionDisable()\n await themeState.toggleLightTheme(animationOff)\n cleanup()\n },\n [themeState.toggleLightTheme, applyTransitionDisable]\n )\n\n const wrappedToggleDarkTheme = useCallback(\n async (animationOff: boolean = false) => {\n const cleanup = applyTransitionDisable()\n await themeState.toggleDarkTheme(animationOff)\n cleanup()\n },\n [themeState.toggleDarkTheme, applyTransitionDisable]\n )\n\n const switchThemeFromElement = async (\n theme: Theme,\n element: HTMLButtonElement\n ) => {\n const cleanup = applyTransitionDisable()\n await withElementAsRef(themeState.ref, element, async () => {\n await themeState.switchTheme(theme)\n })\n cleanup()\n }\n\n const systemTheme = getBrowserSystemTheme()\n\n const contextValue: ViteThemeContextType = {\n ref: themeState.ref,\n theme: themeState.theme,\n colorTheme: themeState.colorTheme,\n resolvedTheme: themeState.resolvedTheme,\n systemTheme,\n setTheme: wrappedSetTheme,\n setColorTheme: themeState.setColorTheme,\n switchTheme: wrappedSwitchTheme,\n switchThemeFromElement,\n switchColorTheme: themeState.switchColorTheme,\n toggleTheme: wrappedToggleTheme,\n toggleLightTheme: wrappedToggleLightTheme,\n toggleDarkTheme: wrappedToggleDarkTheme,\n toggleColorTheme: themeState.toggleColorTheme,\n createColorThemeToggle: themeState.createColorThemeToggle,\n isColorThemeActive: themeState.isColorThemeActive,\n }\n\n return (\n <ViteThemeContext.Provider value={contextValue}>\n <SharedThemeContext.Provider value={contextValue}>\n {children}\n </SharedThemeContext.Provider>\n </ViteThemeContext.Provider>\n )\n}\n\nexport const useViteTheme = (): ViteThemeContextType => {\n const context = useContext(ViteThemeContext)\n if (context === undefined) {\n throw new Error('useViteTheme must be used within a ViteThemeProvider')\n }\n return context\n}\n"]}