uitheme-web 2.0.0-rc.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -102
- package/dist/{chunk-QM4QO6LG.cjs → chunk-4UXANDJ5.cjs} +2 -2
- package/dist/{chunk-YGWVUGQI.js → chunk-C4YNAGUP.js} +2 -2
- package/dist/{index-CR2g5NEe.d.ts → index-Dn3XRBX1.d.ts} +1 -1
- package/dist/{index-DQvBhaeA.d.cts → index-DqlTGyMr.d.cts} +1 -1
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.d.cts +1 -1
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js +1 -1
- package/dist/react/index.cjs +11 -11
- package/dist/react/index.d.cts +5 -5
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.js +2 -2
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,138 +1,99 @@
|
|
|
1
1
|
# uitheme-web
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
The runtime has no mandatory framework or UI primitive dependencies.
|
|
3
|
+
https://github.com/user-attachments/assets/2819cf70-c474-478e-b821-6b26457c8d4a
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Animated light and dark mode for your web app, with support for color themes
|
|
6
|
+
when one look isn't enough, so one app can carry several design systems. The
|
|
7
|
+
controls come ready-made from the registry, installed via its CLI (or the shadcn
|
|
8
|
+
CLI).
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
- Light, dark and system modes
|
|
11
|
+
- Color palettes that work on top of either mode
|
|
12
|
+
- Seven built-in transitions, powered by the View Transitions API
|
|
13
|
+
- Respects reduced motion, and falls back gracefully in older browsers
|
|
14
|
+
- No flash on load with Next.js, TanStack Start and Nuxt
|
|
15
|
+
- Remembers the choice and syncs it across tabs
|
|
16
|
+
- React, Next.js, TanStack Start, Vue and Nuxt from one package
|
|
17
|
+
- No Tailwind or design system required
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
| ----------------------------------- | --------------------------------------------------------------- |
|
|
14
|
-
| `uitheme-web` or `uitheme-web/core` | Framework-neutral controller, transitions, types, and constants |
|
|
15
|
-
| `uitheme-web/react` | React providers and hooks |
|
|
16
|
-
| `uitheme-web/next` | Next.js client provider |
|
|
17
|
-
| `uitheme-web/next/server` | Server-safe pre-hydration script generator |
|
|
18
|
-
| `uitheme-web/tanstack` | Stateless TanStack Start server helpers |
|
|
19
|
-
| `uitheme-web/vue` | Vue 3.5 plugin, provider, and composables |
|
|
20
|
-
| `uitheme-web/vue/bootstrap` | Server-safe pre-hydration script generator |
|
|
21
|
-
| `uitheme-web/nuxt` | Nuxt 4 module |
|
|
19
|
+
Try it on [ui-theme.dev](https://www.ui-theme.dev).
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
Vue, and Nuxt are optional peer dependencies. The selected adapter requires its
|
|
25
|
-
framework in the app. Importing the core does not load a framework.
|
|
21
|
+
## Install
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
'use client';
|
|
23
|
+
```sh
|
|
24
|
+
npm install uitheme-web
|
|
25
|
+
```
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
## Use
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
const { resolvedTheme, switchTheme, mounted } = useUITheme();
|
|
29
|
+
Wrap your app in the provider, and choose a transition:
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
disabled={!mounted}
|
|
40
|
-
onClick={(event) =>
|
|
41
|
-
void switchTheme(resolvedTheme === 'dark' ? 'light' : 'dark', {
|
|
42
|
-
element: event.currentTarget,
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
>
|
|
46
|
-
Change appearance
|
|
47
|
-
</button>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
31
|
+
```tsx
|
|
32
|
+
import { UIThemeProvider } from 'uitheme-web/react';
|
|
50
33
|
|
|
51
34
|
export function App() {
|
|
52
35
|
return (
|
|
53
|
-
<UIThemeProvider>
|
|
54
|
-
<
|
|
36
|
+
<UIThemeProvider animationType="slide">
|
|
37
|
+
<YourApp />
|
|
55
38
|
</UIThemeProvider>
|
|
56
39
|
);
|
|
57
40
|
}
|
|
58
41
|
```
|
|
59
42
|
|
|
60
|
-
|
|
61
|
-
pre-hydration setup and accepts a CSP nonce. For TanStack Start, retain your
|
|
62
|
-
existing server helpers and cookie callbacks. Each provider shares state with
|
|
63
|
-
`useUITheme` from `uitheme-web/react`.
|
|
43
|
+
Then switch themes from anywhere:
|
|
64
44
|
|
|
65
|
-
|
|
45
|
+
```tsx
|
|
46
|
+
import { useUITheme } from 'uitheme-web/react';
|
|
66
47
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
import { createUITheme } from 'uitheme-web/vue';
|
|
70
|
-
import App from './App.vue';
|
|
48
|
+
function ThemeToggle() {
|
|
49
|
+
const { resolvedTheme, switchTheme } = useUITheme();
|
|
71
50
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
51
|
+
return (
|
|
52
|
+
<button
|
|
53
|
+
onClick={() => switchTheme(resolvedTheme === 'dark' ? 'light' : 'dark')}
|
|
54
|
+
>
|
|
55
|
+
Toggle theme
|
|
56
|
+
</button>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
75
59
|
```
|
|
76
60
|
|
|
77
|
-
|
|
78
|
-
`colorTheme`, and `mounted` refs, plus `setTheme`, `setColorTheme`, `switchTheme`,
|
|
79
|
-
and `switchColorTheme`. `UIThemeProvider` can provide an isolated nested scope.
|
|
80
|
-
Use `getThemeScript` from `uitheme-web/vue/bootstrap` in SSR document setup.
|
|
81
|
-
|
|
82
|
-
For Nuxt 4:
|
|
83
|
-
|
|
84
|
-
```ts
|
|
85
|
-
export default defineNuxtConfig({
|
|
86
|
-
modules: ['uitheme-web/nuxt'],
|
|
87
|
-
uiTheme: { colorThemes: ['default', 'ocean'] },
|
|
88
|
-
});
|
|
89
|
-
```
|
|
61
|
+
That's it. Style dark mode with the `dark` class, like you already do.
|
|
90
62
|
|
|
91
|
-
|
|
92
|
-
It does not register styled controls. Automatic Nuxt 3 setup is unsupported.
|
|
63
|
+
## Don't want to build the toggle?
|
|
93
64
|
|
|
94
|
-
|
|
65
|
+
Grab a ready-made one. The CLI sets up the provider and drops the control
|
|
66
|
+
straight into your codebase, so it's yours to tweak:
|
|
95
67
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
Pass the clicked element for a transition origin in viewport CSS pixels.
|
|
68
|
+
```sh
|
|
69
|
+
npx uitheme-cli init
|
|
70
|
+
npx uitheme-cli add theme-toggle
|
|
71
|
+
```
|
|
101
72
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
server requests do not share a global theme store.
|
|
73
|
+
Already on shadcn? [Add the registry](https://www.ui-theme.dev/docs/installation#install-with-shadcn)
|
|
74
|
+
and use `npx shadcn@latest add @uitheme/theme-toggle`.
|
|
105
75
|
|
|
106
|
-
|
|
76
|
+
[Browse all the controls →](https://www.ui-theme.dev/docs/components)
|
|
107
77
|
|
|
108
|
-
|
|
78
|
+
## Using another framework?
|
|
109
79
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
80
|
+
Each one has a short guide:
|
|
81
|
+
[Next.js](https://www.ui-theme.dev/docs/guides/nextjs) ·
|
|
82
|
+
[TanStack Start](https://www.ui-theme.dev/docs/guides/tanstack-start) ·
|
|
83
|
+
[Vue](https://www.ui-theme.dev/docs/guides/vue) ·
|
|
84
|
+
[Nuxt](https://www.ui-theme.dev/docs/guides/nuxt)
|
|
115
85
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
required dependencies. Customize local files, root classes, and internal part
|
|
119
|
-
classes. Keep transition settings in your app and pass them to the provider.
|
|
86
|
+
Building for mobile? Check out
|
|
87
|
+
[`uitheme-rn`](https://www.npmjs.com/package/uitheme-rn) for React Native.
|
|
120
88
|
|
|
121
|
-
|
|
89
|
+
Coming from v1? The [migration guide](https://www.ui-theme.dev/docs/migration)
|
|
90
|
+
walks you through it.
|
|
122
91
|
|
|
123
|
-
|
|
124
|
-
primitives, and their prop types have moved out of the runtime. The old runtime
|
|
125
|
-
binary has moved to `uitheme-cli`.
|
|
92
|
+
## Documentation
|
|
126
93
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
install the local controls, then review the migration preview. The app can have
|
|
130
|
-
unresolved imports until the migration is complete. Custom props and unknown
|
|
131
|
-
provider wiring require manual changes. `--yes` never accepts edited controls
|
|
132
|
-
as verified replacements.
|
|
94
|
+
Palettes, transition options, the full API and more live at
|
|
95
|
+
[ui-theme.dev/docs](https://www.ui-theme.dev/docs).
|
|
133
96
|
|
|
134
|
-
|
|
135
|
-
`uitheme-web/vue/bootstrap`, and `uitheme-vue/nuxt` with `uitheme-web/nuxt`.
|
|
136
|
-
The published Vue v1 package remains available. No bridge release is required.
|
|
97
|
+
## License
|
|
137
98
|
|
|
138
|
-
|
|
99
|
+
MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var chunkKQSBORXP_cjs=require('./chunk-KQSBORXP.cjs'),chunkCYGYUQUK_cjs=require('./chunk-CYGYUQUK.cjs'),ne=require('react'),reactDom=require('react-dom'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ne__default=/*#__PURE__*/_interopDefault(ne);var Q=t=>{let o;return {controller:chunkKQSBORXP_cjs.j(t,{commit:e=>reactDom.flushSync(e),getElement:()=>o?.current??null}),connectTrigger:e=>{o=e;}}}
|
|
1
|
+
'use strict';var chunkKQSBORXP_cjs=require('./chunk-KQSBORXP.cjs'),chunkCYGYUQUK_cjs=require('./chunk-CYGYUQUK.cjs'),ne=require('react'),reactDom=require('react-dom'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ne__default=/*#__PURE__*/_interopDefault(ne);var Q=t=>{let o;return {controller:chunkKQSBORXP_cjs.j(t,{commit:e=>reactDom.flushSync(e),getElement:()=>o?.current??null}),connectTrigger:e=>{o=e;}}},$=(t={})=>{let o=ne.useRef(null),[r]=ne.useState(()=>Q(t)),{controller:e}=r,n=ne.useRef(t),s=ne.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return ne.useLayoutEffect(()=>{let i=Object.fromEntries(Object.keys(n.current).filter(l=>!(l in t)).map(l=>[l,void 0]));e.updateOptions({...i,...t}),n.current=t;}),ne.useLayoutEffect(()=>(r.connectTrigger(o),e.mount()),[e,r]),{...s,ref:o,setTheme:e.setTheme,setColorTheme:e.setColorTheme,switchTheme:e.switchTheme,switchColorTheme:e.switchColorTheme,toggleTheme:e.toggleTheme,toggleLightTheme:e.toggleLightTheme,toggleDarkTheme:e.toggleDarkTheme,toggleColorTheme:e.toggleColorTheme,createColorThemeToggle:e.createColorThemeToggle,isColorThemeActive:e.isColorThemeActive}};var ee=()=>()=>{},te=()=>true,oe=()=>false,M=()=>ne.useSyncExternalStore(ee,te,oe);function m(t){return JSON.stringify(t).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var S=ne.createContext(null);var v=ne.createContext(void 0),ie=(t,o,r,e,n,s,i)=>`
|
|
2
2
|
(function() {
|
|
3
3
|
try {
|
|
4
4
|
var theme = localStorage.getItem(${m(t)}) || ${m(r)};
|
|
@@ -23,4 +23,4 @@
|
|
|
23
23
|
console.warn('Theme pre-hydration script failed:', e);
|
|
24
24
|
}
|
|
25
25
|
})();
|
|
26
|
-
`,E=ne__default.default.memo(({storageKey:t,colorStorageKey:o,defaultTheme:r,defaultColorTheme:e,attribute:n,globalClassName:s,colorThemePrefix:i,nonce:l})=>{let T=ie(t,o,r,e,n,s,i);return jsxRuntime.jsx("script",{nonce:l,suppressHydrationWarning:true,dangerouslySetInnerHTML:{__html:T}})});E.displayName="ThemePreHydrationScript";var we=({children:t,themes:o=["light","dark","system"],colorThemes:r=["default"],defaultTheme:e="system",defaultColorTheme:n=r[0]??"default",animationType:s="circle",clipPathDirection:i,animationPosition:l,logo:T,logoLight:D,logoDark:j,logoWidth:B,logoHeight:V,gradientWidth:G,duration:z=400,storageKey:u=chunkCYGYUQUK_cjs.a,colorStorageKey:d=chunkCYGYUQUK_cjs.b,attribute:g="class",globalClassName:p=chunkCYGYUQUK_cjs.c,colorThemePrefix:
|
|
26
|
+
`,E=ne__default.default.memo(({storageKey:t,colorStorageKey:o,defaultTheme:r,defaultColorTheme:e,attribute:n,globalClassName:s,colorThemePrefix:i,nonce:l})=>{let T=ie(t,o,r,e,n,s,i);return jsxRuntime.jsx("script",{nonce:l,suppressHydrationWarning:true,dangerouslySetInnerHTML:{__html:T}})});E.displayName="ThemePreHydrationScript";var we=({children:t,themes:o=["light","dark","system"],colorThemes:r=["default"],defaultTheme:e="system",defaultColorTheme:n=r[0]??"default",animationType:s="circle",clipPathDirection:i,animationPosition:l,logo:T,logoLight:D,logoDark:j,logoWidth:B,logoHeight:V,gradientWidth:G,duration:z=400,storageKey:u=chunkCYGYUQUK_cjs.a,colorStorageKey:d=chunkCYGYUQUK_cjs.b,attribute:g="class",globalClassName:p=chunkCYGYUQUK_cjs.c,colorThemePrefix:y=chunkCYGYUQUK_cjs.d,nonce:P,disableAnimationOnInit:U=true,disablePreHydrationScript:w=false})=>{let f=M(),c=$({themes:o,colorThemes:r,defaultTheme:e,defaultColorTheme:n,animationType:s,clipPathDirection:i,animationPosition:l,...chunkKQSBORXP_cjs.c({logo:T,logoLight:D,logoDark:j}),logoWidth:B,logoHeight:V,gradientWidth:G,duration:z,storageKey:u,colorStorageKey:d,globalClassName:g==="class"?p:void 0,colorThemePrefix:y}),C=ne.useCallback(async(a,x=false)=>{!f&&U?c.setTheme(a):await c.switchTheme(a,x);},[f,U,c]),W=ne.useCallback((a,x)=>C(a,{element:x}),[C]),Y=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(!f){let a={themes:o,colorThemes:r,mounted:false,ref:{current:null},theme:e,colorTheme:n,resolvedTheme:e==="dark"?"dark":"light",systemTheme:"light",setTheme:()=>{},setColorTheme:()=>{},switchTheme:async()=>{},switchThemeFromElement:async()=>{},switchColorTheme:async()=>{},toggleTheme:async()=>{},toggleLightTheme:async()=>{},toggleDarkTheme:async()=>{},toggleColorTheme:async()=>{},createColorThemeToggle:()=>async()=>{},isColorThemeActive:()=>false};return jsxRuntime.jsx(v.Provider,{value:a,children:jsxRuntime.jsxs(S.Provider,{value:a,children:[!w&&jsxRuntime.jsx(E,{storageKey:u,colorStorageKey:d,defaultTheme:e,defaultColorTheme:n,attribute:g,globalClassName:p,colorThemePrefix:y,nonce:P}),t]})})}let I={...c,systemTheme:Y,switchTheme:C,switchThemeFromElement:W};return jsxRuntime.jsx(v.Provider,{value:I,children:jsxRuntime.jsxs(S.Provider,{value:I,children:[!w&&jsxRuntime.jsx(E,{storageKey:u,colorStorageKey:d,defaultTheme:e,defaultColorTheme:n,attribute:g,globalClassName:p,colorThemePrefix:y,nonce:P}),t]})})},Ie=()=>{let t=ne.useContext(v);if(t===void 0)throw new Error("useNextUITheme must be used within a NextUIThemeProvider");return t};exports.a=$;exports.b=m;exports.c=S;exports.d=M;exports.e=we;exports.f=Ie;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {c as c$1,j}from'./chunk-EKVKQZNN.js';import {d,c,b,a}from'./chunk-NDNCNR4X.js';import ne,{createContext,useRef,useState,useSyncExternalStore,useLayoutEffect,useCallback,useContext}from'react';import {flushSync}from'react-dom';import {jsx,jsxs}from'react/jsx-runtime';var Q=t=>{let o;return {controller:j(t,{commit:e=>flushSync(e),getElement:()=>o?.current??null}),connectTrigger:e=>{o=e;}}}
|
|
1
|
+
import {c as c$1,j}from'./chunk-EKVKQZNN.js';import {d,c,b,a}from'./chunk-NDNCNR4X.js';import ne,{createContext,useRef,useState,useSyncExternalStore,useLayoutEffect,useCallback,useContext}from'react';import {flushSync}from'react-dom';import {jsx,jsxs}from'react/jsx-runtime';var Q=t=>{let o;return {controller:j(t,{commit:e=>flushSync(e),getElement:()=>o?.current??null}),connectTrigger:e=>{o=e;}}},$=(t={})=>{let o=useRef(null),[r]=useState(()=>Q(t)),{controller:e}=r,n=useRef(t),s=useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return useLayoutEffect(()=>{let i=Object.fromEntries(Object.keys(n.current).filter(l=>!(l in t)).map(l=>[l,void 0]));e.updateOptions({...i,...t}),n.current=t;}),useLayoutEffect(()=>(r.connectTrigger(o),e.mount()),[e,r]),{...s,ref:o,setTheme:e.setTheme,setColorTheme:e.setColorTheme,switchTheme:e.switchTheme,switchColorTheme:e.switchColorTheme,toggleTheme:e.toggleTheme,toggleLightTheme:e.toggleLightTheme,toggleDarkTheme:e.toggleDarkTheme,toggleColorTheme:e.toggleColorTheme,createColorThemeToggle:e.createColorThemeToggle,isColorThemeActive:e.isColorThemeActive}};var ee=()=>()=>{},te=()=>true,oe=()=>false,M=()=>useSyncExternalStore(ee,te,oe);function m(t){return JSON.stringify(t).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var S=createContext(null);var v=createContext(void 0),ie=(t,o,r,e,n,s,i)=>`
|
|
2
2
|
(function() {
|
|
3
3
|
try {
|
|
4
4
|
var theme = localStorage.getItem(${m(t)}) || ${m(r)};
|
|
@@ -23,4 +23,4 @@ import {c as c$1,j}from'./chunk-EKVKQZNN.js';import {d,c,b,a}from'./chunk-NDNCNR
|
|
|
23
23
|
console.warn('Theme pre-hydration script failed:', e);
|
|
24
24
|
}
|
|
25
25
|
})();
|
|
26
|
-
`,E=ne.memo(({storageKey:t,colorStorageKey:o,defaultTheme:r,defaultColorTheme:e,attribute:n,globalClassName:s,colorThemePrefix:i,nonce:l})=>{let T=ie(t,o,r,e,n,s,i);return jsx("script",{nonce:l,suppressHydrationWarning:true,dangerouslySetInnerHTML:{__html:T}})});E.displayName="ThemePreHydrationScript";var we=({children:t,themes:o=["light","dark","system"],colorThemes:r=["default"],defaultTheme:e="system",defaultColorTheme:n=r[0]??"default",animationType:s="circle",clipPathDirection:i,animationPosition:l,logo:T,logoLight:D,logoDark:j,logoWidth:B,logoHeight:V,gradientWidth:G,duration:z=400,storageKey:u=a,colorStorageKey:d$1=b,attribute:g="class",globalClassName:p=c,colorThemePrefix:
|
|
26
|
+
`,E=ne.memo(({storageKey:t,colorStorageKey:o,defaultTheme:r,defaultColorTheme:e,attribute:n,globalClassName:s,colorThemePrefix:i,nonce:l})=>{let T=ie(t,o,r,e,n,s,i);return jsx("script",{nonce:l,suppressHydrationWarning:true,dangerouslySetInnerHTML:{__html:T}})});E.displayName="ThemePreHydrationScript";var we=({children:t,themes:o=["light","dark","system"],colorThemes:r=["default"],defaultTheme:e="system",defaultColorTheme:n=r[0]??"default",animationType:s="circle",clipPathDirection:i,animationPosition:l,logo:T,logoLight:D,logoDark:j,logoWidth:B,logoHeight:V,gradientWidth:G,duration:z=400,storageKey:u=a,colorStorageKey:d$1=b,attribute:g="class",globalClassName:p=c,colorThemePrefix:y=d,nonce:P,disableAnimationOnInit:U=true,disablePreHydrationScript:w=false})=>{let f=M(),c=$({themes:o,colorThemes:r,defaultTheme:e,defaultColorTheme:n,animationType:s,clipPathDirection:i,animationPosition:l,...c$1({logo:T,logoLight:D,logoDark:j}),logoWidth:B,logoHeight:V,gradientWidth:G,duration:z,storageKey:u,colorStorageKey:d$1,globalClassName:g==="class"?p:void 0,colorThemePrefix:y}),C=useCallback(async(a,x=false)=>{!f&&U?c.setTheme(a):await c.switchTheme(a,x);},[f,U,c]),W=useCallback((a,x)=>C(a,{element:x}),[C]),Y=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(!f){let a={themes:o,colorThemes:r,mounted:false,ref:{current:null},theme:e,colorTheme:n,resolvedTheme:e==="dark"?"dark":"light",systemTheme:"light",setTheme:()=>{},setColorTheme:()=>{},switchTheme:async()=>{},switchThemeFromElement:async()=>{},switchColorTheme:async()=>{},toggleTheme:async()=>{},toggleLightTheme:async()=>{},toggleDarkTheme:async()=>{},toggleColorTheme:async()=>{},createColorThemeToggle:()=>async()=>{},isColorThemeActive:()=>false};return jsx(v.Provider,{value:a,children:jsxs(S.Provider,{value:a,children:[!w&&jsx(E,{storageKey:u,colorStorageKey:d$1,defaultTheme:e,defaultColorTheme:n,attribute:g,globalClassName:p,colorThemePrefix:y,nonce:P}),t]})})}let I={...c,systemTheme:Y,switchTheme:C,switchThemeFromElement:W};return jsx(v.Provider,{value:I,children:jsxs(S.Provider,{value:I,children:[!w&&jsx(E,{storageKey:u,colorStorageKey:d$1,defaultTheme:e,defaultColorTheme:n,attribute:g,globalClassName:p,colorThemePrefix:y,nonce:P}),t]})})},Ie=()=>{let t=useContext(v);if(t===void 0)throw new Error("useNextUITheme must be used within a NextUIThemeProvider");return t};export{$ as a,m as b,S as c,M as d,we as e,Ie as f};
|
|
@@ -58,7 +58,7 @@ type NextUIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
58
58
|
/** Default color theme to use */
|
|
59
59
|
defaultColorTheme?: ColorTheme;
|
|
60
60
|
/** Animation type for theme transitions */
|
|
61
|
-
animationType?: ThemeAnimationType
|
|
61
|
+
animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
|
|
62
62
|
/** Animation duration in milliseconds */
|
|
63
63
|
duration?: number;
|
|
64
64
|
/** Storage key for theme preference */
|
|
@@ -58,7 +58,7 @@ type NextUIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
58
58
|
/** Default color theme to use */
|
|
59
59
|
defaultColorTheme?: ColorTheme;
|
|
60
60
|
/** Animation type for theme transitions */
|
|
61
|
-
animationType?: ThemeAnimationType
|
|
61
|
+
animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
|
|
62
62
|
/** Animation duration in milliseconds */
|
|
63
63
|
duration?: number;
|
|
64
64
|
/** Storage key for theme preference */
|
package/dist/next/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var chunk4UXANDJ5_cjs=require('../chunk-4UXANDJ5.cjs');require('../chunk-KQSBORXP.cjs'),require('../chunk-I5GA5T23.cjs'),require('../chunk-CYGYUQUK.cjs');Object.defineProperty(exports,"NextUIThemeProvider",{enumerable:true,get:function(){return chunk4UXANDJ5_cjs.e}});Object.defineProperty(exports,"useNextUITheme",{enumerable:true,get:function(){return chunk4UXANDJ5_cjs.f}});
|
package/dist/next/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { N as NextUIThemeContextType, b as NextUIThemeProvider, c as NextUIThemeProviderProps, u as useNextUITheme } from '../index-
|
|
1
|
+
export { N as NextUIThemeContextType, b as NextUIThemeProvider, c as NextUIThemeProviderProps, u as useNextUITheme } from '../index-DqlTGyMr.cjs';
|
|
2
2
|
import 'react';
|
|
3
3
|
import '../types-CrR56NLm.cjs';
|
|
4
4
|
import '../controller-83zmHd-p.cjs';
|
package/dist/next/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { N as NextUIThemeContextType, b as NextUIThemeProvider, c as NextUIThemeProviderProps, u as useNextUITheme } from '../index-
|
|
1
|
+
export { N as NextUIThemeContextType, b as NextUIThemeProvider, c as NextUIThemeProviderProps, u as useNextUITheme } from '../index-Dn3XRBX1.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import '../types-CrR56NLm.js';
|
|
4
4
|
import '../controller-DnMwV2nl.js';
|
package/dist/next/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export{e as NextUIThemeProvider,f as useNextUITheme}from'../chunk-
|
|
2
|
+
export{e as NextUIThemeProvider,f as useNextUITheme}from'../chunk-C4YNAGUP.js';import'../chunk-EKVKQZNN.js';import'../chunk-CY5E6WU4.js';import'../chunk-NDNCNR4X.js';
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var chunk4UXANDJ5_cjs=require('../chunk-4UXANDJ5.cjs'),chunkKQSBORXP_cjs=require('../chunk-KQSBORXP.cjs'),chunkI5GA5T23_cjs=require('../chunk-I5GA5T23.cjs'),chunkCYGYUQUK_cjs=require('../chunk-CYGYUQUK.cjs'),Pe=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Pe__default=/*#__PURE__*/_interopDefault(Pe);var J=async(t,h,o)=>{try{await t?.(h);}catch(i){let r=i instanceof Error?i:new Error(String(i));try{o?o(r):console.error("Theme server notification failed:",r);}catch(c){console.error("Theme server error handler failed:",c);}}};var Q=Pe.createContext(void 0),Le=(t,h,o,i,r,c,u)=>`
|
|
3
3
|
(function() {
|
|
4
4
|
try {
|
|
5
|
-
var theme = localStorage.getItem(${
|
|
6
|
-
var colorTheme = localStorage.getItem(${
|
|
5
|
+
var theme = localStorage.getItem(${chunk4UXANDJ5_cjs.b(t)}) || ${chunk4UXANDJ5_cjs.b(o)};
|
|
6
|
+
var colorTheme = localStorage.getItem(${chunk4UXANDJ5_cjs.b(h)}) || ${chunk4UXANDJ5_cjs.b(i)};
|
|
7
7
|
var el = document.documentElement;
|
|
8
8
|
var resolved;
|
|
9
9
|
if (theme === 'system') {
|
|
10
|
-
if (${
|
|
11
|
-
el.classList.remove(${
|
|
10
|
+
if (${chunk4UXANDJ5_cjs.b(u)} === 'css') {
|
|
11
|
+
el.classList.remove(${chunk4UXANDJ5_cjs.b(r)});
|
|
12
12
|
el.classList.remove('auto');
|
|
13
13
|
el.classList.remove('system');
|
|
14
14
|
el.classList.add('system');
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
} else {
|
|
17
17
|
resolved = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
18
18
|
if (resolved === 'dark') {
|
|
19
|
-
el.classList.add(${
|
|
19
|
+
el.classList.add(${chunk4UXANDJ5_cjs.b(r)});
|
|
20
20
|
} else {
|
|
21
|
-
el.classList.remove(${
|
|
21
|
+
el.classList.remove(${chunk4UXANDJ5_cjs.b(r)});
|
|
22
22
|
}
|
|
23
23
|
el.classList.remove('system');
|
|
24
24
|
el.classList.remove('auto');
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
el.classList.remove('system');
|
|
30
30
|
el.classList.remove('auto');
|
|
31
31
|
if (resolved === 'dark') {
|
|
32
|
-
el.classList.add(${
|
|
32
|
+
el.classList.add(${chunk4UXANDJ5_cjs.b(r)});
|
|
33
33
|
} else {
|
|
34
|
-
el.classList.remove(${
|
|
34
|
+
el.classList.remove(${chunk4UXANDJ5_cjs.b(r)});
|
|
35
35
|
}
|
|
36
36
|
el.style.colorScheme = resolved;
|
|
37
37
|
}
|
|
38
38
|
if (colorTheme && colorTheme !== 'default') {
|
|
39
|
-
el.classList.add(${
|
|
39
|
+
el.classList.add(${chunk4UXANDJ5_cjs.b(c)} + colorTheme);
|
|
40
40
|
}
|
|
41
41
|
} catch (e) {
|
|
42
42
|
console.warn('Theme pre-hydration script failed:', e);
|
|
43
43
|
}
|
|
44
44
|
})();
|
|
45
|
-
`,ne=Pe__default.default.memo(({storageKey:t=chunkCYGYUQUK_cjs.a,colorStorageKey:h=chunkCYGYUQUK_cjs.b,defaultTheme:o="system",defaultColorTheme:i="default",globalClassName:r=chunkCYGYUQUK_cjs.c,colorThemePrefix:c=chunkCYGYUQUK_cjs.d,nonce:u,systemThemeMode:v="js"})=>{let S=
|
|
45
|
+
`,ne=Pe__default.default.memo(({storageKey:t=chunkCYGYUQUK_cjs.a,colorStorageKey:h=chunkCYGYUQUK_cjs.b,defaultTheme:o="system",defaultColorTheme:i="default",globalClassName:r=chunkCYGYUQUK_cjs.c,colorThemePrefix:c=chunkCYGYUQUK_cjs.d,nonce:u,systemThemeMode:v="js"})=>{let S=Le(t,h,o,i,r,c,v);return jsxRuntime.jsx("script",{nonce:u,suppressHydrationWarning:true,dangerouslySetInnerHTML:{__html:S}})});ne.displayName="TanStackStartThemeScript";var Re=({children:t,themes:h=["light","dark","system"],colorThemes:o=["default"],defaultTheme:i="system",defaultColorTheme:r=o[0]??"default",animationType:c="circle",clipPathDirection:u,animationPosition:v,logo:S,logoLight:L,logoDark:R,logoWidth:O,logoHeight:_,gradientWidth:D,duration:F=400,storageKey:I=chunkCYGYUQUK_cjs.a,colorStorageKey:C=chunkCYGYUQUK_cjs.b,globalClassName:V=chunkCYGYUQUK_cjs.c,colorThemePrefix:P=chunkCYGYUQUK_cjs.d,serverTheme:g,serverColorTheme:d,systemThemeMode:n="css",onServerThemeChange:a,onServerColorThemeChange:X,onServerError:N})=>{let w=chunk4UXANDJ5_cjs.d(),k=g!==void 0,x=k?g==="system"?"system":g:void 0,T=chunk4UXANDJ5_cjs.a({themes:h,colorThemes:o,defaultTheme:i,defaultColorTheme:r,animationType:c,clipPathDirection:u,animationPosition:v,...chunkKQSBORXP_cjs.c({logo:S,logoLight:L,logoDark:R}),logoWidth:O,logoHeight:_,gradientWidth:D,duration:F,storageKey:I,colorStorageKey:C,globalClassName:V,colorThemePrefix:P,systemThemeMode:n,initialTheme:x,initialColorTheme:d,onThemeChange:e=>{J(a,e,N);},onColorThemeChange:e=>{J(X,e,N);}}),$=Pe.useRef(false);Pe.useEffect(()=>{if(!(!k||!w||$.current)){$.current=true;try{x&&chunkKQSBORXP_cjs.g(x,I),d&&chunkKQSBORXP_cjs.i(d,C);}catch(e){console.warn("Unable to persist the initial server theme:",e);}}},[k,w,x,d,I,C]);let p=T.setTheme,m=T.setColorTheme,s=(e=false)=>w?e:e===true||e===false?true:{...e,animationOff:true},K=(e,y)=>T.switchTheme(e,s(y)),he=e=>T.toggleTheme(s(e)),ae=e=>T.toggleLightTheme(s(e)),Te=e=>T.toggleDarkTheme(s(e)),Z=(e,y)=>T.switchColorTheme(e,s(y)),le=(e,y)=>K(e,{element:y}),j=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",ee=k?g==="dark"?"dark":g==="system"?j:"light":i==="dark"?"dark":"light";if(!w){let e={themes:h,colorThemes:o,mounted:false,ref:{current:null},theme:x??i,colorTheme:d??r,resolvedTheme:ee,systemTheme:"light",isHydrated:false,setTheme:p,setColorTheme:m,switchTheme:async y=>p(y),switchThemeFromElement:async y=>p(y),switchColorTheme:Z,toggleTheme:async()=>{p(ee==="dark"?"light":"dark");},toggleLightTheme:async()=>p("light"),toggleDarkTheme:async()=>p("dark"),toggleColorTheme:T.toggleColorTheme,createColorThemeToggle:T.createColorThemeToggle,isColorThemeActive:T.isColorThemeActive};return jsxRuntime.jsx(Q.Provider,{value:e,children:jsxRuntime.jsx(chunk4UXANDJ5_cjs.c.Provider,{value:e,children:t})})}let te={...T,systemTheme:j,isHydrated:true,setTheme:p,setColorTheme:m,switchTheme:K,switchThemeFromElement:le,switchColorTheme:Z,toggleTheme:he,toggleLightTheme:ae,toggleDarkTheme:Te};return jsxRuntime.jsx(Q.Provider,{value:te,children:jsxRuntime.jsx(chunk4UXANDJ5_cjs.c.Provider,{value:te,children:t})})},Oe=()=>{let t=Pe.useContext(Q);if(t===void 0)throw new Error("useTanStackUITheme must be used within a TanStackUIThemeProvider");return t};var ie=Pe.createContext(void 0),Fe=({children:t,themes:h=["light","dark","system"],colorThemes:o=["default"],defaultTheme:i="system",defaultColorTheme:r=o[0]??"default",animationType:c="circle",clipPathDirection:u,animationPosition:v,logo:S,logoLight:L,logoDark:R,logoWidth:O,logoHeight:_,gradientWidth:D,duration:F=400,attribute:I="class",disableTransitionOnChange:C=false,storageKey:V="ui-theme",colorStorageKey:P="ui-color-theme",globalClassName:g="dark",colorThemePrefix:d="theme-"})=>{let n=chunk4UXANDJ5_cjs.a({themes:h,colorThemes:o,defaultTheme:i,defaultColorTheme:r,animationType:c,clipPathDirection:u,animationPosition:v,...chunkKQSBORXP_cjs.c({logo:S,logoLight:L,logoDark:R}),logoWidth:O,logoHeight:_,gradientWidth:D,duration:F,storageKey:V,colorStorageKey:P,globalClassName:I==="class"?g:void 0,colorThemePrefix:d}),a=Pe.useCallback(()=>{if(!C)return ()=>{};let m=document.createElement("style");return m.textContent="*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}",document.head.appendChild(m),window.getComputedStyle(document.body),()=>{setTimeout(()=>{document.head.removeChild(m);},1);}},[C]),X=Pe.useCallback(m=>{let s=a();n.setTheme(m),s();},[n,a]),N=Pe.useCallback(async(m,s=false)=>{let K=a();try{await n.switchTheme(m,s);}finally{K();}},[n,a]),w=Pe.useCallback(async(m=false)=>{let s=a();try{await n.toggleTheme(m);}finally{s();}},[n,a]),k=Pe.useCallback(async(m=false)=>{let s=a();try{await n.toggleLightTheme(m);}finally{s();}},[n,a]),x=Pe.useCallback(async(m=false)=>{let s=a();try{await n.toggleDarkTheme(m);}finally{s();}},[n,a]),T=(m,s)=>N(m,{element:s}),$=chunkI5GA5T23_cjs.c(),p={...n,systemTheme:$,setTheme:X,switchTheme:N,switchThemeFromElement:T,toggleTheme:w,toggleLightTheme:k,toggleDarkTheme:x};return jsxRuntime.jsx(ie.Provider,{value:p,children:jsxRuntime.jsx(chunk4UXANDJ5_cjs.c.Provider,{value:p,children:t})})},Ve=()=>{let t=Pe.useContext(ie);if(t===void 0)throw new Error("useViteUITheme must be used within a ViteUIThemeProvider");return t};var se=Pe.createContext(void 0),Me=({children:t,themes:h=["light","dark","system"],colorThemes:o=["default"],defaultTheme:i="system",defaultColorTheme:r=o[0]??"default",animationType:c="circle",clipPathDirection:u,animationPosition:v,logo:S,logoLight:L,logoDark:R,logoWidth:O,logoHeight:_,gradientWidth:D,duration:F=400,storageKey:I,colorStorageKey:C})=>{let V=chunk4UXANDJ5_cjs.d(),P=chunk4UXANDJ5_cjs.a({themes:h,colorThemes:o,defaultTheme:i,defaultColorTheme:r,animationType:c,clipPathDirection:u,animationPosition:v,...chunkKQSBORXP_cjs.c({logo:S,logoLight:L,logoDark:R}),logoWidth:O,logoHeight:_,gradientWidth:D,duration:F,storageKey:I,colorStorageKey:C}),g=(n,a)=>P.switchTheme(n,{element:a});if(!V){let n={themes:h,colorThemes:o,mounted:false,systemTheme:"light",ref:{current:null},theme:i,colorTheme:r,resolvedTheme:i==="dark"?"dark":"light",setTheme:()=>{},setColorTheme:()=>{},switchTheme:async()=>{},switchThemeFromElement:async()=>{},switchColorTheme:async()=>{},toggleTheme:async()=>{},toggleLightTheme:async()=>{},toggleDarkTheme:async()=>{},toggleColorTheme:async()=>{},createColorThemeToggle:()=>async()=>{},isColorThemeActive:()=>false};return jsxRuntime.jsx(se.Provider,{value:n,children:jsxRuntime.jsx(chunk4UXANDJ5_cjs.c.Provider,{value:n,children:t})})}let d={...P,switchThemeFromElement:g};return jsxRuntime.jsx(se.Provider,{value:d,children:jsxRuntime.jsx(chunk4UXANDJ5_cjs.c.Provider,{value:d,children:t})})},be=()=>{let t=Pe.useContext(chunk4UXANDJ5_cjs.c);if(t===null)throw new Error("useUITheme must be used within a UIThemeProvider");return {...t,switchThemeFromElement:(h,o)=>t.switchTheme(h,{element:o})}};Object.defineProperty(exports,"NextUIThemeProvider",{enumerable:true,get:function(){return chunk4UXANDJ5_cjs.e}});Object.defineProperty(exports,"useHydrated",{enumerable:true,get:function(){return chunk4UXANDJ5_cjs.d}});Object.defineProperty(exports,"useNextUITheme",{enumerable:true,get:function(){return chunk4UXANDJ5_cjs.f}});Object.defineProperty(exports,"useTheme",{enumerable:true,get:function(){return chunk4UXANDJ5_cjs.a}});Object.defineProperty(exports,"TRANSITION_DIRECTIONS",{enumerable:true,get:function(){return chunkKQSBORXP_cjs.b}});Object.defineProperty(exports,"ThemeAnimationType",{enumerable:true,get:function(){return chunkKQSBORXP_cjs.a}});Object.defineProperty(exports,"preloadThemeLogo",{enumerable:true,get:function(){return chunkKQSBORXP_cjs.d}});Object.defineProperty(exports,"getSystemTheme",{enumerable:true,get:function(){return chunkI5GA5T23_cjs.c}});Object.defineProperty(exports,"injectBaseStyles",{enumerable:true,get:function(){return chunkI5GA5T23_cjs.a}});Object.defineProperty(exports,"prefersReducedMotion",{enumerable:true,get:function(){return chunkI5GA5T23_cjs.g}});Object.defineProperty(exports,"resolveTheme",{enumerable:true,get:function(){return chunkI5GA5T23_cjs.d}});Object.defineProperty(exports,"resolveThemeForServer",{enumerable:true,get:function(){return chunkI5GA5T23_cjs.e}});Object.defineProperty(exports,"supportsViewTransitions",{enumerable:true,get:function(){return chunkI5GA5T23_cjs.f}});Object.defineProperty(exports,"COLOR_STORAGE_KEY",{enumerable:true,get:function(){return chunkCYGYUQUK_cjs.b}});Object.defineProperty(exports,"COLOR_THEME_PREFIX",{enumerable:true,get:function(){return chunkCYGYUQUK_cjs.d}});Object.defineProperty(exports,"DEFAULT_BLUR_AMOUNT",{enumerable:true,get:function(){return chunkCYGYUQUK_cjs.g}});Object.defineProperty(exports,"DEFAULT_DURATION",{enumerable:true,get:function(){return chunkCYGYUQUK_cjs.e}});Object.defineProperty(exports,"DEFAULT_EASING",{enumerable:true,get:function(){return chunkCYGYUQUK_cjs.f}});Object.defineProperty(exports,"DEFAULT_STYLE_ID",{enumerable:true,get:function(){return chunkCYGYUQUK_cjs.h}});Object.defineProperty(exports,"GLOBAL_CLASS_NAME",{enumerable:true,get:function(){return chunkCYGYUQUK_cjs.c}});Object.defineProperty(exports,"STORAGE_KEY",{enumerable:true,get:function(){return chunkCYGYUQUK_cjs.a}});exports.TanStackStartThemeScript=ne;exports.TanStackUIThemeProvider=Re;exports.UIThemeProvider=Me;exports.ViteUIThemeProvider=Fe;exports.useTanStackUITheme=Oe;exports.useUITheme=be;exports.useViteUITheme=Ve;
|
package/dist/react/index.d.cts
CHANGED
|
@@ -2,8 +2,8 @@ export { p as preloadThemeLogo } from '../logo-DtwtRv4y.cjs';
|
|
|
2
2
|
import { c as Theme, C as ColorTheme, T as ThemeAnimationOptions, a as ThemeAnimationType } from '../types-CrR56NLm.cjs';
|
|
3
3
|
export { A as AnimationConfig, e as AnimationPosition, S as SlideDirection, f as TRANSITION_DIRECTIONS, d as ThemeConfig, g as ThemeControlTransitionProps, h as ThemeLogoOptions, b as ThemeState, i as TransitionDirection } from '../types-CrR56NLm.cjs';
|
|
4
4
|
export { C as COLOR_STORAGE_KEY, a as COLOR_THEME_PREFIX, D as DEFAULT_BLUR_AMOUNT, b as DEFAULT_DURATION, c as DEFAULT_EASING, d as DEFAULT_STYLE_ID, G as GLOBAL_CLASS_NAME, S as STORAGE_KEY, o as getSystemTheme, p as injectBaseStyles, q as prefersReducedMotion, s as resolveTheme, r as resolveThemeForServer, t as supportsViewTransitions } from '../constants-9M8X-rnX.cjs';
|
|
5
|
-
import { U as UseThemeProps, a as UseThemeReturn } from '../index-
|
|
6
|
-
export { N as NextUIThemeContextType, b as NextUIThemeProvider, c as NextUIThemeProviderProps, u as useNextUITheme } from '../index-
|
|
5
|
+
import { U as UseThemeProps, a as UseThemeReturn } from '../index-DqlTGyMr.cjs';
|
|
6
|
+
export { N as NextUIThemeContextType, b as NextUIThemeProvider, c as NextUIThemeProviderProps, u as useNextUITheme } from '../index-DqlTGyMr.cjs';
|
|
7
7
|
import React, { ReactNode } from 'react';
|
|
8
8
|
import { S as SystemThemeMode } from '../controller-83zmHd-p.cjs';
|
|
9
9
|
export { C as ColorThemeToggle, f as ThemeTransitionInput, g as ThemeTransitionOptions } from '../controller-83zmHd-p.cjs';
|
|
@@ -36,7 +36,7 @@ type TanStackUIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
36
36
|
/** Default color theme to use */
|
|
37
37
|
defaultColorTheme?: ColorTheme;
|
|
38
38
|
/** Animation type for theme transitions */
|
|
39
|
-
animationType?: ThemeAnimationType
|
|
39
|
+
animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
|
|
40
40
|
/** Animation duration in milliseconds */
|
|
41
41
|
duration?: number;
|
|
42
42
|
/** Storage key for theme preference */
|
|
@@ -188,7 +188,7 @@ type ViteUIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
188
188
|
/** Default color theme to use */
|
|
189
189
|
defaultColorTheme?: ColorTheme;
|
|
190
190
|
/** Animation type for theme transitions */
|
|
191
|
-
animationType?: ThemeAnimationType
|
|
191
|
+
animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
|
|
192
192
|
/** Animation duration in milliseconds */
|
|
193
193
|
duration?: number;
|
|
194
194
|
/** Attribute to use for theme ('class' or 'data-theme') */
|
|
@@ -246,7 +246,7 @@ type UIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
246
246
|
/** Default color theme to use */
|
|
247
247
|
defaultColorTheme?: ColorTheme;
|
|
248
248
|
/** Animation type for theme transitions */
|
|
249
|
-
animationType?: ThemeAnimationType
|
|
249
|
+
animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
|
|
250
250
|
/** Animation duration in milliseconds */
|
|
251
251
|
duration?: number;
|
|
252
252
|
/** Storage key for theme */
|
package/dist/react/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export { p as preloadThemeLogo } from '../logo-DtwtRv4y.js';
|
|
|
2
2
|
import { c as Theme, C as ColorTheme, T as ThemeAnimationOptions, a as ThemeAnimationType } from '../types-CrR56NLm.js';
|
|
3
3
|
export { A as AnimationConfig, e as AnimationPosition, S as SlideDirection, f as TRANSITION_DIRECTIONS, d as ThemeConfig, g as ThemeControlTransitionProps, h as ThemeLogoOptions, b as ThemeState, i as TransitionDirection } from '../types-CrR56NLm.js';
|
|
4
4
|
export { C as COLOR_STORAGE_KEY, a as COLOR_THEME_PREFIX, D as DEFAULT_BLUR_AMOUNT, b as DEFAULT_DURATION, c as DEFAULT_EASING, d as DEFAULT_STYLE_ID, G as GLOBAL_CLASS_NAME, S as STORAGE_KEY, o as getSystemTheme, p as injectBaseStyles, q as prefersReducedMotion, s as resolveTheme, r as resolveThemeForServer, t as supportsViewTransitions } from '../constants-PAa1nGZ0.js';
|
|
5
|
-
import { U as UseThemeProps, a as UseThemeReturn } from '../index-
|
|
6
|
-
export { N as NextUIThemeContextType, b as NextUIThemeProvider, c as NextUIThemeProviderProps, u as useNextUITheme } from '../index-
|
|
5
|
+
import { U as UseThemeProps, a as UseThemeReturn } from '../index-Dn3XRBX1.js';
|
|
6
|
+
export { N as NextUIThemeContextType, b as NextUIThemeProvider, c as NextUIThemeProviderProps, u as useNextUITheme } from '../index-Dn3XRBX1.js';
|
|
7
7
|
import React, { ReactNode } from 'react';
|
|
8
8
|
import { S as SystemThemeMode } from '../controller-DnMwV2nl.js';
|
|
9
9
|
export { C as ColorThemeToggle, f as ThemeTransitionInput, g as ThemeTransitionOptions } from '../controller-DnMwV2nl.js';
|
|
@@ -36,7 +36,7 @@ type TanStackUIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
36
36
|
/** Default color theme to use */
|
|
37
37
|
defaultColorTheme?: ColorTheme;
|
|
38
38
|
/** Animation type for theme transitions */
|
|
39
|
-
animationType?: ThemeAnimationType
|
|
39
|
+
animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
|
|
40
40
|
/** Animation duration in milliseconds */
|
|
41
41
|
duration?: number;
|
|
42
42
|
/** Storage key for theme preference */
|
|
@@ -188,7 +188,7 @@ type ViteUIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
188
188
|
/** Default color theme to use */
|
|
189
189
|
defaultColorTheme?: ColorTheme;
|
|
190
190
|
/** Animation type for theme transitions */
|
|
191
|
-
animationType?: ThemeAnimationType
|
|
191
|
+
animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
|
|
192
192
|
/** Animation duration in milliseconds */
|
|
193
193
|
duration?: number;
|
|
194
194
|
/** Attribute to use for theme ('class' or 'data-theme') */
|
|
@@ -246,7 +246,7 @@ type UIThemeProviderProps = ThemeAnimationOptions & {
|
|
|
246
246
|
/** Default color theme to use */
|
|
247
247
|
defaultColorTheme?: ColorTheme;
|
|
248
248
|
/** Animation type for theme transitions */
|
|
249
|
-
animationType?: ThemeAnimationType
|
|
249
|
+
animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
|
|
250
250
|
/** Animation duration in milliseconds */
|
|
251
251
|
duration?: number;
|
|
252
252
|
/** Storage key for theme */
|
package/dist/react/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {b as b$1,d as d$1,a as a$1,c as c$2}from'../chunk-
|
|
2
|
+
import {b as b$1,d as d$1,a as a$1,c as c$2}from'../chunk-C4YNAGUP.js';export{e as NextUIThemeProvider,d as useHydrated,f as useNextUITheme,a as useTheme}from'../chunk-C4YNAGUP.js';import {c as c$1,g,i}from'../chunk-EKVKQZNN.js';export{b as TRANSITION_DIRECTIONS,a as ThemeAnimationType,d as preloadThemeLogo}from'../chunk-EKVKQZNN.js';import {c as c$3}from'../chunk-CY5E6WU4.js';export{c as getSystemTheme,a as injectBaseStyles,g as prefersReducedMotion,d as resolveTheme,e as resolveThemeForServer,f as supportsViewTransitions}from'../chunk-CY5E6WU4.js';import {a,b,c,d}from'../chunk-NDNCNR4X.js';export{b as COLOR_STORAGE_KEY,d as COLOR_THEME_PREFIX,g as DEFAULT_BLUR_AMOUNT,e as DEFAULT_DURATION,f as DEFAULT_EASING,h as DEFAULT_STYLE_ID,c as GLOBAL_CLASS_NAME,a as STORAGE_KEY}from'../chunk-NDNCNR4X.js';import Pe,{createContext,useRef,useEffect,useContext,useCallback}from'react';import {jsx}from'react/jsx-runtime';var J=async(t,h,o)=>{try{await t?.(h);}catch(i){let r=i instanceof Error?i:new Error(String(i));try{o?o(r):console.error("Theme server notification failed:",r);}catch(c){console.error("Theme server error handler failed:",c);}}};var Q=createContext(void 0),Le=(t,h,o,i,r,c,u)=>`
|
|
3
3
|
(function() {
|
|
4
4
|
try {
|
|
5
5
|
var theme = localStorage.getItem(${b$1(t)}) || ${b$1(o)};
|
|
@@ -42,4 +42,4 @@ import {b as b$1,d as d$1,a as a$1,c as c$2}from'../chunk-YGWVUGQI.js';export{e
|
|
|
42
42
|
console.warn('Theme pre-hydration script failed:', e);
|
|
43
43
|
}
|
|
44
44
|
})();
|
|
45
|
-
`,ne=Pe.memo(({storageKey:t=a,colorStorageKey:h=b,defaultTheme:o="system",defaultColorTheme:i="default",globalClassName:r=c,colorThemePrefix:c$1=d,nonce:u,systemThemeMode:v="js"})=>{let S=
|
|
45
|
+
`,ne=Pe.memo(({storageKey:t=a,colorStorageKey:h=b,defaultTheme:o="system",defaultColorTheme:i="default",globalClassName:r=c,colorThemePrefix:c$1=d,nonce:u,systemThemeMode:v="js"})=>{let S=Le(t,h,o,i,r,c$1,v);return jsx("script",{nonce:u,suppressHydrationWarning:true,dangerouslySetInnerHTML:{__html:S}})});ne.displayName="TanStackStartThemeScript";var Re=({children:t,themes:h=["light","dark","system"],colorThemes:o=["default"],defaultTheme:i$1="system",defaultColorTheme:r=o[0]??"default",animationType:c$3="circle",clipPathDirection:u,animationPosition:v,logo:S,logoLight:L,logoDark:R,logoWidth:O,logoHeight:_,gradientWidth:D,duration:F=400,storageKey:I=a,colorStorageKey:C=b,globalClassName:V=c,colorThemePrefix:P=d,serverTheme:g$1,serverColorTheme:d$2,systemThemeMode:n="css",onServerThemeChange:a$2,onServerColorThemeChange:X,onServerError:N})=>{let w=d$1(),k=g$1!==void 0,x=k?g$1==="system"?"system":g$1:void 0,T=a$1({themes:h,colorThemes:o,defaultTheme:i$1,defaultColorTheme:r,animationType:c$3,clipPathDirection:u,animationPosition:v,...c$1({logo:S,logoLight:L,logoDark:R}),logoWidth:O,logoHeight:_,gradientWidth:D,duration:F,storageKey:I,colorStorageKey:C,globalClassName:V,colorThemePrefix:P,systemThemeMode:n,initialTheme:x,initialColorTheme:d$2,onThemeChange:e=>{J(a$2,e,N);},onColorThemeChange:e=>{J(X,e,N);}}),$=useRef(false);useEffect(()=>{if(!(!k||!w||$.current)){$.current=true;try{x&&g(x,I),d$2&&i(d$2,C);}catch(e){console.warn("Unable to persist the initial server theme:",e);}}},[k,w,x,d$2,I,C]);let p=T.setTheme,m=T.setColorTheme,s=(e=false)=>w?e:e===true||e===false?true:{...e,animationOff:true},K=(e,y)=>T.switchTheme(e,s(y)),he=e=>T.toggleTheme(s(e)),ae=e=>T.toggleLightTheme(s(e)),Te=e=>T.toggleDarkTheme(s(e)),Z=(e,y)=>T.switchColorTheme(e,s(y)),le=(e,y)=>K(e,{element:y}),j=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",ee=k?g$1==="dark"?"dark":g$1==="system"?j:"light":i$1==="dark"?"dark":"light";if(!w){let e={themes:h,colorThemes:o,mounted:false,ref:{current:null},theme:x??i$1,colorTheme:d$2??r,resolvedTheme:ee,systemTheme:"light",isHydrated:false,setTheme:p,setColorTheme:m,switchTheme:async y=>p(y),switchThemeFromElement:async y=>p(y),switchColorTheme:Z,toggleTheme:async()=>{p(ee==="dark"?"light":"dark");},toggleLightTheme:async()=>p("light"),toggleDarkTheme:async()=>p("dark"),toggleColorTheme:T.toggleColorTheme,createColorThemeToggle:T.createColorThemeToggle,isColorThemeActive:T.isColorThemeActive};return jsx(Q.Provider,{value:e,children:jsx(c$2.Provider,{value:e,children:t})})}let te={...T,systemTheme:j,isHydrated:true,setTheme:p,setColorTheme:m,switchTheme:K,switchThemeFromElement:le,switchColorTheme:Z,toggleTheme:he,toggleLightTheme:ae,toggleDarkTheme:Te};return jsx(Q.Provider,{value:te,children:jsx(c$2.Provider,{value:te,children:t})})},Oe=()=>{let t=useContext(Q);if(t===void 0)throw new Error("useTanStackUITheme must be used within a TanStackUIThemeProvider");return t};var ie=createContext(void 0),Fe=({children:t,themes:h=["light","dark","system"],colorThemes:o=["default"],defaultTheme:i="system",defaultColorTheme:r=o[0]??"default",animationType:c="circle",clipPathDirection:u,animationPosition:v,logo:S,logoLight:L,logoDark:R,logoWidth:O,logoHeight:_,gradientWidth:D,duration:F=400,attribute:I="class",disableTransitionOnChange:C=false,storageKey:V="ui-theme",colorStorageKey:P="ui-color-theme",globalClassName:g="dark",colorThemePrefix:d="theme-"})=>{let n=a$1({themes:h,colorThemes:o,defaultTheme:i,defaultColorTheme:r,animationType:c,clipPathDirection:u,animationPosition:v,...c$1({logo:S,logoLight:L,logoDark:R}),logoWidth:O,logoHeight:_,gradientWidth:D,duration:F,storageKey:V,colorStorageKey:P,globalClassName:I==="class"?g:void 0,colorThemePrefix:d}),a=useCallback(()=>{if(!C)return ()=>{};let m=document.createElement("style");return m.textContent="*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}",document.head.appendChild(m),window.getComputedStyle(document.body),()=>{setTimeout(()=>{document.head.removeChild(m);},1);}},[C]),X=useCallback(m=>{let s=a();n.setTheme(m),s();},[n,a]),N=useCallback(async(m,s=false)=>{let K=a();try{await n.switchTheme(m,s);}finally{K();}},[n,a]),w=useCallback(async(m=false)=>{let s=a();try{await n.toggleTheme(m);}finally{s();}},[n,a]),k=useCallback(async(m=false)=>{let s=a();try{await n.toggleLightTheme(m);}finally{s();}},[n,a]),x=useCallback(async(m=false)=>{let s=a();try{await n.toggleDarkTheme(m);}finally{s();}},[n,a]),T=(m,s)=>N(m,{element:s}),$=c$3(),p={...n,systemTheme:$,setTheme:X,switchTheme:N,switchThemeFromElement:T,toggleTheme:w,toggleLightTheme:k,toggleDarkTheme:x};return jsx(ie.Provider,{value:p,children:jsx(c$2.Provider,{value:p,children:t})})},Ve=()=>{let t=useContext(ie);if(t===void 0)throw new Error("useViteUITheme must be used within a ViteUIThemeProvider");return t};var se=createContext(void 0),Me=({children:t,themes:h=["light","dark","system"],colorThemes:o=["default"],defaultTheme:i="system",defaultColorTheme:r=o[0]??"default",animationType:c="circle",clipPathDirection:u,animationPosition:v,logo:S,logoLight:L,logoDark:R,logoWidth:O,logoHeight:_,gradientWidth:D,duration:F=400,storageKey:I,colorStorageKey:C})=>{let V=d$1(),P=a$1({themes:h,colorThemes:o,defaultTheme:i,defaultColorTheme:r,animationType:c,clipPathDirection:u,animationPosition:v,...c$1({logo:S,logoLight:L,logoDark:R}),logoWidth:O,logoHeight:_,gradientWidth:D,duration:F,storageKey:I,colorStorageKey:C}),g=(n,a)=>P.switchTheme(n,{element:a});if(!V){let n={themes:h,colorThemes:o,mounted:false,systemTheme:"light",ref:{current:null},theme:i,colorTheme:r,resolvedTheme:i==="dark"?"dark":"light",setTheme:()=>{},setColorTheme:()=>{},switchTheme:async()=>{},switchThemeFromElement:async()=>{},switchColorTheme:async()=>{},toggleTheme:async()=>{},toggleLightTheme:async()=>{},toggleDarkTheme:async()=>{},toggleColorTheme:async()=>{},createColorThemeToggle:()=>async()=>{},isColorThemeActive:()=>false};return jsx(se.Provider,{value:n,children:jsx(c$2.Provider,{value:n,children:t})})}let d={...P,switchThemeFromElement:g};return jsx(se.Provider,{value:d,children:jsx(c$2.Provider,{value:d,children:t})})},be=()=>{let t=useContext(c$2);if(t===null)throw new Error("useUITheme must be used within a UIThemeProvider");return {...t,switchThemeFromElement:(h,o)=>t.switchTheme(h,{element:o})}};export{ne as TanStackStartThemeScript,Re as TanStackUIThemeProvider,Me as UIThemeProvider,Fe as ViteUIThemeProvider,Oe as useTanStackUITheme,be as useUITheme,Ve as useViteUITheme};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uitheme-web",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Cross-framework UI theme switching library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"directory": "packages/ui-theme"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
|
-
"access": "public"
|
|
25
|
+
"access": "public",
|
|
26
|
+
"provenance": true
|
|
26
27
|
},
|
|
27
28
|
"sideEffects": false,
|
|
28
29
|
"exports": {
|
|
@@ -157,4 +158,4 @@
|
|
|
157
158
|
"test:package": "node scripts/smoke-v2-package.mjs",
|
|
158
159
|
"test:browser:vue": "playwright test --config playwright.vue.config.ts"
|
|
159
160
|
}
|
|
160
|
-
}
|
|
161
|
+
}
|