uitheme-web 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/types.ts","../../src/core/constants.ts","../../src/core/animations.ts","../../src/core/storage.ts"],"names":["ThemeAnimationType","isBrowser"],"mappings":";AAAO,IAAK,kBAAA,qBAAAA,mBAAAA,KAAL;AACL,EAAAA,oBAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,oBAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,oBAAA,OAAA,CAAA,GAAQ,OAAA;AAHE,EAAA,OAAAA,mBAAAA;AAAA,CAAA,EAAA,kBAAA,IAAA,EAAA;;;ACAL,IAAM,WAAA,GAAc;AACpB,IAAM,iBAAA,GAAoB;AAC1B,IAAM,iBAAA,GAAoB;AAC1B,IAAM,kBAAA,GAAqB;AAC3B,IAAM,gBAAA,GAAmB;AACzB,IAAM,cAAA,GAAiB;AACvB,IAAM,mBAAA,GAAsB;AAC5B,IAAM,gBAAA,GAAmB;;;ACJhC,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA;AAKpC,IAAM,sBAAsB,MAAe;AACzC,EAAA,IAAI,CAAC,WAAW,OAAO,KAAA;AACvB,EAAA,OAAO,MAAA,CAAO,UAAA,IAAc,GAAA,IAAQ,MAAA,CAAO,WAAA,IAAe,GAAA;AAC5D,CAAA;AAKO,IAAM,mBAAmB,MAAY;AAC1C,EAAA,IAAI,CAAC,SAAA,EAAW;AAEhB,EAAA,MAAM,OAAA,GAAU,qBAAA;AAChB,EAAA,IAAI,QAAA,CAAS,cAAA,CAAe,OAAO,CAAA,EAAG;AAEtC,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,aAAA,CAAc,OAAO,CAAA;AAC5C,EAAA,KAAA,CAAM,EAAA,GAAK,OAAA;AACX,EAAA,MAAM,mBAAmB,mBAAA,EAAoB;AAE7C,EAAA,KAAA,C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= 'slide',\n}\n\nexport type Theme = 'light' | 'dark' | 'system';\nexport type ColorTheme = string;\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 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 interface ThemeConfig {\n themes?: Theme[];\n colorThemes?: ColorTheme[];\n defaultTheme?: Theme;\n defaultColorTheme?: ColorTheme;\n globalClassName?: string;\n colorThemePrefix?: string;\n storageKey?: string;\n colorStorageKey?: string;\n}\n\nexport interface ThemeState {\n theme: Theme;\n colorTheme: ColorTheme;\n resolvedTheme: 'light' | 'dark';\n}\n","export const STORAGE_KEY = 'theme';\nexport const COLOR_STORAGE_KEY = 'color-theme';\nexport const GLOBAL_CLASS_NAME = 'dark';\nexport const COLOR_THEME_PREFIX = 'theme-';\nexport const DEFAULT_DURATION = 750;\nexport const DEFAULT_EASING = 'ease-in-out';\nexport const DEFAULT_BLUR_AMOUNT = 2;\nexport const DEFAULT_STYLE_ID = 'ui-theme-style';\n","import { AnimationConfig, SlideDirection } from './types';\nimport { DEFAULT_STYLE_ID } from './constants';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Checks if the current display is high resolution\n */\nconst getIsHighResolution = (): boolean => {\n if (!isBrowser) return false;\n return window.innerWidth >= 3000 || window.innerHeight >= 2000;\n};\n\n/**\n * Injects base styles required for view transitions\n */\nexport const injectBaseStyles = (): void => {\n if (!isBrowser) return;\n\n const styleId = 'ui-theme-base-style';\n if (document.getElementById(styleId)) return;\n\n const style = document.createElement('style');\n style.id = styleId;\n const isHighResolution = getIsHighResolution();\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 * Creates an SVG blur circle mask for animations\n * @param blur - Blur amount for the gaussian filter\n * @returns Data URI string for the SVG mask\n */\nexport const createBlurCircleMask = (blur: number): string => {\n const isHighResolution = getIsHighResolution();\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\n/**\n * Gets the system theme preference\n * @returns 'light' or 'dark' based on system preference\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\n/**\n * Resolves a theme value to its actual light/dark value\n * @param theme - Theme to resolve ('light', 'dark', or 'system')\n * @returns Resolved theme ('light' or 'dark')\n */\nexport const resolveTheme = (theme: string): 'light' | 'dark' => {\n if (theme === 'system') {\n return getSystemTheme();\n }\n return theme === 'dark' ? 'dark' : 'light';\n};\n\n/**\n * Resolves a stored theme to the server-side class to apply on <html>.\n * CSS mode uses the 'system' class so media queries can respond before hydration.\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\n/**\n * Checks if the browser supports View Transitions API\n * @returns true if view transitions are supported\n */\nexport const supportsViewTransitions = (): boolean => {\n return isBrowser && 'startViewTransition' in document;\n};\n\n/**\n * Checks if user prefers reduced motion\n * @returns true if user prefers reduced motion\n */\nexport const prefersReducedMotion = (): boolean => {\n return (\n isBrowser && window.matchMedia('(prefers-reduced-motion: reduce)').matches\n );\n};\n\n/**\n * Converts a slide direction to from coordinates\n * @param direction - Slide direction\n * @returns Object with a (x) and b (y) coordinates\n */\nexport const getSlideFromCoords = (\n direction: SlideDirection\n): { a: number; b: number } => {\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/**\n * Creates a circle expanding animation for theme transitions\n * @param config - Animation configuration\n */\nexport const createCircleAnimation = (config: AnimationConfig): void => {\n const { x, y, duration, easing } = config;\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 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\n/**\n * Creates a slide animation for theme transitions\n * @param config - Animation configuration\n */\nexport const createSlideAnimation = (config: AnimationConfig): void => {\n const {\n a = -100,\n b = 0,\n x = 0,\n y = 0,\n duration,\n styleId = DEFAULT_STYLE_ID,\n } = 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 setTimeout(() => {\n const el = document.getElementById(styleId);\n if (el) {\n el.remove();\n }\n }, duration);\n};\n\n/**\n * Creates a blur circle animation for theme transitions\n * @param config - Animation configuration\n */\nexport const createBlurCircleAnimation = (config: AnimationConfig): void => {\n const {\n x,\n y,\n duration,\n easing,\n blurAmount,\n styleId = DEFAULT_STYLE_ID,\n } = config;\n\n const existingStyle = document.getElementById(styleId);\n if (existingStyle) {\n existingStyle.remove();\n }\n\n const isHighResolution = getIsHighResolution();\n const viewportSize = Math.max(window.innerWidth, window.innerHeight) + 200;\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: ui-theme-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: ui-theme-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 ui-theme-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 el = document.getElementById(styleId);\n if (el) {\n el.remove();\n }\n }, duration);\n};\n","import { Theme, ColorTheme } from './types';\nimport { STORAGE_KEY, COLOR_STORAGE_KEY } from './constants';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Gets the stored theme from localStorage\n * @param key - Storage key for the theme\n * @param validThemes - Array of valid theme values\n * @param defaultTheme - Default theme if stored value is invalid\n * @returns The stored theme or default\n */\nexport const getStoredTheme = (\n key: string = STORAGE_KEY,\n validThemes: Theme[] = ['light', 'dark', 'system'],\n defaultTheme: Theme = 'system'\n): Theme => {\n if (!isBrowser) return defaultTheme;\n\n const saved = localStorage.getItem(key) as Theme | null;\n return saved && validThemes.includes(saved) ? saved : defaultTheme;\n};\n\n/**\n * Stores theme in localStorage\n * @param theme - Theme to store\n * @param key - Storage key for the theme\n */\nexport const setStoredTheme = (\n theme: Theme,\n key: string = STORAGE_KEY\n): void => {\n if (!isBrowser) return;\n localStorage.setItem(key, theme);\n};\n\n/**\n * Gets the stored color theme from localStorage\n * @param key - Storage key for the color theme\n * @param validColorThemes - Array of valid color theme values\n * @param defaultColorTheme - Default color theme if stored value is invalid\n * @returns The stored color theme or default\n */\nexport const getStoredColorTheme = (\n key: string = COLOR_STORAGE_KEY,\n validColorThemes: ColorTheme[] = ['default'],\n defaultColorTheme: ColorTheme = 'default'\n): ColorTheme => {\n if (!isBrowser) return defaultColorTheme;\n\n const saved = localStorage.getItem(key);\n return saved && validColorThemes.includes(saved) ? saved : defaultColorTheme;\n};\n\n/**\n * Stores color theme in localStorage\n * @param colorTheme - Color theme to store\n * @param key - Storage key for the color theme\n */\nexport const setStoredColorTheme = (\n colorTheme: ColorTheme,\n key: string = COLOR_STORAGE_KEY\n): void => {\n if (!isBrowser) return;\n localStorage.setItem(key, colorTheme);\n};\n"]}