@space-man/react-theme-animation 2.1.0 → 3.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 +115 -164
- package/dist/animations-CaaRrn3-.d.ts +208 -0
- package/dist/chunk-FNL7ZHF4.js +44 -0
- package/dist/chunk-I3T2QXRT.js +18 -0
- package/dist/chunk-QYUMCBTQ.js +1 -0
- package/dist/chunk-X6UEG7WG.js +12 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.js +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -0
- package/dist/logo-DtwtRv4y.d.ts +4 -0
- package/dist/react/index.d.ts +228 -0
- package/dist/react/index.js +2 -0
- package/dist/tanstack/index.d.ts +20 -0
- package/dist/tanstack/index.js +1 -0
- package/package.json +82 -63
- package/dist/cjs/components/NextThemeProvider.d.ts +0 -81
- package/dist/cjs/components/NextThemeProvider.js +0 -223
- package/dist/cjs/components/SpacemanThemeProvider.d.ts +0 -57
- package/dist/cjs/components/SpacemanThemeProvider.js +0 -113
- package/dist/cjs/components/TanStackThemeProvider.d.ts +0 -68
- package/dist/cjs/components/TanStackThemeProvider.js +0 -183
- package/dist/cjs/components/ThemeSelector.d.ts +0 -3
- package/dist/cjs/components/ThemeSelector.js +0 -39
- package/dist/cjs/components/ThemeSwitcher.d.ts +0 -3
- package/dist/cjs/components/ThemeSwitcher.js +0 -81
- package/dist/cjs/components/ViteThemeProvider.d.ts +0 -61
- package/dist/cjs/components/ViteThemeProvider.js +0 -140
- package/dist/cjs/components/ui/select.d.ts +0 -15
- package/dist/cjs/components/ui/select.js +0 -83
- package/dist/cjs/hooks/use-theme-animation.d.ts +0 -2
- package/dist/cjs/hooks/use-theme-animation.js +0 -234
- package/dist/cjs/index.d.ts +0 -10
- package/dist/cjs/index.js +0 -30
- package/dist/cjs/types/index.d.ts +0 -78
- package/dist/cjs/types/index.js +0 -9
- package/dist/cjs/utils/animations.d.ts +0 -21
- package/dist/cjs/utils/animations.js +0 -189
- package/dist/esm/components/NextThemeProvider.d.ts +0 -81
- package/dist/esm/components/NextThemeProvider.js +0 -185
- package/dist/esm/components/SpacemanThemeProvider.d.ts +0 -57
- package/dist/esm/components/SpacemanThemeProvider.js +0 -108
- package/dist/esm/components/TanStackThemeProvider.d.ts +0 -68
- package/dist/esm/components/TanStackThemeProvider.js +0 -178
- package/dist/esm/components/ThemeSelector.d.ts +0 -3
- package/dist/esm/components/ThemeSelector.js +0 -35
- package/dist/esm/components/ThemeSwitcher.d.ts +0 -3
- package/dist/esm/components/ThemeSwitcher.js +0 -77
- package/dist/esm/components/ViteThemeProvider.d.ts +0 -61
- package/dist/esm/components/ViteThemeProvider.js +0 -135
- package/dist/esm/components/ui/select.d.ts +0 -15
- package/dist/esm/components/ui/select.js +0 -39
- package/dist/esm/hooks/use-theme-animation.d.ts +0 -2
- package/dist/esm/hooks/use-theme-animation.js +0 -230
- package/dist/esm/index.d.ts +0 -10
- package/dist/esm/index.js +0 -10
- package/dist/esm/types/index.d.ts +0 -78
- package/dist/esm/types/index.js +0 -6
- package/dist/esm/utils/animations.d.ts +0 -21
- package/dist/esm/utils/animations.js +0 -177
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var x=typeof window<"u",k=()=>{if(!x||document.getElementById("spaceman-theme-base-style"))return;let t=document.createElement("style");t.id="spaceman-theme-base-style",t.textContent=`
|
|
2
|
+
html[data-spaceman-theme-transition]::view-transition-group(root),
|
|
3
|
+
html[data-spaceman-theme-transition]::view-transition-old(root),
|
|
4
|
+
html[data-spaceman-theme-transition]::view-transition-new(root) {
|
|
5
|
+
animation: none;
|
|
6
|
+
}
|
|
7
|
+
html[data-spaceman-theme-transition]::view-transition-old(root),
|
|
8
|
+
html[data-spaceman-theme-transition]::view-transition-new(root) {
|
|
9
|
+
mix-blend-mode: normal;
|
|
10
|
+
}
|
|
11
|
+
html[data-spaceman-theme-transition],
|
|
12
|
+
html[data-spaceman-theme-transition] *,
|
|
13
|
+
html[data-spaceman-theme-transition] *::before,
|
|
14
|
+
html[data-spaceman-theme-transition] *::after {
|
|
15
|
+
transition: none !important;
|
|
16
|
+
}
|
|
17
|
+
`,document.head.appendChild(t);};var C=()=>x&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",M=t=>t==="system"?C():t==="dark"?"dark":"light",P=t=>t==="system"?"system":t==="dark"?"dark":"light",R=()=>x&&document.startViewTransition instanceof Function,T=()=>x&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,E=t=>{switch(t){case "left":return {a:-100,b:0};case "right":return {a:100,b:0};case "top":return {a:0,b:-100};case "bottom":return {a:0,b:100};case "top-left":return {a:-100,b:-100};case "top-right":return {a:100,b:-100};case "bottom-left":return {a:-100,b:100};case "bottom-right":return {a:100,b:100};default:return {a:-100,b:0}}},$=()=>{let t=getComputedStyle(document.documentElement,"::view-transition-new(root)"),n=Math.max(window.innerWidth,parseFloat(t.width)||0),e=Math.max(window.innerHeight,parseFloat(t.height)||0);return {width:n,height:e}},w=(t,n)=>{let{width:e,height:o}=$();return Math.hypot(Math.max(Math.abs(t),Math.abs(e-t)),Math.max(Math.abs(n),Math.abs(o-n)))+1},B=t=>{let n=t.includes("left")?0:t.includes("right")?window.innerWidth:window.innerWidth/2,e=t.includes("top")?0:t.includes("bottom")?window.innerHeight:window.innerHeight/2;return {x:n,y:e}},S=0,u=(t,n)=>{let e=document.documentElement.animate(n,{duration:t.duration,easing:t.easing,fill:"both",pseudoElement:"::view-transition-new(root)"}),o=e.effect;if(!(o instanceof KeyframeEffect))return e;let i=o.getKeyframes(),d=i.some(m=>"clipPath"in m)?"clipPath":i.some(m=>"maskImage"in m)?"maskImage":"transform";if(getComputedStyle(document.documentElement,"::view-transition-new(root)")[d]!=="none")return e;let c=e.playState==="paused",s=e.currentTime;e.cancel(),e.finished.catch(()=>{});let r=`spaceman-theme-reveal-${++S}`,a=document.createElement("style"),l=i.map(m=>{let y=Object.entries(m).filter(([h])=>!["offset","computedOffset","easing","composite"].includes(h)).map(([h,v])=>`${h.replace(/[A-Z]/g,A=>`-${A.toLowerCase()}`)}:${v};`).join("");return `${m.computedOffset*100}%{${y}}`}).join("");a.textContent=`@keyframes ${r}{${l}}html[data-spaceman-theme-transition]::view-transition-new(root){animation:${r} ${t.duration}ms ${t.easing} both;}`,document.head.appendChild(a);let f=getComputedStyle(document.documentElement,"::view-transition-new(root)").animationName,p=document.getAnimations().find(m=>m instanceof CSSAnimation&&m.animationName===f);if(!p)throw a.remove(),new Error("Transition pseudo animations are unavailable");return c&&(p.pause(),p.currentTime=s),p.finished.then(()=>{a.remove();},()=>{a.remove();}),p},I=t=>{let n=t.clipPathDirection??"top-left",e={"top-left":"polygon(-1% -1%, 101% -101%, -101% 101%, -1% -1%)",top:"polygon(-1% -1%, 101% -1%, 101% -1%, -1% -1%)","top-right":"polygon(101% -1%, 201% 101%, -1% -101%, 101% -1%)",right:"polygon(101% -1%, 101% 101%, 101% 101%, 101% -1%)","bottom-right":"polygon(101% 101%, -1% 201%, 201% -1%, 101% 101%)",bottom:"polygon(101% 101%, -1% 101%, -1% 101%, 101% 101%)","bottom-left":"polygon(-1% 101%, -101% -1%, 101% 201%, -1% 101%)",left:"polygon(-1% 101%, -1% -1%, -1% -1%, -1% 101%)"},o={"top-left":"polygon(-1% -1%, 201% -1%, -1% 201%, -1% -1%)",top:"polygon(-1% -1%, 101% -1%, 101% 101%, -1% 101%)","top-right":"polygon(101% -1%, 101% 201%, -101% -1%, 101% -1%)",right:"polygon(101% -1%, 101% 101%, -1% 101%, -1% -1%)","bottom-right":"polygon(101% 101%, -101% 101%, 101% -101%, 101% 101%)",bottom:"polygon(101% 101%, -1% 101%, -1% -1%, 101% -1%)","bottom-left":"polygon(-1% 101%, -1% -101%, 201% 101%, -1% 101%)",left:"polygon(-1% 101%, -1% -1%, 101% -1%, 101% 101%)"};return u(t,{clipPath:[e[n],o[n]]})},D=t=>{let n=t.clipPathDirection??"top-left",{width:e,height:o}=$(),i=n.includes("-"),d=n.includes("left"),g=n.includes("top"),c=n==="left"||n==="right",s=d?0:n.includes("right")?1:.5,r=g?0:n.includes("bottom")?1:.5,a=i||c?e*3:e,l=i||!c?o*3:o,f=i?`${s*100},${r*100} ${(1-s)*100},${r*100} ${s*100},${(1-r)*100}`:"0,0 100,0 100,100 0,100",p=i?a*l/Math.hypot(a,l):c?a:l,y=1-Math.max(0,Math.min(t.gradientWidth??80,p*.2))/p,h=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><defs><linearGradient id="edge" x1="${s*100}" y1="${r*100}" x2="${100*(i?.5:c?1-s:s)}" y2="${100*(i?.5:c?r:1-r)}" gradientUnits="userSpaceOnUse"><stop offset="${y}" stop-color="black"/><stop offset="1" stop-color="black" stop-opacity="0"/></linearGradient></defs><polygon points="${f}" fill="url(#edge)"/></svg>`;return u(t,{maskImage:[`url("data:image/svg+xml,${encodeURIComponent(h)}")`,`url("data:image/svg+xml,${encodeURIComponent(h)}")`],maskMode:["alpha","alpha"],maskRepeat:["no-repeat","no-repeat"],maskSize:[i?"0px 0px":c?`0px ${l}px`:`${a}px 0px`,`${a}px ${l}px`],maskPosition:[`${s*e}px ${r*o}px`,`${s*(e-a)}px ${r*(o-l)}px`]})},F=t=>{let{x:n,y:e}=t,o=w(n,e),i=Math.sqrt(3)*o;return u(t,{clipPath:[`polygon(${n}px ${e}px, ${n}px ${e}px, ${n}px ${e}px)`,`polygon(${n}px ${e-2*o}px, ${n+i}px ${e+o}px, ${n-i}px ${e+o}px)`]})},z=t=>{let{width:n,height:e}=$();return b({...t,x:n/2,y:e/2})},b=t=>{let{x:n,y:e}=t;return u(t,{clipPath:[`circle(0px at ${n}px ${e}px)`,`circle(${w(n,e)}px at ${n}px ${e}px)`]})},O=t=>{let{a:n=-100,b:e=0,x:o,y:i}=t;return u(t,{transform:[`translate(${n}%, ${e}%)`,`translate(${o}%, ${i}%)`]})},N=t=>{let{x:n,y:e,blurAmount:o}=t;if(o<=0)return b(t);let i=Math.min(o,20),d=w(n,e)+i,g=d*2;return u(t,{maskImage:[`radial-gradient(closest-side, #000 calc(100% - ${i}px), transparent 100%)`,`radial-gradient(closest-side, #000 calc(100% - ${i}px), transparent 100%)`],maskRepeat:["no-repeat","no-repeat"],maskSize:["0px 0px",`${g}px ${g}px`],maskPosition:[`${n}px ${e}px`,`${n-d}px ${e-d}px`]})};
|
|
18
|
+
export{k as a,C as b,M as c,P as d,R as e,T as f,E as g,B as h,I as i,D as j,F as k,z as l,b as m,O as n,N as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d as d$1}from'./chunk-I3T2QXRT.js';var a="theme",d="color-theme",s="dark",c="theme-";function f(e,o,m={}){let{defaultTheme:h="system",defaultColorTheme:l="default"}=m,r=e==="light"||e==="dark"||e==="system"?e:h,n=o??l;return {theme:d$1(r),themePreference:r,colorTheme:n}}export{a,d as b,s as c,c as d,f as e};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {e,f,a,n,o,i,j,k as k$1,l,m}from'./chunk-I3T2QXRT.js';var I=e=>{if(e.logoLight!==void 0||e.logoDark!==void 0){if(e.logoLight===void 0||e.logoLight===""||e.logoDark===void 0||e.logoDark==="")throw new Error("logoLight and logoDark must both be provided.");if(e.logo!==void 0)throw new Error("Use logo or the logoLight/logoDark pair, not both.");return {logoLight:e.logoLight,logoDark:e.logoDark}}return {logo:e.logo}},x=0,v=e=>{let o=w(e.logo);if(!o)return;let i=e.logoWidth!=="auto"&&e.logoWidth!==void 0&&Number.isFinite(e.logoWidth)&&e.logoWidth>0?e.logoWidth:void 0,t=e.logoHeight!=="auto"&&e.logoHeight!==void 0&&Number.isFinite(e.logoHeight)&&e.logoHeight>0?e.logoHeight:void 0,a=i??(t!==void 0?t*o.aspectRatio:e.logoWidth==="auto"||e.logoHeight==="auto"?o.naturalWidth:96),n=t??a/o.aspectRatio,l=`spaceman-theme-logo-${++x}`,r=document.createElement("img");r.src=o.image,r.alt="",r.setAttribute("aria-hidden","true"),r.setAttribute("data-spaceman-theme-logo",""),r.style.cssText=`position:fixed;left:calc(50% - ${a/2}px);top:calc(50% - ${n/2}px);width:${a}px;height:${n}px;max-width:none;max-height:none;object-fit:contain;display:block;margin:0;padding:0;border:0;transform:none;pointer-events:none;z-index:2147483647;view-transition-name:${l};`;let m=document.createElement("style");return m.setAttribute("data-spaceman-theme-logo-style",""),m.textContent=`
|
|
2
|
+
@keyframes ${l}-fade { 0%, 85% { opacity:1; } 100% { opacity:0; } }
|
|
3
|
+
html[data-spaceman-theme-transition]::view-transition-group(${l}) {
|
|
4
|
+
z-index:2;
|
|
5
|
+
animation:${l}-fade ${e.duration}ms linear both;
|
|
6
|
+
}
|
|
7
|
+
html[data-spaceman-theme-transition]::view-transition-old(${l}) { display:none; }
|
|
8
|
+
html[data-spaceman-theme-transition]::view-transition-new(${l}) {
|
|
9
|
+
animation:none; mix-blend-mode:normal;
|
|
10
|
+
}
|
|
11
|
+
`,document.head.appendChild(m),document.documentElement.appendChild(r),{element:r,style:m}},h=new Map,R=async e=>{if(typeof window>"u")return Promise.resolve();let o=h.get(e);if(o)return o.loading;let i={loading:Promise.resolve()};return h.set(e,i),i.loading=(async()=>{let t=new AbortController,a=setTimeout(()=>{t.abort();},2e3);try{let n=await fetch(e,{signal:t.signal});if(!n.ok)return;let l=await n.text(),r=new DOMParser().parseFromString(l,"image/svg+xml");if(r.querySelector("parsererror")||r.documentElement.localName!=="svg"||r.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")return;let m=`data:image/svg+xml,${encodeURIComponent(l)}`,d=new Image;d.src=m,await d.decode(),d.naturalWidth>0&&d.naturalHeight>0&&(i.ready={image:m,naturalWidth:d.naturalWidth,aspectRatio:d.naturalWidth/d.naturalHeight});}catch{}finally{clearTimeout(a);}})(),i.loading},w=e=>e!==void 0&&e!==""?h.get(e)?.ready:void 0;var A=(r=>(r.CIRCLE="circle",r.BLUR_CIRCLE="blur-circle",r.SLIDE="slide",r.CLIP_PATH="clip-path",r.POLYGON_GRADIENT="polygon-gradient",r.TRIANGLE="triangle",r.SVG_LOGO="svg-logo",r))(A||{}),D=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"];var s=new WeakMap,k=async(e$1,o$1)=>{if(!("document"in globalThis)){e$1();return}let i$1=s.get(document);i$1?.transition?.skipTransition(),i$1?.animation?.cancel(),i$1?.logo?.element.remove(),i$1?.logo?.style.remove();let t={updateDone:Promise.resolve()};s.set(document,t);let a$1=()=>{t.animation?.cancel(),t.logo?.element.remove(),t.logo?.style.remove(),s.get(document)===t&&(s.delete(document),document.documentElement.removeAttribute("data-spaceman-theme-transition"));};t.updateDone=(async()=>{if(i$1&&await i$1.updateDone.catch(()=>{}),s.get(document)!==t||!o$1||!e()||f()||document.visibilityState==="hidden"){e$1();return}a(),document.documentElement.setAttribute("data-spaceman-theme-transition",""),o$1.animationType==="svg-logo"&&(t.logo=v(o$1));let n;try{n=document.startViewTransition(e$1);}catch{e$1();return}t.transition=n,n.ready.catch(()=>{}),n.finished.then(a$1,a$1),await n.updateCallbackDone;})();try{await t.updateDone;let n$1=t.transition;if(!n$1){a$1();return}try{await n$1.ready;}catch{a$1();return}if(s.get(document)!==t){n$1.skipTransition();return}if(!o$1)return;try{t.animation=o$1.animationType==="slide"?n(o$1):o$1.animationType==="blur-circle"?o(o$1):o$1.animationType==="clip-path"?i(o$1):o$1.animationType==="polygon-gradient"?j(o$1):o$1.animationType==="triangle"?k$1(o$1):o$1.animationType==="svg-logo"?l(o$1):m(o$1),t.animation.finished.catch(()=>{});let l$1=t.animation.effect;!(t.animation instanceof CSSAnimation)&&(!(l$1 instanceof KeyframeEffect)||l$1.pseudoElement!=="::view-transition-new(root)")&&(n$1.skipTransition(),a$1());}catch{n$1.skipTransition(),a$1();}}catch(n){throw a$1(),n}};
|
|
12
|
+
export{I as a,R as b,A as c,D as d,k as e};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { q as AnimationConfig } from '../animations-CaaRrn3-.js';
|
|
2
|
+
export { A as AnimationPosition, C as ColorTheme, a as ColorThemeToggle, S as SlideDirection, b as SystemThemeMode, T as TRANSITION_DIRECTIONS, c as Theme, d as ThemeAnimationOptions, e as ThemeAnimationType, f as ThemeLogoOptions, g as ThemeSelectorProps, h as ThemeSwitcherProps, i as ThemeTransitionInput, j as ThemeTransitionOptions, k as TransitionDirection, U as UseThemeAnimationProps, l as UseThemeAnimationReturn, t as createBlurCircleAnimation, u as createCircleAnimation, v as createClipPathAnimation, w as createPolygonGradientAnimation, x as createSlideAnimation, y as createSvgLogoAnimation, z as createTriangleAnimation, B as getAnimationPosition, D as getSlideFromCoords, m as getSystemTheme, n as injectBaseStyles, p as prefersReducedMotion, r as resolveTheme, o as resolveThemeForServer, s as supportsViewTransitions } from '../animations-CaaRrn3-.js';
|
|
3
|
+
export { p as preloadThemeLogo } from '../logo-DtwtRv4y.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
/** Latest request wins visually; every requested state update still runs once. */
|
|
7
|
+
declare const runThemeTransition: (update: () => void, config: AnimationConfig | null) => Promise<void>;
|
|
8
|
+
|
|
9
|
+
export { AnimationConfig, runThemeTransition };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{d as TRANSITION_DIRECTIONS,c as ThemeAnimationType,b as preloadThemeLogo,e as runThemeTransition}from'../chunk-X6UEG7WG.js';export{o as createBlurCircleAnimation,m as createCircleAnimation,i as createClipPathAnimation,j as createPolygonGradientAnimation,n as createSlideAnimation,l as createSvgLogoAnimation,k as createTriangleAnimation,h as getAnimationPosition,g as getSlideFromCoords,b as getSystemTheme,a as injectBaseStyles,f as prefersReducedMotion,c as resolveTheme,d as resolveThemeForServer,e as supportsViewTransitions}from'../chunk-I3T2QXRT.js';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { NextThemeProvider, SpacemanThemeProvider, TanStackStartThemeScript, TanStackThemeProvider, ThemeProvider, ThemeSelector, ThemeSwitcher, ViteThemeProvider, useHydrated, useNextTheme, useSpacemanTheme, useTanStackTheme, useTheme, useThemeAnimation, useViteTheme } from './react/index.js';
|
|
2
|
+
export { A as AnimationPosition, C as ColorTheme, a as ColorThemeToggle, S as SlideDirection, b as SystemThemeMode, T as TRANSITION_DIRECTIONS, c as Theme, d as ThemeAnimationOptions, e as ThemeAnimationType, f as ThemeLogoOptions, g as ThemeSelectorProps, h as ThemeSwitcherProps, i as ThemeTransitionInput, j as ThemeTransitionOptions, k as TransitionDirection, U as UseThemeAnimationProps, l as UseThemeAnimationReturn, m as getSystemTheme, n as injectBaseStyles, p as prefersReducedMotion, r as resolveTheme, o as resolveThemeForServer, s as supportsViewTransitions } from './animations-CaaRrn3-.js';
|
|
3
|
+
export { COLOR_STORAGE_KEY, COLOR_THEME_PREFIX, GLOBAL_CLASS_NAME, STORAGE_KEY, ServerResolvedTheme, ServerThemeData, buildServerThemeData } from './tanstack/index.js';
|
|
4
|
+
export { p as preloadThemeLogo } from './logo-DtwtRv4y.js';
|
|
5
|
+
import 'react';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{g as NextThemeProvider,e as SpacemanThemeProvider,k as TanStackStartThemeScript,l as TanStackThemeProvider,h as ThemeProvider,d as ThemeSelector,c as ThemeSwitcher,n as ViteThemeProvider,a as useHydrated,i as useNextTheme,f as useSpacemanTheme,m as useTanStackTheme,j as useTheme,b as useThemeAnimation,o as useViteTheme}from'./chunk-FNL7ZHF4.js';export{d as TRANSITION_DIRECTIONS,c as ThemeAnimationType,b as preloadThemeLogo}from'./chunk-X6UEG7WG.js';export{b as COLOR_STORAGE_KEY,d as COLOR_THEME_PREFIX,c as GLOBAL_CLASS_NAME,a as STORAGE_KEY,e as buildServerThemeData}from'./chunk-QYUMCBTQ.js';export{b as getSystemTheme,a as injectBaseStyles,f as prefersReducedMotion,c as resolveTheme,d as resolveThemeForServer,e as supportsViewTransitions}from'./chunk-I3T2QXRT.js';
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { U as UseThemeAnimationProps, l as UseThemeAnimationReturn, h as ThemeSwitcherProps, g as ThemeSelectorProps, c as Theme, C as ColorTheme, e as ThemeAnimationType, i as ThemeTransitionInput, a as ColorThemeToggle, b as SystemThemeMode } from '../animations-CaaRrn3-.js';
|
|
2
|
+
export { A as AnimationPosition, S as SlideDirection, T as TRANSITION_DIRECTIONS, d as ThemeAnimationOptions, f as ThemeLogoOptions, j as ThemeTransitionOptions, k as TransitionDirection, m as getSystemTheme, n as injectBaseStyles, p as prefersReducedMotion, r as resolveTheme, o as resolveThemeForServer, s as supportsViewTransitions } from '../animations-CaaRrn3-.js';
|
|
3
|
+
import React, { ReactNode } from 'react';
|
|
4
|
+
export { p as preloadThemeLogo } from '../logo-DtwtRv4y.js';
|
|
5
|
+
|
|
6
|
+
declare const useThemeAnimation: (props?: Readonly<UseThemeAnimationProps>) => UseThemeAnimationReturn;
|
|
7
|
+
|
|
8
|
+
declare function ThemeSwitcher(props: ThemeSwitcherProps): React.JSX.Element;
|
|
9
|
+
|
|
10
|
+
declare function ThemeSelector(props: ThemeSelectorProps): React.JSX.Element;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Context type for the Spaceman Theme Provider
|
|
14
|
+
*/
|
|
15
|
+
interface SpacemanThemeContextType {
|
|
16
|
+
readonly ref: React.RefObject<HTMLButtonElement | null>;
|
|
17
|
+
readonly theme: Theme;
|
|
18
|
+
readonly colorTheme: ColorTheme;
|
|
19
|
+
readonly resolvedTheme: 'light' | 'dark';
|
|
20
|
+
readonly setTheme: (theme: Theme) => void;
|
|
21
|
+
readonly setColorTheme: (colorTheme: ColorTheme) => void;
|
|
22
|
+
readonly switchTheme: (theme: Theme, options?: ThemeTransitionInput) => Promise<void>;
|
|
23
|
+
readonly switchColorTheme: (colorTheme: string, options?: ThemeTransitionInput) => Promise<void>;
|
|
24
|
+
readonly toggleTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
25
|
+
readonly toggleLightTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
26
|
+
readonly toggleDarkTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
27
|
+
readonly toggleColorTheme: ColorThemeToggle;
|
|
28
|
+
readonly createColorThemeToggle: (targetColorTheme: string) => ColorThemeToggle;
|
|
29
|
+
readonly isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
30
|
+
readonly switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Props for the Spaceman Theme Provider
|
|
34
|
+
*/
|
|
35
|
+
type SpacemanThemeProviderProps = UseThemeAnimationProps & {
|
|
36
|
+
readonly children: ReactNode;
|
|
37
|
+
readonly themes?: readonly Theme[];
|
|
38
|
+
readonly colorThemes?: readonly ColorTheme[];
|
|
39
|
+
readonly defaultTheme?: Theme;
|
|
40
|
+
readonly defaultColorTheme?: ColorTheme;
|
|
41
|
+
readonly animationType?: ThemeAnimationType;
|
|
42
|
+
readonly duration?: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Spaceman Theme Provider - Provides centralized theme state management
|
|
46
|
+
*
|
|
47
|
+
* This provider creates a single source of truth for theme state using the useThemeAnimation hook.
|
|
48
|
+
* All theme-related components should consume from this context to ensure synchronization.
|
|
49
|
+
*
|
|
50
|
+
* @param children - React children to wrap with theme context
|
|
51
|
+
* @param themes - Available theme options (default: ['light', 'dark', 'system'])
|
|
52
|
+
* @param colorThemes - Available color theme options (default: ['default'])
|
|
53
|
+
* @param defaultTheme - Default theme to use (default: 'system')
|
|
54
|
+
* @param defaultColorTheme - Default color theme to use (default: 'default')
|
|
55
|
+
* @param animationType - Animation type for theme transitions (default: CIRCLE)
|
|
56
|
+
* @param duration - Animation duration in milliseconds (default: 400)
|
|
57
|
+
*/
|
|
58
|
+
declare function SpacemanThemeProvider({ children, themes, colorThemes, defaultTheme, defaultColorTheme, animationType, duration, ...animationOptions }: Readonly<SpacemanThemeProviderProps>): React.JSX.Element;
|
|
59
|
+
/**
|
|
60
|
+
* Hook to consume the Spaceman Theme context
|
|
61
|
+
*
|
|
62
|
+
* @returns Theme context value with all theme state and methods
|
|
63
|
+
* @throws Error if used outside of SpacemanThemeProvider
|
|
64
|
+
*/
|
|
65
|
+
declare const useSpacemanTheme: () => SpacemanThemeContextType;
|
|
66
|
+
|
|
67
|
+
interface NextThemeContextType {
|
|
68
|
+
readonly ref: React.RefObject<HTMLButtonElement | null>;
|
|
69
|
+
readonly theme: Theme;
|
|
70
|
+
readonly colorTheme: ColorTheme;
|
|
71
|
+
readonly resolvedTheme: 'light' | 'dark';
|
|
72
|
+
readonly systemTheme: 'light' | 'dark';
|
|
73
|
+
readonly setTheme: (theme: Theme) => void;
|
|
74
|
+
readonly setColorTheme: (colorTheme: ColorTheme) => void;
|
|
75
|
+
readonly switchTheme: (theme: Theme, options?: ThemeTransitionInput) => Promise<void>;
|
|
76
|
+
readonly switchColorTheme: (colorTheme: string, options?: ThemeTransitionInput) => Promise<void>;
|
|
77
|
+
readonly toggleTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
78
|
+
readonly toggleLightTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
79
|
+
readonly toggleDarkTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
80
|
+
readonly toggleColorTheme: ColorThemeToggle;
|
|
81
|
+
readonly createColorThemeToggle: (targetColorTheme: string) => ColorThemeToggle;
|
|
82
|
+
readonly isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
83
|
+
readonly switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
type NextThemeProviderProps = UseThemeAnimationProps & {
|
|
86
|
+
readonly children: React.ReactNode;
|
|
87
|
+
readonly themes?: readonly Theme[];
|
|
88
|
+
readonly colorThemes?: readonly ColorTheme[];
|
|
89
|
+
readonly defaultTheme?: Theme;
|
|
90
|
+
readonly defaultColorTheme?: ColorTheme;
|
|
91
|
+
readonly animationType?: ThemeAnimationType;
|
|
92
|
+
readonly duration?: number;
|
|
93
|
+
readonly storageKey?: string;
|
|
94
|
+
readonly colorStorageKey?: string;
|
|
95
|
+
readonly attribute?: 'class' | 'data-theme';
|
|
96
|
+
readonly value?: Record<string, string>;
|
|
97
|
+
readonly enableSystem?: boolean;
|
|
98
|
+
readonly enableColorScheme?: boolean;
|
|
99
|
+
readonly disableTransitionOnChange?: boolean;
|
|
100
|
+
readonly forcedTheme?: Theme;
|
|
101
|
+
readonly nonce?: string;
|
|
102
|
+
readonly scriptProps?: Omit<React.ScriptHTMLAttributes<HTMLScriptElement>, 'dangerouslySetInnerHTML' | 'nonce'>;
|
|
103
|
+
readonly colorThemePrefix?: string;
|
|
104
|
+
readonly globalClassName?: string;
|
|
105
|
+
readonly disableAnimationOnInit?: boolean;
|
|
106
|
+
readonly disablePreHydrationScript?: boolean;
|
|
107
|
+
readonly onThemeChange?: (theme: Theme) => void;
|
|
108
|
+
readonly onColorThemeChange?: (colorTheme: ColorTheme) => void;
|
|
109
|
+
};
|
|
110
|
+
declare function NextThemeProvider({ attribute, children, colorStorageKey, colorThemePrefix, colorThemes, defaultColorTheme, defaultTheme, disableAnimationOnInit, disablePreHydrationScript, disableTransitionOnChange, duration, enableColorScheme, enableSystem, forcedTheme, globalClassName, nonce, onColorThemeChange, onThemeChange, scriptProps, storageKey, themes, value, animationType, ...animationOptions }: Readonly<NextThemeProviderProps>): React.JSX.Element;
|
|
111
|
+
declare const ThemeProvider: typeof NextThemeProvider;
|
|
112
|
+
declare const useNextTheme: () => NextThemeContextType;
|
|
113
|
+
declare const useTheme: () => NextThemeContextType;
|
|
114
|
+
|
|
115
|
+
interface TanStackStartThemeScriptProps {
|
|
116
|
+
readonly storageKey?: string;
|
|
117
|
+
readonly colorStorageKey?: string;
|
|
118
|
+
readonly defaultTheme?: Theme;
|
|
119
|
+
readonly defaultColorTheme?: ColorTheme;
|
|
120
|
+
readonly globalClassName?: string;
|
|
121
|
+
readonly colorThemePrefix?: string;
|
|
122
|
+
readonly nonce?: string;
|
|
123
|
+
readonly systemThemeMode?: SystemThemeMode;
|
|
124
|
+
}
|
|
125
|
+
declare const TanStackStartThemeScript: React.FC<TanStackStartThemeScriptProps>;
|
|
126
|
+
|
|
127
|
+
interface TanStackThemeContextType {
|
|
128
|
+
readonly ref: React.RefObject<HTMLButtonElement | null>;
|
|
129
|
+
readonly theme: Theme;
|
|
130
|
+
readonly colorTheme: ColorTheme;
|
|
131
|
+
readonly resolvedTheme: 'light' | 'dark';
|
|
132
|
+
readonly systemTheme: 'light' | 'dark';
|
|
133
|
+
readonly isHydrated: boolean;
|
|
134
|
+
readonly setTheme: (theme: Theme) => void;
|
|
135
|
+
readonly setColorTheme: (colorTheme: ColorTheme) => void;
|
|
136
|
+
readonly switchTheme: (theme: Theme, options?: ThemeTransitionInput) => Promise<void>;
|
|
137
|
+
readonly switchColorTheme: (colorTheme: string, options?: ThemeTransitionInput) => Promise<void>;
|
|
138
|
+
readonly toggleTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
139
|
+
readonly toggleLightTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
140
|
+
readonly toggleDarkTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
141
|
+
readonly toggleColorTheme: ColorThemeToggle;
|
|
142
|
+
readonly createColorThemeToggle: (targetColorTheme: string) => ColorThemeToggle;
|
|
143
|
+
readonly isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
144
|
+
readonly switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
145
|
+
}
|
|
146
|
+
type TanStackThemeProviderProps = UseThemeAnimationProps & {
|
|
147
|
+
readonly children: ReactNode;
|
|
148
|
+
readonly themes?: readonly Theme[];
|
|
149
|
+
readonly colorThemes?: readonly ColorTheme[];
|
|
150
|
+
readonly defaultTheme?: Theme;
|
|
151
|
+
readonly defaultColorTheme?: ColorTheme;
|
|
152
|
+
readonly animationType?: ThemeAnimationType;
|
|
153
|
+
readonly duration?: number;
|
|
154
|
+
readonly storageKey?: string;
|
|
155
|
+
readonly colorStorageKey?: string;
|
|
156
|
+
readonly globalClassName?: string;
|
|
157
|
+
readonly colorThemePrefix?: string;
|
|
158
|
+
readonly serverTheme?: 'light' | 'dark' | 'system';
|
|
159
|
+
readonly serverColorTheme?: ColorTheme;
|
|
160
|
+
readonly systemThemeMode?: SystemThemeMode;
|
|
161
|
+
readonly onServerThemeChange?: (theme: Theme) => Promise<void> | void;
|
|
162
|
+
readonly onServerColorThemeChange?: (colorTheme: ColorTheme) => Promise<void> | void;
|
|
163
|
+
};
|
|
164
|
+
declare function TanStackThemeProvider({ children, themes, colorThemes, defaultTheme, defaultColorTheme, animationType, duration, storageKey, colorStorageKey, globalClassName, colorThemePrefix, serverTheme, serverColorTheme, systemThemeMode, onServerThemeChange, onServerColorThemeChange, ...animationOptions }: Readonly<TanStackThemeProviderProps>): React.JSX.Element;
|
|
165
|
+
declare const useTanStackTheme: () => TanStackThemeContextType;
|
|
166
|
+
|
|
167
|
+
interface ViteThemeContextType {
|
|
168
|
+
readonly ref: React.RefObject<HTMLButtonElement | null>;
|
|
169
|
+
readonly theme: Theme;
|
|
170
|
+
readonly colorTheme: ColorTheme;
|
|
171
|
+
readonly resolvedTheme: 'light' | 'dark';
|
|
172
|
+
readonly systemTheme: 'light' | 'dark';
|
|
173
|
+
readonly setTheme: (theme: Theme) => void;
|
|
174
|
+
readonly setColorTheme: (colorTheme: ColorTheme) => void;
|
|
175
|
+
readonly switchTheme: (theme: Theme, options?: ThemeTransitionInput) => Promise<void>;
|
|
176
|
+
readonly switchColorTheme: (colorTheme: string, options?: ThemeTransitionInput) => Promise<void>;
|
|
177
|
+
readonly toggleTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
178
|
+
readonly toggleLightTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
179
|
+
readonly toggleDarkTheme: (options?: ThemeTransitionInput) => Promise<void>;
|
|
180
|
+
readonly toggleColorTheme: ColorThemeToggle;
|
|
181
|
+
readonly createColorThemeToggle: (targetColorTheme: string) => ColorThemeToggle;
|
|
182
|
+
readonly isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
183
|
+
readonly switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
184
|
+
}
|
|
185
|
+
type ViteThemeProviderProps = UseThemeAnimationProps & {
|
|
186
|
+
readonly children: ReactNode;
|
|
187
|
+
readonly themes?: readonly Theme[];
|
|
188
|
+
readonly colorThemes?: readonly ColorTheme[];
|
|
189
|
+
readonly defaultTheme?: Theme;
|
|
190
|
+
readonly defaultColorTheme?: ColorTheme;
|
|
191
|
+
readonly animationType?: ThemeAnimationType;
|
|
192
|
+
readonly duration?: number;
|
|
193
|
+
readonly attribute?: 'class' | 'data-theme';
|
|
194
|
+
readonly disableTransitionOnChange?: boolean;
|
|
195
|
+
readonly storageKey?: string;
|
|
196
|
+
readonly colorStorageKey?: string;
|
|
197
|
+
readonly globalClassName?: string;
|
|
198
|
+
readonly colorThemePrefix?: string;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Vite Theme Provider - Optimized for Vite SPA applications
|
|
202
|
+
*
|
|
203
|
+
* This provider is designed for Vite-based single-page applications with optional
|
|
204
|
+
* transition disabling to prevent flash during theme switches.
|
|
205
|
+
*
|
|
206
|
+
* Note: For flash prevention on initial load, add a script to your index.html
|
|
207
|
+
* or inject it via Vite plugin to apply theme before React loads.
|
|
208
|
+
*
|
|
209
|
+
* @param children - React children to wrap with theme context
|
|
210
|
+
* @param themes - Available theme options
|
|
211
|
+
* @param colorThemes - Available color theme options
|
|
212
|
+
* @param defaultTheme - Default theme to use
|
|
213
|
+
* @param defaultColorTheme - Default color theme to use
|
|
214
|
+
* @param animationType - Animation type for theme transitions
|
|
215
|
+
* @param duration - Animation duration in milliseconds
|
|
216
|
+
* @param attribute - HTML attribute to use for theme ('class' or 'data-theme')
|
|
217
|
+
* @param disableTransitionOnChange - Temporarily disable CSS transitions during theme switch
|
|
218
|
+
* @param storageKey - LocalStorage key for theme preference
|
|
219
|
+
* @param colorStorageKey - LocalStorage key for color theme preference
|
|
220
|
+
* @param globalClassName - Class name for dark theme (when using 'class' attribute)
|
|
221
|
+
* @param colorThemePrefix - Prefix for color theme classes
|
|
222
|
+
*/
|
|
223
|
+
declare function ViteThemeProvider({ children, themes, colorThemes, defaultTheme, defaultColorTheme, animationType, duration, attribute, disableTransitionOnChange, storageKey, colorStorageKey, globalClassName, colorThemePrefix, ...animationOptions }: Readonly<ViteThemeProviderProps>): React.JSX.Element;
|
|
224
|
+
declare const useViteTheme: () => ViteThemeContextType;
|
|
225
|
+
|
|
226
|
+
declare function useHydrated(): boolean;
|
|
227
|
+
|
|
228
|
+
export { ColorTheme, ColorThemeToggle, NextThemeProvider, SpacemanThemeProvider, SystemThemeMode, TanStackStartThemeScript, TanStackThemeProvider, Theme, ThemeAnimationType, ThemeProvider, ThemeSelector, ThemeSelectorProps, ThemeSwitcher, ThemeSwitcherProps, ThemeTransitionInput, UseThemeAnimationProps, UseThemeAnimationReturn, ViteThemeProvider, useHydrated, useNextTheme, useSpacemanTheme, useTanStackTheme, useTheme, useThemeAnimation, useViteTheme };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
export{g as NextThemeProvider,e as SpacemanThemeProvider,k as TanStackStartThemeScript,l as TanStackThemeProvider,h as ThemeProvider,d as ThemeSelector,c as ThemeSwitcher,n as ViteThemeProvider,a as useHydrated,i as useNextTheme,f as useSpacemanTheme,m as useTanStackTheme,j as useTheme,b as useThemeAnimation,o as useViteTheme}from'../chunk-FNL7ZHF4.js';export{d as TRANSITION_DIRECTIONS,c as ThemeAnimationType,b as preloadThemeLogo}from'../chunk-X6UEG7WG.js';import'../chunk-QYUMCBTQ.js';export{b as getSystemTheme,a as injectBaseStyles,f as prefersReducedMotion,c as resolveTheme,d as resolveThemeForServer,e as supportsViewTransitions}from'../chunk-I3T2QXRT.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { c as Theme, C as ColorTheme } from '../animations-CaaRrn3-.js';
|
|
2
|
+
export { o as resolveThemeForServer } from '../animations-CaaRrn3-.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
|
|
5
|
+
declare const STORAGE_KEY = "theme";
|
|
6
|
+
declare const COLOR_STORAGE_KEY = "color-theme";
|
|
7
|
+
declare const GLOBAL_CLASS_NAME = "dark";
|
|
8
|
+
declare const COLOR_THEME_PREFIX = "theme-";
|
|
9
|
+
type ServerResolvedTheme = 'light' | 'dark' | 'system';
|
|
10
|
+
interface ServerThemeData {
|
|
11
|
+
readonly theme: ServerResolvedTheme;
|
|
12
|
+
readonly themePreference: Theme;
|
|
13
|
+
readonly colorTheme: ColorTheme;
|
|
14
|
+
}
|
|
15
|
+
declare function buildServerThemeData(themeCookie: string | undefined, colorThemeCookie: string | undefined, options?: {
|
|
16
|
+
readonly defaultTheme?: Theme;
|
|
17
|
+
readonly defaultColorTheme?: ColorTheme;
|
|
18
|
+
}): ServerThemeData;
|
|
19
|
+
|
|
20
|
+
export { COLOR_STORAGE_KEY, COLOR_THEME_PREFIX, ColorTheme, GLOBAL_CLASS_NAME, STORAGE_KEY, type ServerResolvedTheme, type ServerThemeData, Theme, buildServerThemeData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as COLOR_STORAGE_KEY,d as COLOR_THEME_PREFIX,c as GLOBAL_CLASS_NAME,a as STORAGE_KEY,e as buildServerThemeData}from'../chunk-QYUMCBTQ.js';export{d as resolveThemeForServer}from'../chunk-I3T2QXRT.js';
|
package/package.json
CHANGED
|
@@ -1,91 +1,110 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@space-man/react-theme-animation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "React theme switching with smooth view transition animations and multi-theme support",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"animation",
|
|
7
|
+
"dark",
|
|
8
8
|
"dark mode",
|
|
9
|
-
"light mode",
|
|
10
|
-
"theme switching",
|
|
11
|
-
"view transitions",
|
|
12
9
|
"hooks",
|
|
13
|
-
"
|
|
10
|
+
"light",
|
|
11
|
+
"light mode",
|
|
12
|
+
"nextjs",
|
|
13
|
+
"react",
|
|
14
|
+
"reactjs",
|
|
15
|
+
"shadcn",
|
|
14
16
|
"switch",
|
|
17
|
+
"tailwind",
|
|
18
|
+
"tailwindcss",
|
|
19
|
+
"theme",
|
|
20
|
+
"theme switching",
|
|
15
21
|
"typescript",
|
|
16
|
-
"
|
|
17
|
-
"light",
|
|
22
|
+
"view transitions",
|
|
18
23
|
"view-transition",
|
|
19
24
|
"view-transition-api",
|
|
20
|
-
"tailwind",
|
|
21
|
-
"tailwindcss",
|
|
22
|
-
"shadcn",
|
|
23
|
-
"reactjs",
|
|
24
|
-
"nextjs",
|
|
25
25
|
"vite"
|
|
26
26
|
],
|
|
27
|
-
"publishConfig": {
|
|
28
|
-
"registry": "https://registry.npmjs.org/",
|
|
29
|
-
"access": "public"
|
|
30
|
-
},
|
|
31
|
-
"repository": {
|
|
32
|
-
"type": "git",
|
|
33
|
-
"url": "git+https://github.com/tonyedgal/spaceman-react-theme-animation.git"
|
|
34
|
-
},
|
|
35
27
|
"homepage": "https://github.com/tonyedgal/spaceman-react-theme-animation#readme",
|
|
36
28
|
"bugs": {
|
|
37
29
|
"url": "https://github.com/tonyedgal/spaceman-react-theme-animation/issues"
|
|
38
30
|
},
|
|
39
31
|
"license": "MIT",
|
|
40
32
|
"author": "tonyedgal",
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/tonyedgal/spaceman-react-theme-animation.git"
|
|
36
|
+
},
|
|
44
37
|
"files": [
|
|
45
38
|
"dist",
|
|
46
39
|
"LICENSE",
|
|
47
40
|
"README.md"
|
|
48
41
|
],
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"
|
|
74
|
-
|
|
42
|
+
"type": "module",
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"main": "./dist/index.js",
|
|
45
|
+
"module": "./dist/index.js",
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
47
|
+
"exports": {
|
|
48
|
+
".": {
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./dist/index.d.ts",
|
|
51
|
+
"default": "./dist/index.js"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"./core": {
|
|
55
|
+
"import": {
|
|
56
|
+
"types": "./dist/core/index.d.ts",
|
|
57
|
+
"default": "./dist/core/index.js"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"./react": {
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./dist/react/index.d.ts",
|
|
63
|
+
"default": "./dist/react/index.js"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"./tanstack": {
|
|
67
|
+
"import": {
|
|
68
|
+
"types": "./dist/tanstack/index.d.ts",
|
|
69
|
+
"default": "./dist/tanstack/index.js"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"./package.json": "./package.json"
|
|
75
73
|
},
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"@typescript-eslint/eslint-plugin": "^8.15.0",
|
|
81
|
-
"@typescript-eslint/parser": "^8.15.0",
|
|
82
|
-
"eslint": "^9.15.0",
|
|
83
|
-
"eslint-plugin-react": "^7.37.2",
|
|
84
|
-
"eslint-plugin-react-hooks": "^5.0.0",
|
|
85
|
-
"prettier": "^3.3.3",
|
|
86
|
-
"typescript": "^5.6.3"
|
|
74
|
+
"publishConfig": {
|
|
75
|
+
"access": "public",
|
|
76
|
+
"provenance": true,
|
|
77
|
+
"registry": "https://registry.npmjs.org/"
|
|
87
78
|
},
|
|
88
79
|
"dependencies": {
|
|
89
80
|
"clsx": "^2.1.1"
|
|
81
|
+
},
|
|
82
|
+
"devDependencies": {
|
|
83
|
+
"@playwright/test": "1.63.0",
|
|
84
|
+
"@radix-ui/react-select": "^2.3.7",
|
|
85
|
+
"@types/node": "^26.6.4",
|
|
86
|
+
"@types/react": "^19.3.0",
|
|
87
|
+
"@types/react-dom": "^19.3.0",
|
|
88
|
+
"motion": "^14.0.0",
|
|
89
|
+
"react": "^19.3.0",
|
|
90
|
+
"react-dom": "^19.3.0",
|
|
91
|
+
"vite": "^8.3.2",
|
|
92
|
+
"zod": "^4.6.5"
|
|
93
|
+
},
|
|
94
|
+
"peerDependencies": {
|
|
95
|
+
"@radix-ui/react-select": ">=2",
|
|
96
|
+
"motion": ">=12",
|
|
97
|
+
"react": ">=18",
|
|
98
|
+
"react-dom": ">=18"
|
|
99
|
+
},
|
|
100
|
+
"scripts": {
|
|
101
|
+
"build": "tsup && node scripts/mark-react-client.mjs",
|
|
102
|
+
"clean": "rm -rf dist",
|
|
103
|
+
"dev": "tsup --watch",
|
|
104
|
+
"test": "node scripts/smoke-subpath-imports.mjs",
|
|
105
|
+
"test:browser": "playwright test",
|
|
106
|
+
"test:types": "tsc --noEmit -p tests/tsconfig.json",
|
|
107
|
+
"test:unit": "node --test tests/*.test.mjs",
|
|
108
|
+
"typecheck": "tsc --noEmit"
|
|
90
109
|
}
|
|
91
|
-
}
|
|
110
|
+
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { Theme, ColorTheme, ThemeAnimationType } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Context type for the Next Theme Provider
|
|
5
|
-
*/
|
|
6
|
-
interface NextThemeContextType {
|
|
7
|
-
ref: React.RefObject<HTMLButtonElement | null>;
|
|
8
|
-
theme: Theme;
|
|
9
|
-
colorTheme: ColorTheme;
|
|
10
|
-
resolvedTheme: 'light' | 'dark';
|
|
11
|
-
systemTheme: 'light' | 'dark';
|
|
12
|
-
setTheme: (theme: Theme) => void;
|
|
13
|
-
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
14
|
-
switchTheme: (theme: Theme, animationOff?: boolean) => Promise<void>;
|
|
15
|
-
switchColorTheme: (colorTheme: string) => void;
|
|
16
|
-
toggleTheme: (animationOff?: boolean) => Promise<void>;
|
|
17
|
-
toggleLightTheme: (animationOff?: boolean) => Promise<void>;
|
|
18
|
-
toggleDarkTheme: (animationOff?: boolean) => Promise<void>;
|
|
19
|
-
toggleColorTheme: () => void;
|
|
20
|
-
createColorThemeToggle: (targetColorTheme: string) => () => void;
|
|
21
|
-
isColorThemeActive: (targetColorTheme: string) => boolean;
|
|
22
|
-
switchThemeFromElement: (theme: Theme, element: HTMLButtonElement) => Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Props for the Next Theme Provider
|
|
26
|
-
*/
|
|
27
|
-
interface NextThemeProviderProps {
|
|
28
|
-
children: ReactNode;
|
|
29
|
-
themes?: Theme[];
|
|
30
|
-
colorThemes?: ColorTheme[];
|
|
31
|
-
defaultTheme?: Theme;
|
|
32
|
-
defaultColorTheme?: ColorTheme;
|
|
33
|
-
animationType?: ThemeAnimationType;
|
|
34
|
-
duration?: number;
|
|
35
|
-
storageKey?: string;
|
|
36
|
-
colorStorageKey?: string;
|
|
37
|
-
attribute?: 'class' | 'data-theme';
|
|
38
|
-
globalClassName?: string;
|
|
39
|
-
colorThemePrefix?: string;
|
|
40
|
-
nonce?: string;
|
|
41
|
-
disableAnimationOnInit?: boolean;
|
|
42
|
-
disablePreHydrationScript?: boolean;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Next Theme Provider - Next.js optimized theme management with animations
|
|
46
|
-
*
|
|
47
|
-
* This provider is specifically optimized for Next.js and SSR frameworks with
|
|
48
|
-
* pre-hydration script injection to prevent flash of wrong theme.
|
|
49
|
-
*
|
|
50
|
-
* Features:
|
|
51
|
-
* - Pre-hydration script for flash prevention (SSR apps)
|
|
52
|
-
* - Animated theme transitions via View Transitions API
|
|
53
|
-
* - Multi-dimensional theming (theme + colorTheme)
|
|
54
|
-
* - System theme detection
|
|
55
|
-
* - CSP support via nonce prop
|
|
56
|
-
*
|
|
57
|
-
* @param children - React children to wrap with theme context
|
|
58
|
-
* @param themes - Available theme options
|
|
59
|
-
* @param colorThemes - Available color theme options
|
|
60
|
-
* @param defaultTheme - Default theme to use
|
|
61
|
-
* @param defaultColorTheme - Default color theme to use
|
|
62
|
-
* @param animationType - Animation type for theme transitions
|
|
63
|
-
* @param duration - Animation duration in milliseconds
|
|
64
|
-
* @param storageKey - LocalStorage key for theme preference
|
|
65
|
-
* @param colorStorageKey - LocalStorage key for color theme preference
|
|
66
|
-
* @param attribute - HTML attribute to use for theme ('class' or 'data-theme')
|
|
67
|
-
* @param globalClassName - Class name for dark theme (when using 'class' attribute)
|
|
68
|
-
* @param colorThemePrefix - Prefix for color theme classes
|
|
69
|
-
* @param nonce - CSP nonce for inline script (SSR apps)
|
|
70
|
-
* @param disableAnimationOnInit - Skip animation during initial hydration
|
|
71
|
-
* @param disablePreHydrationScript - Disable flash prevention script (for SPAs without SSR)
|
|
72
|
-
*/
|
|
73
|
-
export declare const NextThemeProvider: React.FC<NextThemeProviderProps>;
|
|
74
|
-
/**
|
|
75
|
-
* Hook to consume the Next Theme context
|
|
76
|
-
*
|
|
77
|
-
* @returns Theme context value with all theme state and methods
|
|
78
|
-
* @throws Error if used outside of NextThemeProvider
|
|
79
|
-
*/
|
|
80
|
-
export declare const useNextTheme: () => NextThemeContextType;
|
|
81
|
-
export {};
|