uitheme-web 1.0.1 → 1.2.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 +167 -36
- package/dist/chunk-DFJEYTIW.js +12 -0
- package/dist/chunk-V3LMT5IJ.cjs +12 -0
- package/dist/chunk-W4YFUPGE.cjs +18 -0
- package/dist/chunk-WFG34KG5.js +18 -0
- package/dist/cli/index.js +39 -0
- package/dist/constants-DmZ7yAIL.d.cts +145 -0
- package/dist/constants-DmZ7yAIL.d.ts +145 -0
- package/dist/core/index.cjs +1 -270
- package/dist/core/index.d.cts +7 -3
- package/dist/core/index.d.ts +7 -3
- package/dist/core/index.js +1 -246
- package/dist/logo-DtwtRv4y.d.cts +4 -0
- package/dist/logo-DtwtRv4y.d.ts +4 -0
- package/dist/react/index.cjs +33 -1701
- package/dist/react/index.d.cts +78 -182
- package/dist/react/index.d.ts +78 -182
- package/dist/react/index.js +33 -1640
- package/dist/tanstack/index.cjs +1 -30
- package/dist/tanstack/index.d.cts +2 -2
- package/dist/tanstack/index.d.ts +2 -2
- package/dist/tanstack/index.js +1 -25
- package/package.json +22 -14
- package/dist/constants-n21pnuRC.d.cts +0 -106
- package/dist/constants-n21pnuRC.d.ts +0 -106
package/README.md
CHANGED
|
@@ -20,6 +20,24 @@ pnpm add uitheme-web
|
|
|
20
20
|
yarn add uitheme-web
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
## Migrating from `@ui-theme/web`
|
|
24
|
+
|
|
25
|
+
This package was published under the name `@ui-theme/web` before the rename. That name is deprecated. Run the migration command to move a project across:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx uitheme-web migrate
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The command lists the files it will change and asks for confirmation. It then rewrites the import specifiers, the Tailwind `@source` path, and the dependency in `package.json`. The entry point names stay the same, so `/core`, `/react` and `/tanstack` are unchanged.
|
|
32
|
+
|
|
33
|
+
| Option | Effect |
|
|
34
|
+
| ------------- | --------------------------------------- |
|
|
35
|
+
| `--yes` | Rewrite without asking for confirmation |
|
|
36
|
+
| `--cwd <dir>` | Work on a project in another directory |
|
|
37
|
+
| `--help` | Show the help |
|
|
38
|
+
|
|
39
|
+
The command skips `node_modules`, `dist`, `.next` and other build output. It does not change prose in your markdown files.
|
|
40
|
+
|
|
23
41
|
## Tailwind Setup For Prebuilt Components
|
|
24
42
|
|
|
25
43
|
`UIThemeSwitcher`, `UIThemeSelector`, and the bundled select primitives use Tailwind utility classes. `uitheme-web` does not ship a compiled CSS file for those components, so the consuming app must include the package in Tailwind's source scan.
|
|
@@ -80,48 +98,84 @@ function ThemeToggle() {
|
|
|
80
98
|
- [TanStack Start Setup Guide](../../docs/tanstack-start-setup.md) - Isomorphic rendering, hydration-safe patterns
|
|
81
99
|
- [Vite React SPA Setup Guide](../../docs/vite-setup.md) - Client-side setup, flash prevention, routing
|
|
82
100
|
|
|
101
|
+
## Animated mode and palette changes
|
|
102
|
+
|
|
103
|
+
Use `switchColorTheme`, `toggleColorTheme`, or `createColorThemeToggle` for animated palettes. `setTheme` and `setColorTheme` remain immediate setters. Every provider and the standalone hook accepts the same transition options:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
const { toggleTheme, switchColorTheme } = useTheme({
|
|
107
|
+
colorThemes: ['default', 'ocean', 'rose'],
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
<button onClick={(event) => void toggleTheme({
|
|
111
|
+
element: event.currentTarget,
|
|
112
|
+
animationOff: event.detail === 0,
|
|
113
|
+
})}>Toggle mode</button>
|
|
114
|
+
|
|
115
|
+
<button onClick={(event) => void switchColorTheme('ocean', {
|
|
116
|
+
element: event.currentTarget,
|
|
117
|
+
animationOff: event.detail === 0,
|
|
118
|
+
})}>Ocean palette</button>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`element` uses the trigger's center. `origin: { x, y }` overrides it with viewport-relative **CSS pixels**, without multiplying by `devicePixelRatio`. Without either option, the hook uses its existing button `ref`; attach a shared ref to only one trigger. Slide transitions need no trigger. Boolean calls such as `toggleTheme(true)` still disable animation.
|
|
122
|
+
|
|
123
|
+
`ThemeTransitionInput` is `boolean | { element?: Element | null; origin?: { x: number; y: number }; animationOff?: boolean }`. Color helpers now return `Promise<void>`; existing fire-and-forget calls still work. `toggleColorTheme` and `createColorThemeToggle('ocean')` can be used directly as `onClick`, reading the clicked element and skipping keyboard motion.
|
|
124
|
+
|
|
125
|
+
The default is 400 ms with `cubic-bezier(0.32, 0.72, 0, 1)`: a steep curve for a full-viewport reveal. Explicit durations are respected at every display size. `blurAmount` is now a feather width in CSS pixels, capped at 20 px; the gradient softens the edge without blurring the page content. Unsupported browsers, failed/skipped captures, missing circle origins, and reduced motion apply the theme without a reveal. New requests interrupt older transitions; CSS transitions are suppressed only during library-owned captures and playback.
|
|
126
|
+
|
|
127
|
+
Core consumers can call `runThemeTransition(update, config)` to handle capture, scoped styles, interruption, and cleanup. The React hook uses this runner internally. Low-level animation helpers should be called **after** `transition.ready` with caller-managed pseudo-element styles. They return native `Animation` handles; cancel them when done. `styleId` remains accepted for compatibility; the native animation path no longer creates a timer-owned stylesheet with that ID.
|
|
128
|
+
|
|
129
|
+
[Research, browser verification, and performance evidence](../../docs/theme-transition-verification.md).
|
|
130
|
+
|
|
83
131
|
## API Reference
|
|
84
132
|
|
|
85
133
|
### Shared Hook Return (All Providers)
|
|
86
134
|
|
|
87
135
|
All providers expose the same hook interface:
|
|
88
136
|
|
|
89
|
-
| Property | Type
|
|
90
|
-
| ---------------------- |
|
|
91
|
-
| theme | Theme
|
|
92
|
-
| colorTheme | ColorTheme
|
|
93
|
-
| resolvedTheme | 'light' \| 'dark'
|
|
94
|
-
| systemTheme | 'light' \| 'dark'
|
|
95
|
-
| ref | RefObject<HTMLElement>
|
|
96
|
-
| setTheme | (theme: Theme) => void
|
|
97
|
-
| setColorTheme | (colorTheme: ColorTheme) => void
|
|
98
|
-
| switchTheme | (theme: Theme,
|
|
99
|
-
| switchColorTheme | (colorTheme: string) => void
|
|
100
|
-
| toggleTheme | (
|
|
101
|
-
| toggleLightTheme | (
|
|
102
|
-
| toggleDarkTheme | (
|
|
103
|
-
| toggleColorTheme |
|
|
104
|
-
| createColorThemeToggle | (colorTheme: string) =>
|
|
105
|
-
| isColorThemeActive | (colorTheme: string) => boolean
|
|
106
|
-
| switchThemeFromElement | (theme: Theme, element: HTMLElement) => Promise<void>
|
|
137
|
+
| Property | Type | Description |
|
|
138
|
+
| ---------------------- | --------------------------------------------------------------------- | ---------------------------------- |
|
|
139
|
+
| theme | Theme | Current theme |
|
|
140
|
+
| colorTheme | ColorTheme | Current color theme |
|
|
141
|
+
| resolvedTheme | 'light' \| 'dark' | Resolved theme (system → actual) |
|
|
142
|
+
| systemTheme | 'light' \| 'dark' | OS theme preference |
|
|
143
|
+
| ref | RefObject<HTMLElement> | Ref for animation origin |
|
|
144
|
+
| setTheme | (theme: Theme) => void | Set theme instantly |
|
|
145
|
+
| setColorTheme | (colorTheme: ColorTheme) => void | Set color theme |
|
|
146
|
+
| switchTheme | (theme: Theme, options?: ThemeTransitionInput) => Promise<void> | Switch with animation |
|
|
147
|
+
| switchColorTheme | (colorTheme: string, options?: ThemeTransitionInput) => Promise<void> | Switch color theme with animation |
|
|
148
|
+
| toggleTheme | (options?: ThemeTransitionInput) => Promise<void> | Toggle light/dark |
|
|
149
|
+
| toggleLightTheme | (options?: ThemeTransitionInput) => Promise<void> | Toggle to light |
|
|
150
|
+
| toggleDarkTheme | (options?: ThemeTransitionInput) => Promise<void> | Toggle to dark |
|
|
151
|
+
| toggleColorTheme | ColorThemeToggle | Toggle between color themes |
|
|
152
|
+
| createColorThemeToggle | (colorTheme: string) => ColorThemeToggle | Create color theme toggle |
|
|
153
|
+
| isColorThemeActive | (colorTheme: string) => boolean | Check if color theme active |
|
|
154
|
+
| switchThemeFromElement | (theme: Theme, element: HTMLElement) => Promise<void> | Switch with animation from element |
|
|
107
155
|
|
|
108
156
|
### Provider Props
|
|
109
157
|
|
|
110
|
-
| Prop | UITheme | NextUITheme | TanStackUITheme | ViteUITheme | Type
|
|
111
|
-
| ------------------------- | ------- | ----------- | --------------- | ----------- |
|
|
112
|
-
| defaultTheme | ✓ | ✓ | ✓ | ✓ | Theme
|
|
113
|
-
| defaultColorTheme | ✓ | ✓ | ✓ | ✓ | ColorTheme
|
|
114
|
-
| themes | ✓ | ✓ | ✓ | ✓ | Theme[]
|
|
115
|
-
| colorThemes | ✓ | ✓ | ✓ | ✓ | ColorTheme[]
|
|
116
|
-
| animationType | ✓ | ✓ | ✓ | ✓ | ThemeAnimationType
|
|
117
|
-
|
|
|
118
|
-
|
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
|
|
|
158
|
+
| Prop | UITheme | NextUITheme | TanStackUITheme | ViteUITheme | Type | Default |
|
|
159
|
+
| ------------------------- | ------- | ----------- | --------------- | ----------- | ------------------- | --------------------------- |
|
|
160
|
+
| defaultTheme | ✓ | ✓ | ✓ | ✓ | Theme | 'system' |
|
|
161
|
+
| defaultColorTheme | ✓ | ✓ | ✓ | ✓ | ColorTheme | 'default' |
|
|
162
|
+
| themes | ✓ | ✓ | ✓ | ✓ | Theme[] | ['light', 'dark', 'system'] |
|
|
163
|
+
| colorThemes | ✓ | ✓ | ✓ | ✓ | ColorTheme[] | ['default'] |
|
|
164
|
+
| animationType | ✓ | ✓ | ✓ | ✓ | ThemeAnimationType | CIRCLE |
|
|
165
|
+
| clipPathDirection | ✓ | ✓ | ✓ | ✓ | TransitionDirection | 'top-left' |
|
|
166
|
+
| animationPosition | ✓ | ✓ | ✓ | ✓ | AnimationPosition | trigger / center fallback |
|
|
167
|
+
| logo | ✓ | ✓ | ✓ | ✓ | string (SVG URL) | - |
|
|
168
|
+
| logoWidth | ✓ | ✓ | ✓ | ✓ | number or "auto" | 96 / aspect ratio |
|
|
169
|
+
| logoHeight | ✓ | ✓ | ✓ | ✓ | number or "auto" | aspect ratio |
|
|
170
|
+
| gradientWidth | ✓ | ✓ | ✓ | ✓ | number (CSS px) | 80 |
|
|
171
|
+
| duration | ✓ | ✓ | ✓ | ✓ | number | 400 |
|
|
172
|
+
| storageKey | ✓ | ✓ | ✓ | ✓ | string | varies |
|
|
173
|
+
| colorStorageKey | ✓ | ✓ | ✓ | ✓ | string | varies |
|
|
174
|
+
| nonce | ✗ | ✓ | ✗ | ✗ | string | - |
|
|
175
|
+
| disablePreHydrationScript | ✗ | ✓ | ✗ | ✗ | boolean | false |
|
|
176
|
+
| disableTransitionOnChange | ✗ | ✗ | ✗ | ✓ | boolean | false |
|
|
177
|
+
| onThemeChange | ✓ | ✓ | ✓ | ✓ | function | - |
|
|
178
|
+
| onColorThemeChange | ✓ | ✓ | ✓ | ✓ | function | - |
|
|
125
179
|
|
|
126
180
|
### Components
|
|
127
181
|
|
|
@@ -173,10 +227,10 @@ Define theme variables in your global CSS file:
|
|
|
173
227
|
<details>
|
|
174
228
|
<summary>Browser Support</summary>
|
|
175
229
|
|
|
176
|
-
- View Transitions
|
|
177
|
-
- Fallback:
|
|
230
|
+
- Animated reveals require View Transitions and animation of transition pseudo-elements.
|
|
231
|
+
- Fallback: unsupported browsers apply the theme immediately.
|
|
178
232
|
- Reduced Motion: Respects prefers-reduced-motion
|
|
179
|
-
- Framework Support: React
|
|
233
|
+
- Framework Support: React 18+
|
|
180
234
|
|
|
181
235
|
</details>
|
|
182
236
|
|
|
@@ -185,6 +239,70 @@ Define theme variables in your global CSS file:
|
|
|
185
239
|
|
|
186
240
|
### Animation Control
|
|
187
241
|
|
|
242
|
+
Choose `CIRCLE`, `BLUR_CIRCLE`, `SLIDE`, `CLIP_PATH`, `POLYGON_GRADIENT`,
|
|
243
|
+
`TRIANGLE`, or `SVG_LOGO` from `ThemeAnimationType`. All effects also apply to
|
|
244
|
+
animated color-palette changes. GIF effects are not included.
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
import { ThemeAnimationType, UIThemeProvider } from 'uitheme-web/react';
|
|
248
|
+
|
|
249
|
+
<UIThemeProvider
|
|
250
|
+
animationType={ThemeAnimationType.CLIP_PATH}
|
|
251
|
+
clipPathDirection="top-right"
|
|
252
|
+
duration={400}
|
|
253
|
+
>
|
|
254
|
+
<App />
|
|
255
|
+
</UIThemeProvider>;
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
`CLIP_PATH` is a sharp polygon wipe; `POLYGON_GRADIENT` feathers its leading edge.
|
|
259
|
+
Both accept `clipPathDirection` in clockwise order: `top-left`, `top`,
|
|
260
|
+
`top-right`, `right`, `bottom-right`, `bottom`, `bottom-left`, `left`.
|
|
261
|
+
`POLYGON_GRADIENT` also accepts `gradientWidth` (default: 80 CSS pixels, capped
|
|
262
|
+
relative to the mask size).
|
|
263
|
+
|
|
264
|
+
For circle, blurred circle, or triangle effects, `animationPosition` can be
|
|
265
|
+
any of those eight positions, `center`, or `trigger`. The trigger uses the clicked
|
|
266
|
+
element or attached ref. Triangle effects fall back to the viewport
|
|
267
|
+
center when no trigger is available. An explicit per-call `origin` takes precedence.
|
|
268
|
+
|
|
269
|
+
### SVG logo transition
|
|
270
|
+
|
|
271
|
+
Pass a self-contained SVG file URL, such as `/brand.svg`, a bundler asset import,
|
|
272
|
+
or a blob URL created from a file input. The SVG is displayed at a fixed size in
|
|
273
|
+
the viewport center while a circular theme reveal expands underneath it. The
|
|
274
|
+
logo stays still and fades out over the final 15% of the transition.
|
|
275
|
+
|
|
276
|
+
```tsx
|
|
277
|
+
<UIThemeProvider
|
|
278
|
+
animationType={ThemeAnimationType.SVG_LOGO}
|
|
279
|
+
logo="/brand.svg"
|
|
280
|
+
logoWidth={120}
|
|
281
|
+
duration={600}
|
|
282
|
+
>
|
|
283
|
+
<App />
|
|
284
|
+
</UIThemeProvider>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
`logoWidth` and `logoHeight` accept positive CSS-pixel dimensions or `"auto"`. Either dimension
|
|
288
|
+
alone preserves the SVG aspect ratio; both dimensions define a box with
|
|
289
|
+
`object-fit: contain`. Without either, width defaults to 96 px. The SVG effect
|
|
290
|
+
always uses the viewport center, including when a trigger or another animation
|
|
291
|
+
position is provided. The logo retains its artwork colors.
|
|
292
|
+
|
|
293
|
+
The hook preloads and decodes the logo before capture. If it is still loading,
|
|
294
|
+
invalid, unavailable, or not an SVG, that toggle uses the circle effect instead
|
|
295
|
+
of waiting. Core consumers can `await preloadThemeLogo(url)` before starting a
|
|
296
|
+
transition. Use transparent backgrounds and a suitable `viewBox`; preserve the
|
|
297
|
+
logo's intrinsic aspect ratio. SVG markup is loaded as an image, never inserted
|
|
298
|
+
into the page.
|
|
299
|
+
|
|
300
|
+
These options work with all four providers, `useTheme`, `UIThemeSwitcher`, and
|
|
301
|
+
`UIThemeSelector`. Reduced motion applies the theme immediately.
|
|
302
|
+
|
|
303
|
+
See [animation options and browser verification](../../docs/theme-animation-options.md)
|
|
304
|
+
for the effect gallery, research, and testing boundaries.
|
|
305
|
+
|
|
188
306
|
```tsx
|
|
189
307
|
const { switchTheme, toggleTheme } = useUITheme();
|
|
190
308
|
|
|
@@ -224,3 +342,16 @@ const { theme, toggleTheme, ref } = useTheme({
|
|
|
224
342
|
## License
|
|
225
343
|
|
|
226
344
|
MIT
|
|
345
|
+
|
|
346
|
+
Use `logoLight` and `logoDark` together instead of `logo` to select the current theme’s asset: `logoDark` for dark-to-light, `logoLight` for light-to-dark. Use a light or white `logoDark` on the dark interface and a dark or black `logoLight` on the light interface. Both are required; combining the pair with `logo` is rejected.
|
|
347
|
+
|
|
348
|
+
When one dimension is set and the other omitted, the omitted dimension defaults to `"auto"` and preserves the SVG aspect ratio. Explicit `"auto"` for both uses the SVG’s intrinsic size. With both omitted, the existing 96 px default width is preserved.
|
|
349
|
+
|
|
350
|
+
All built-in controls share the active state from any of the four providers.
|
|
351
|
+
Outside a provider, they own their standalone state. Keyboard selection inside
|
|
352
|
+
the dropdown portal skips moving reveals.
|
|
353
|
+
|
|
354
|
+
`useHydrated()` is exported from `uitheme-web/react`. For TanStack server/cookie
|
|
355
|
+
callbacks, use `onServerError={(error) => ...}` to observe failed notifications;
|
|
356
|
+
otherwise failures are reported through `console.error` without unhandled promise
|
|
357
|
+
rejections.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {q as q$1,r,f,g as g$1,a,o,p,j,k as k$1,l,m,n}from'./chunk-WFG34KG5.js';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 O=e=>{if(e.logoLight!==void 0||e.logoDark!==void 0){if(!e.logoLight||!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}},E=0,S=e=>{let t=I(e.logo);if(!t)return;let n=e.logoWidth!=="auto"&&e.logoWidth&&Number.isFinite(e.logoWidth)&&e.logoWidth>0?e.logoWidth:void 0,o=e.logoHeight!=="auto"&&e.logoHeight&&Number.isFinite(e.logoHeight)&&e.logoHeight>0?e.logoHeight:void 0,a=n??(o?o*t.aspectRatio:e.logoWidth==="auto"||e.logoHeight==="auto"?t.naturalWidth:96),i=o??a/t.aspectRatio,s=`ui-theme-logo-${++E}`,r=document.createElement("img");r.src=t.image,r.alt="",r.setAttribute("aria-hidden","true"),r.setAttribute("data-ui-theme-logo",""),r.style.cssText=`position:fixed;left:calc(50% - ${a/2}px);top:calc(50% - ${i/2}px);width:${a}px;height:${i}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:${s};`;let m=document.createElement("style");return m.setAttribute("data-ui-theme-logo-style",""),m.textContent=`
|
|
2
|
+
@keyframes ${s}-fade { 0%, 85% { opacity:1; } 100% { opacity:0; } }
|
|
3
|
+
html[data-ui-theme-transition]::view-transition-group(${s}) {
|
|
4
|
+
z-index:2;
|
|
5
|
+
animation:${s}-fade ${e.duration}ms linear both;
|
|
6
|
+
}
|
|
7
|
+
html[data-ui-theme-transition]::view-transition-old(${s}) { display:none; }
|
|
8
|
+
html[data-ui-theme-transition]::view-transition-new(${s}) {
|
|
9
|
+
animation:none; mix-blend-mode:normal;
|
|
10
|
+
}
|
|
11
|
+
`,document.head.appendChild(m),document.documentElement.appendChild(r),{element:r,style:m}},u=new Map,k=e=>{if(typeof window>"u")return Promise.resolve();let t=u.get(e);if(t)return t.loading;let n={loading:Promise.resolve()};return u.set(e,n),n.loading=(async()=>{let o=new AbortController,a=setTimeout(()=>o.abort(),2e3);try{let i=await fetch(e,{signal:o.signal});if(!i.ok)return;let s=await i.text(),r=new DOMParser().parseFromString(s,"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(s)}`,l=new Image;l.src=m,await l.decode(),l.naturalWidth>0&&l.naturalHeight>0&&(n.ready={image:m,naturalWidth:l.naturalWidth,aspectRatio:l.naturalWidth/l.naturalHeight});}catch{}finally{clearTimeout(a);}})(),n.loading},I=e=>e?u.get(e)?.ready:void 0;var g=new WeakMap,G=async(e,t)=>{if(typeof document>"u"){e();return}let n$1=g.get(document);n$1?.transition?.skipTransition(),n$1?.animation?.cancel(),n$1?.logo?.element.remove(),n$1?.logo?.style.remove();let o$1={updateDone:Promise.resolve()};g.set(document,o$1);let a$1=()=>{o$1.animation?.cancel(),o$1.logo?.element.remove(),o$1.logo?.style.remove(),g.get(document)===o$1&&(g.delete(document),document.documentElement.removeAttribute("data-ui-theme-transition"));};o$1.updateDone=(async()=>{if(n$1&&await n$1.updateDone.catch(()=>{}),g.get(document)!==o$1||!t||!f()||g$1()||document.visibilityState==="hidden"){e();return}a(),document.documentElement.setAttribute("data-ui-theme-transition",""),t.animationType==="svg-logo"&&(o$1.logo=S(t));let i;try{i=document.startViewTransition(e);}catch{e();return}o$1.transition=i,i.ready.catch(()=>{}),i.finished.then(a$1,a$1),await i.updateCallbackDone;})();try{await o$1.updateDone;let i=o$1.transition;if(!i){a$1();return}try{await i.ready;}catch{a$1();return}if(g.get(document)!==o$1){i.skipTransition();return}if(!t)return;try{o$1.animation=t.animationType==="slide"?o(t):t.animationType==="blur-circle"?p(t):t.animationType==="clip-path"?j(t):t.animationType==="polygon-gradient"?k$1(t):t.animationType==="triangle"?l(t):t.animationType==="svg-logo"?m(t):n(t),o$1.animation.finished.catch(()=>{});let s=o$1.animation.effect;!(o$1.animation instanceof CSSAnimation)&&(!(s instanceof KeyframeEffect)||s.pseudoElement!=="::view-transition-new(root)")&&(i.skipTransition(),a$1());}catch{i.skipTransition(),a$1();}}catch(i){throw a$1(),i}};var d=typeof window<"u",$=(e=q$1,t=["light","dark","system"],n="system")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return t.find(a=>a===o)??n},q=(e,t=q$1)=>{d&&localStorage.setItem(t,e);},V=(e=r,t=["default"],n="default")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return o&&t.includes(o)?o:n},M=(e,t=r)=>{d&&localStorage.setItem(t,e);};
|
|
12
|
+
export{A as a,D as b,O as c,k as d,G as e,$ as f,q as g,V as h,M as i};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';var chunkW4YFUPGE_cjs=require('./chunk-W4YFUPGE.cjs');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 O=e=>{if(e.logoLight!==void 0||e.logoDark!==void 0){if(!e.logoLight||!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}},E=0,S=e=>{let t=I(e.logo);if(!t)return;let n=e.logoWidth!=="auto"&&e.logoWidth&&Number.isFinite(e.logoWidth)&&e.logoWidth>0?e.logoWidth:void 0,o=e.logoHeight!=="auto"&&e.logoHeight&&Number.isFinite(e.logoHeight)&&e.logoHeight>0?e.logoHeight:void 0,a=n??(o?o*t.aspectRatio:e.logoWidth==="auto"||e.logoHeight==="auto"?t.naturalWidth:96),i=o??a/t.aspectRatio,s=`ui-theme-logo-${++E}`,r=document.createElement("img");r.src=t.image,r.alt="",r.setAttribute("aria-hidden","true"),r.setAttribute("data-ui-theme-logo",""),r.style.cssText=`position:fixed;left:calc(50% - ${a/2}px);top:calc(50% - ${i/2}px);width:${a}px;height:${i}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:${s};`;let m=document.createElement("style");return m.setAttribute("data-ui-theme-logo-style",""),m.textContent=`
|
|
2
|
+
@keyframes ${s}-fade { 0%, 85% { opacity:1; } 100% { opacity:0; } }
|
|
3
|
+
html[data-ui-theme-transition]::view-transition-group(${s}) {
|
|
4
|
+
z-index:2;
|
|
5
|
+
animation:${s}-fade ${e.duration}ms linear both;
|
|
6
|
+
}
|
|
7
|
+
html[data-ui-theme-transition]::view-transition-old(${s}) { display:none; }
|
|
8
|
+
html[data-ui-theme-transition]::view-transition-new(${s}) {
|
|
9
|
+
animation:none; mix-blend-mode:normal;
|
|
10
|
+
}
|
|
11
|
+
`,document.head.appendChild(m),document.documentElement.appendChild(r),{element:r,style:m}},u=new Map,k=e=>{if(typeof window>"u")return Promise.resolve();let t=u.get(e);if(t)return t.loading;let n={loading:Promise.resolve()};return u.set(e,n),n.loading=(async()=>{let o=new AbortController,a=setTimeout(()=>o.abort(),2e3);try{let i=await fetch(e,{signal:o.signal});if(!i.ok)return;let s=await i.text(),r=new DOMParser().parseFromString(s,"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(s)}`,l=new Image;l.src=m,await l.decode(),l.naturalWidth>0&&l.naturalHeight>0&&(n.ready={image:m,naturalWidth:l.naturalWidth,aspectRatio:l.naturalWidth/l.naturalHeight});}catch{}finally{clearTimeout(a);}})(),n.loading},I=e=>e?u.get(e)?.ready:void 0;var g=new WeakMap,G=async(e,t)=>{if(typeof document>"u"){e();return}let n=g.get(document);n?.transition?.skipTransition(),n?.animation?.cancel(),n?.logo?.element.remove(),n?.logo?.style.remove();let o={updateDone:Promise.resolve()};g.set(document,o);let a=()=>{o.animation?.cancel(),o.logo?.element.remove(),o.logo?.style.remove(),g.get(document)===o&&(g.delete(document),document.documentElement.removeAttribute("data-ui-theme-transition"));};o.updateDone=(async()=>{if(n&&await n.updateDone.catch(()=>{}),g.get(document)!==o||!t||!chunkW4YFUPGE_cjs.f()||chunkW4YFUPGE_cjs.g()||document.visibilityState==="hidden"){e();return}chunkW4YFUPGE_cjs.a(),document.documentElement.setAttribute("data-ui-theme-transition",""),t.animationType==="svg-logo"&&(o.logo=S(t));let i;try{i=document.startViewTransition(e);}catch{e();return}o.transition=i,i.ready.catch(()=>{}),i.finished.then(a,a),await i.updateCallbackDone;})();try{await o.updateDone;let i=o.transition;if(!i){a();return}try{await i.ready;}catch{a();return}if(g.get(document)!==o){i.skipTransition();return}if(!t)return;try{o.animation=t.animationType==="slide"?chunkW4YFUPGE_cjs.o(t):t.animationType==="blur-circle"?chunkW4YFUPGE_cjs.p(t):t.animationType==="clip-path"?chunkW4YFUPGE_cjs.j(t):t.animationType==="polygon-gradient"?chunkW4YFUPGE_cjs.k(t):t.animationType==="triangle"?chunkW4YFUPGE_cjs.l(t):t.animationType==="svg-logo"?chunkW4YFUPGE_cjs.m(t):chunkW4YFUPGE_cjs.n(t),o.animation.finished.catch(()=>{});let s=o.animation.effect;!(o.animation instanceof CSSAnimation)&&(!(s instanceof KeyframeEffect)||s.pseudoElement!=="::view-transition-new(root)")&&(i.skipTransition(),a());}catch{i.skipTransition(),a();}}catch(i){throw a(),i}};var d=typeof window<"u",$=(e=chunkW4YFUPGE_cjs.q,t=["light","dark","system"],n="system")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return t.find(a=>a===o)??n},q=(e,t=chunkW4YFUPGE_cjs.q)=>{d&&localStorage.setItem(t,e);},V=(e=chunkW4YFUPGE_cjs.r,t=["default"],n="default")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return o&&t.includes(o)?o:n},M=(e,t=chunkW4YFUPGE_cjs.r)=>{d&&localStorage.setItem(t,e);};
|
|
12
|
+
exports.a=A;exports.b=D;exports.c=O;exports.d=k;exports.e=G;exports.f=$;exports.g=q;exports.h=V;exports.i=M;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';var x=typeof window<"u",k=()=>{if(!x||document.getElementById("ui-theme-base-style"))return;let t=document.createElement("style");t.id="ui-theme-base-style",t.textContent=`
|
|
2
|
+
html[data-ui-theme-transition]::view-transition-group(root),
|
|
3
|
+
html[data-ui-theme-transition]::view-transition-old(root),
|
|
4
|
+
html[data-ui-theme-transition]::view-transition-new(root) {
|
|
5
|
+
animation: none;
|
|
6
|
+
}
|
|
7
|
+
html[data-ui-theme-transition]::view-transition-old(root),
|
|
8
|
+
html[data-ui-theme-transition]::view-transition-new(root) {
|
|
9
|
+
mix-blend-mode: normal;
|
|
10
|
+
}
|
|
11
|
+
html[data-ui-theme-transition],
|
|
12
|
+
html[data-ui-theme-transition] *,
|
|
13
|
+
html[data-ui-theme-transition] *::before,
|
|
14
|
+
html[data-ui-theme-transition] *::after {
|
|
15
|
+
transition: none !important;
|
|
16
|
+
}
|
|
17
|
+
`,document.head.appendChild(t);},E=t=>`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-50 -50 100 100"><defs>${`<filter id="blur"><feGaussianBlur stdDeviation="${t}" /></filter>`}</defs><circle cx="0" cy="0" r="25" fill="white" filter="url(%23blur)"/></svg>')`,C=()=>x&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",M=t=>t==="system"?C():t==="dark"?"dark":"light",R=t=>t==="system"?"system":t==="dark"?"dark":"light",T=()=>x&&document.startViewTransition instanceof Function,P=()=>x&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,D=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}}},y=()=>{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}=y();return Math.hypot(Math.max(Math.abs(t),Math.abs(e-t)),Math.max(Math.abs(n),Math.abs(o-n)))+1},L=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,h=(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(c=>"clipPath"in c)?"clipPath":i.some(c=>"maskImage"in c)?"maskImage":"transform";if(getComputedStyle(document.documentElement,"::view-transition-new(root)")[d]!=="none")return e;let l=e.playState==="paused",s=e.currentTime;e.cancel(),e.finished.catch(()=>{});let a=`ui-theme-reveal-${++S}`,r=document.createElement("style"),m=i.map(c=>{let $=Object.entries(c).filter(([u])=>!["offset","computedOffset","easing","composite"].includes(u)).map(([u,A])=>`${u.replace(/[A-Z]/g,v=>`-${v.toLowerCase()}`)}:${A};`).join("");return `${c.computedOffset*100}%{${$}}`}).join("");r.textContent=`@keyframes ${a}{${m}}html[data-ui-theme-transition]::view-transition-new(root){animation:${a} ${t.duration}ms ${t.easing} both;}`,document.head.appendChild(r);let f=getComputedStyle(document.documentElement,"::view-transition-new(root)").animationName,p=document.getAnimations().find(c=>c instanceof CSSAnimation&&c.animationName===f);if(!p)throw r.remove(),new Error("Transition pseudo animations are unavailable");return l&&(p.pause(),p.currentTime=s),p.finished.then(()=>r.remove(),()=>r.remove()),p},O=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 h(t,{clipPath:[e[n],o[n]]})},_=t=>{let n=t.clipPathDirection??"top-left",{width:e,height:o}=y(),i=n.includes("-"),d=n.includes("left"),g=n.includes("top"),l=n==="left"||n==="right",s=d?0:n.includes("right")?1:.5,a=g?0:n.includes("bottom")?1:.5,r=i||l?e*3:e,m=i||!l?o*3:o,f=i?`${s*100},${a*100} ${(1-s)*100},${a*100} ${s*100},${(1-a)*100}`:"0,0 100,0 100,100 0,100",p=i?r*m/Math.hypot(r,m):l?r:m,$=1-Math.max(0,Math.min(t.gradientWidth??80,p*.2))/p,u=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><defs><linearGradient id="edge" x1="${s*100}" y1="${a*100}" x2="${100*(i?.5:l?1-s:s)}" y2="${100*(i?.5:l?a:1-a)}" gradientUnits="userSpaceOnUse"><stop offset="${$}" stop-color="black"/><stop offset="1" stop-color="black" stop-opacity="0"/></linearGradient></defs><polygon points="${f}" fill="url(#edge)"/></svg>`;return h(t,{maskImage:[`url("data:image/svg+xml,${encodeURIComponent(u)}")`,`url("data:image/svg+xml,${encodeURIComponent(u)}")`],maskMode:["alpha","alpha"],maskRepeat:["no-repeat","no-repeat"],maskSize:[i?"0px 0px":l?`0px ${m}px`:`${r}px 0px`,`${r}px ${m}px`],maskPosition:[`${s*e}px ${a*o}px`,`${s*(e-r)}px ${a*(o-m)}px`]})},F=t=>{let{x:n,y:e}=t,o=w(n,e),i=Math.sqrt(3)*o;return h(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)`]})},I=t=>{let{width:n,height:e}=y();return b({...t,x:n/2,y:e/2})},b=t=>{let{x:n,y:e}=t;return h(t,{clipPath:[`circle(0px at ${n}px ${e}px)`,`circle(${w(n,e)}px at ${n}px ${e}px)`]})},U=t=>{let{a:n=-100,b:e=0,x:o=0,y:i=0}=t;return h(t,{transform:[`translate(${n}%, ${e}%)`,`translate(${o}%, ${i}%)`]})},B=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 h(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`]})};var N="theme",K="color-theme",z="dark",j="theme-",H=400,W="cubic-bezier(0.32, 0.72, 0, 1)",Y=2,q="ui-theme-style";
|
|
18
|
+
exports.a=k;exports.b=E;exports.c=C;exports.d=M;exports.e=R;exports.f=T;exports.g=P;exports.h=D;exports.i=L;exports.j=O;exports.k=_;exports.l=F;exports.m=I;exports.n=b;exports.o=U;exports.p=B;exports.q=N;exports.r=K;exports.s=z;exports.t=j;exports.u=H;exports.v=W;exports.w=Y;exports.x=q;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var x=typeof window<"u",k=()=>{if(!x||document.getElementById("ui-theme-base-style"))return;let t=document.createElement("style");t.id="ui-theme-base-style",t.textContent=`
|
|
2
|
+
html[data-ui-theme-transition]::view-transition-group(root),
|
|
3
|
+
html[data-ui-theme-transition]::view-transition-old(root),
|
|
4
|
+
html[data-ui-theme-transition]::view-transition-new(root) {
|
|
5
|
+
animation: none;
|
|
6
|
+
}
|
|
7
|
+
html[data-ui-theme-transition]::view-transition-old(root),
|
|
8
|
+
html[data-ui-theme-transition]::view-transition-new(root) {
|
|
9
|
+
mix-blend-mode: normal;
|
|
10
|
+
}
|
|
11
|
+
html[data-ui-theme-transition],
|
|
12
|
+
html[data-ui-theme-transition] *,
|
|
13
|
+
html[data-ui-theme-transition] *::before,
|
|
14
|
+
html[data-ui-theme-transition] *::after {
|
|
15
|
+
transition: none !important;
|
|
16
|
+
}
|
|
17
|
+
`,document.head.appendChild(t);},E=t=>`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-50 -50 100 100"><defs>${`<filter id="blur"><feGaussianBlur stdDeviation="${t}" /></filter>`}</defs><circle cx="0" cy="0" r="25" fill="white" filter="url(%23blur)"/></svg>')`,C=()=>x&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",M=t=>t==="system"?C():t==="dark"?"dark":"light",R=t=>t==="system"?"system":t==="dark"?"dark":"light",T=()=>x&&document.startViewTransition instanceof Function,P=()=>x&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,D=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}}},y=()=>{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}=y();return Math.hypot(Math.max(Math.abs(t),Math.abs(e-t)),Math.max(Math.abs(n),Math.abs(o-n)))+1},L=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,h=(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(c=>"clipPath"in c)?"clipPath":i.some(c=>"maskImage"in c)?"maskImage":"transform";if(getComputedStyle(document.documentElement,"::view-transition-new(root)")[d]!=="none")return e;let l=e.playState==="paused",s=e.currentTime;e.cancel(),e.finished.catch(()=>{});let a=`ui-theme-reveal-${++S}`,r=document.createElement("style"),m=i.map(c=>{let $=Object.entries(c).filter(([u])=>!["offset","computedOffset","easing","composite"].includes(u)).map(([u,A])=>`${u.replace(/[A-Z]/g,v=>`-${v.toLowerCase()}`)}:${A};`).join("");return `${c.computedOffset*100}%{${$}}`}).join("");r.textContent=`@keyframes ${a}{${m}}html[data-ui-theme-transition]::view-transition-new(root){animation:${a} ${t.duration}ms ${t.easing} both;}`,document.head.appendChild(r);let f=getComputedStyle(document.documentElement,"::view-transition-new(root)").animationName,p=document.getAnimations().find(c=>c instanceof CSSAnimation&&c.animationName===f);if(!p)throw r.remove(),new Error("Transition pseudo animations are unavailable");return l&&(p.pause(),p.currentTime=s),p.finished.then(()=>r.remove(),()=>r.remove()),p},O=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 h(t,{clipPath:[e[n],o[n]]})},_=t=>{let n=t.clipPathDirection??"top-left",{width:e,height:o}=y(),i=n.includes("-"),d=n.includes("left"),g=n.includes("top"),l=n==="left"||n==="right",s=d?0:n.includes("right")?1:.5,a=g?0:n.includes("bottom")?1:.5,r=i||l?e*3:e,m=i||!l?o*3:o,f=i?`${s*100},${a*100} ${(1-s)*100},${a*100} ${s*100},${(1-a)*100}`:"0,0 100,0 100,100 0,100",p=i?r*m/Math.hypot(r,m):l?r:m,$=1-Math.max(0,Math.min(t.gradientWidth??80,p*.2))/p,u=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><defs><linearGradient id="edge" x1="${s*100}" y1="${a*100}" x2="${100*(i?.5:l?1-s:s)}" y2="${100*(i?.5:l?a:1-a)}" gradientUnits="userSpaceOnUse"><stop offset="${$}" stop-color="black"/><stop offset="1" stop-color="black" stop-opacity="0"/></linearGradient></defs><polygon points="${f}" fill="url(#edge)"/></svg>`;return h(t,{maskImage:[`url("data:image/svg+xml,${encodeURIComponent(u)}")`,`url("data:image/svg+xml,${encodeURIComponent(u)}")`],maskMode:["alpha","alpha"],maskRepeat:["no-repeat","no-repeat"],maskSize:[i?"0px 0px":l?`0px ${m}px`:`${r}px 0px`,`${r}px ${m}px`],maskPosition:[`${s*e}px ${a*o}px`,`${s*(e-r)}px ${a*(o-m)}px`]})},F=t=>{let{x:n,y:e}=t,o=w(n,e),i=Math.sqrt(3)*o;return h(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)`]})},I=t=>{let{width:n,height:e}=y();return b({...t,x:n/2,y:e/2})},b=t=>{let{x:n,y:e}=t;return h(t,{clipPath:[`circle(0px at ${n}px ${e}px)`,`circle(${w(n,e)}px at ${n}px ${e}px)`]})},U=t=>{let{a:n=-100,b:e=0,x:o=0,y:i=0}=t;return h(t,{transform:[`translate(${n}%, ${e}%)`,`translate(${o}%, ${i}%)`]})},B=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 h(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`]})};var N="theme",K="color-theme",z="dark",j="theme-",H=400,W="cubic-bezier(0.32, 0.72, 0, 1)",Y=2,q="ui-theme-style";
|
|
18
|
+
export{k as a,E as b,C as c,M as d,R as e,T as f,P as g,D as h,L as i,O as j,_ as k,F as l,I as m,b as n,U as o,B as p,N as q,K as r,z as s,j as t,H as u,W as v,Y as w,q as x};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {parseArgs}from'util';import {readFile,writeFile,readdir}from'fs/promises';import u from'path';import {createInterface}from'readline/promises';var g,y,$,E,S=true;typeof process<"u"&&({FORCE_COLOR:g,NODE_DISABLE_COLORS:y,NO_COLOR:$,TERM:E}=process.env||{},S=process.stdout&&process.stdout.isTTY);var _={enabled:!y&&$==null&&E!=="dumb"&&(g!=null&&g!=="0"||S)};function o(e,t){let n=new RegExp(`\\x1b\\[${t}m`,"g"),r=`\x1B[${e}m`,i=`\x1B[${t}m`;return function(s){return !_.enabled||s==null?s:r+(~(""+s).indexOf(i)?s.replace(n,i+r):s)+i}}var a=o(1,22),p=o(2,22),f=o(31,39),d=o(32,39),m=o(33,39),w=o(34,39),O=o(36,39);var h="@ui-theme/web",c="uitheme-web",M=/(['"`])@ui-theme\/web(?![@\w-])(\/[^'"`\n]*)?\1/g,T=/node_modules\/@ui-theme\/web(?![\w-])/g,j=/"@ui-theme\/web"\s*:\s*"([^"]*)"/g;function A(e){return e.replace(M,(t,n,r)=>`${n}${c}${r??""}${n}`)}function D(e){return e.replace(T,`node_modules/${c}`)}function k(e){return D(A(e))}function C(e,t){let n=false,r=e.replace(j,(i,s)=>t===null?(n=true,`"${c}": "${s}"`):`"${c}": "^${t}"`);return {text:r,changed:r!==e,keptRange:n}}var U=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts",".css"]),F=new Set(["node_modules",".git",".next",".output",".svelte-kit",".turbo",".vercel",".cache","build","coverage","dist","out"]),G=12;async function Y(){try{let e=new URL("../../package.json",import.meta.url),t=JSON.parse(await readFile(e,"utf8")),n=String(t.version??"");return /^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/.test(n)?n:null}catch{return null}}async function N(e,t,n){if(n>G)return [];let r=await readdir(t,{withFileTypes:true}),i=[];for(let s of r){let l=u.join(t,s.name);if(s.isDirectory()){if(F.has(s.name))continue;i.push(...await N(e,l,n+1));continue}s.isFile()&&U.has(u.extname(s.name))&&i.push(l);}return i}async function B(e){let t=[];for(let n of await N(e,e,0)){let r=await readFile(n,"utf8"),i=k(r);i!==r&&t.push({file:n,before:r,after:i});}return t}async function W(e,t){let n=u.join(e,"package.json"),r;try{r=await readFile(n,"utf8");}catch{return null}let{text:i,changed:s,keptRange:l}=C(r,t);return s?{file:n,before:r,after:i,keptRange:l}:null}async function H(e){let t=createInterface({input:process.stdin,output:process.stdout});try{let n=await t.question(e);return /^y(es)?$/i.test(n.trim())}finally{t.close();}}function X(e,t,n){if(process.stdout.write(`
|
|
3
|
+
`),t.length===0&&n===null){process.stdout.write(`${d("Nothing to do.")} No file mentions ${h}.
|
|
4
|
+
|
|
5
|
+
`);return}process.stdout.write(`The migration will rewrite ${a(String(t.length+(n?1:0)))} file(s):
|
|
6
|
+
|
|
7
|
+
`);for(let r of t)process.stdout.write(` ${w(u.relative(e,r.file))}
|
|
8
|
+
`);n&&process.stdout.write(` ${w(u.relative(e,n.file))}
|
|
9
|
+
`),process.stdout.write(`
|
|
10
|
+
${h} becomes ${c}.
|
|
11
|
+
`),process.stdout.write(`${p("Entry points keep their names: /core, /react and /tanstack.")}
|
|
12
|
+
|
|
13
|
+
`);}async function P(e){await writeFile(e.file,e.after,"utf8");}async function R(e){let t=u.resolve(e.cwd),n=await Y(),r=await B(t),i=await W(t,n);if(X(t,r,i),r.length===0&&i===null)return 0;if(!e.yes&&!await H(`Rewrite these files? ${p("[y/N]")} `))return process.stdout.write(`
|
|
14
|
+
${m("Cancelled.")} No file was changed.
|
|
15
|
+
`),0;for(let l of r)await P(l);i&&await P(i);let s=r.length+(i?1:0);return process.stdout.write(`
|
|
16
|
+
${d("Done.")} Rewrote ${a(String(s))} file(s).
|
|
17
|
+
`),process.stdout.write(`Install the new package with ${O(`${a(c)}`)} and run your package manager.
|
|
18
|
+
|
|
19
|
+
`),i?.keptRange&&process.stdout.write(`${m("Note.")} The command could not read its own version, so the dependency range in package.json was left as it was. Set it to ^${c}'s current version by hand.
|
|
20
|
+
|
|
21
|
+
`),0}var v=`${a("uitheme-web")}
|
|
22
|
+
|
|
23
|
+
${a("Usage")}
|
|
24
|
+
uitheme-web <command> [options]
|
|
25
|
+
|
|
26
|
+
${a("Commands")}
|
|
27
|
+
migrate Move a project from @ui-theme/web to uitheme-web
|
|
28
|
+
|
|
29
|
+
${a("Options")}
|
|
30
|
+
-c, --cwd <dir> Project directory. Defaults to the current directory
|
|
31
|
+
-y, --yes Rewrite without asking for confirmation
|
|
32
|
+
-h, --help Show this help
|
|
33
|
+
|
|
34
|
+
${p("Example")}
|
|
35
|
+
npx uitheme-web migrate
|
|
36
|
+
`;function b(e){process.stderr.write(`${f(e)}
|
|
37
|
+
|
|
38
|
+
${v}`),process.exit(1);}async function K(e){let t,n;try{let s=parseArgs({args:e,allowPositionals:!0,options:{cwd:{type:"string",short:"c"},yes:{type:"boolean",short:"y",default:!1},help:{type:"boolean",short:"h",default:!1}}});t=s.values,n=s.positionals;}catch(s){b(s instanceof Error?s.message:String(s));}let[r,...i]=n;if(t.help||r===void 0||r==="help"){process.stdout.write(v);return}if(i.length>0&&b(`Unexpected argument: ${i.join(" ")}`),r==="migrate"){await R({cwd:t.cwd??process.cwd(),yes:t.yes??false});return}b(`Unknown command: ${r}`);}K(process.argv.slice(2)).catch(e=>{process.stderr.write(`${f("The command failed.")} ${e instanceof Error?e.message:String(e)}
|
|
39
|
+
`),process.exitCode=1;});
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
declare enum ThemeAnimationType {
|
|
2
|
+
CIRCLE = "circle",
|
|
3
|
+
BLUR_CIRCLE = "blur-circle",
|
|
4
|
+
SLIDE = "slide",
|
|
5
|
+
CLIP_PATH = "clip-path",
|
|
6
|
+
POLYGON_GRADIENT = "polygon-gradient",
|
|
7
|
+
TRIANGLE = "triangle",
|
|
8
|
+
SVG_LOGO = "svg-logo"
|
|
9
|
+
}
|
|
10
|
+
/** Clockwise from the top-left corner. */
|
|
11
|
+
declare const TRANSITION_DIRECTIONS: readonly ["top-left", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left"];
|
|
12
|
+
type TransitionDirection = (typeof TRANSITION_DIRECTIONS)[number];
|
|
13
|
+
type AnimationPosition = TransitionDirection | 'center' | 'trigger';
|
|
14
|
+
interface ThemeAnimationSettings {
|
|
15
|
+
/** Starting edge/corner for polygon wipes. Defaults to top-left. */
|
|
16
|
+
clipPathDirection?: TransitionDirection;
|
|
17
|
+
/** Fixed circle/triangle origin; SVG_LOGO always uses the viewport center. */
|
|
18
|
+
animationPosition?: AnimationPosition;
|
|
19
|
+
/** Stationary logo width in CSS pixels or auto; default is 96 when both are omitted. */
|
|
20
|
+
logoWidth?: number | 'auto';
|
|
21
|
+
/** Logo height in CSS pixels or auto; omitted dimensions preserve the SVG aspect ratio. */
|
|
22
|
+
logoHeight?: number | 'auto';
|
|
23
|
+
/** Gradient wipe feather in CSS pixels; defaults to 80. */
|
|
24
|
+
gradientWidth?: number;
|
|
25
|
+
}
|
|
26
|
+
/** Choose one shared asset, or both destination-specific assets. */
|
|
27
|
+
type ThemeLogoOptions = {
|
|
28
|
+
logo?: string;
|
|
29
|
+
logoLight?: never;
|
|
30
|
+
logoDark?: never;
|
|
31
|
+
} | {
|
|
32
|
+
logo?: never;
|
|
33
|
+
logoLight: string;
|
|
34
|
+
logoDark: string;
|
|
35
|
+
};
|
|
36
|
+
type ThemeAnimationOptions = ThemeAnimationSettings & ThemeLogoOptions;
|
|
37
|
+
type Theme = 'light' | 'dark' | 'system';
|
|
38
|
+
type ColorTheme = string;
|
|
39
|
+
type SlideDirection = 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
40
|
+
interface AnimationConfig extends ThemeAnimationSettings {
|
|
41
|
+
/** Asset already selected for the destination theme before capture. */
|
|
42
|
+
logo?: string;
|
|
43
|
+
a?: number;
|
|
44
|
+
b?: number;
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
duration: number;
|
|
48
|
+
easing: string;
|
|
49
|
+
animationType: ThemeAnimationType;
|
|
50
|
+
blurAmount: number;
|
|
51
|
+
styleId: string;
|
|
52
|
+
}
|
|
53
|
+
interface ThemeConfig {
|
|
54
|
+
themes?: Theme[];
|
|
55
|
+
colorThemes?: ColorTheme[];
|
|
56
|
+
defaultTheme?: Theme;
|
|
57
|
+
defaultColorTheme?: ColorTheme;
|
|
58
|
+
globalClassName?: string;
|
|
59
|
+
colorThemePrefix?: string;
|
|
60
|
+
storageKey?: string;
|
|
61
|
+
colorStorageKey?: string;
|
|
62
|
+
}
|
|
63
|
+
interface ThemeState {
|
|
64
|
+
theme: Theme;
|
|
65
|
+
colorTheme: ColorTheme;
|
|
66
|
+
resolvedTheme: 'light' | 'dark';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Injects styles scoped to transitions owned by this library. */
|
|
70
|
+
declare const injectBaseStyles: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Creates an SVG blur circle mask for animations
|
|
73
|
+
* @param blur - Blur amount for the gaussian filter
|
|
74
|
+
* @returns Data URI string for the SVG mask
|
|
75
|
+
*/
|
|
76
|
+
declare const createBlurCircleMask: (blur: number) => string;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the system theme preference
|
|
79
|
+
* @returns 'light' or 'dark' based on system preference
|
|
80
|
+
*/
|
|
81
|
+
declare const getSystemTheme: () => "light" | "dark";
|
|
82
|
+
/**
|
|
83
|
+
* Resolves a theme value to its actual light/dark value
|
|
84
|
+
* @param theme - Theme to resolve ('light', 'dark', or 'system')
|
|
85
|
+
* @returns Resolved theme ('light' or 'dark')
|
|
86
|
+
*/
|
|
87
|
+
declare const resolveTheme: (theme: string) => "light" | "dark";
|
|
88
|
+
/**
|
|
89
|
+
* Resolves a stored theme to the server-side class to apply on <html>.
|
|
90
|
+
* CSS mode uses the 'system' class so media queries can respond before hydration.
|
|
91
|
+
*/
|
|
92
|
+
declare const resolveThemeForServer: (theme: string) => "light" | "dark" | "system";
|
|
93
|
+
/**
|
|
94
|
+
* Checks if the browser supports View Transitions API
|
|
95
|
+
* @returns true if view transitions are supported
|
|
96
|
+
*/
|
|
97
|
+
declare const supportsViewTransitions: () => boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Checks if user prefers reduced motion
|
|
100
|
+
* @returns true if user prefers reduced motion
|
|
101
|
+
*/
|
|
102
|
+
declare const prefersReducedMotion: () => boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Converts a slide direction to from coordinates
|
|
105
|
+
* @param direction - Slide direction
|
|
106
|
+
* @returns Object with a (x) and b (y) coordinates
|
|
107
|
+
*/
|
|
108
|
+
declare const getSlideFromCoords: (direction: SlideDirection) => {
|
|
109
|
+
a: number;
|
|
110
|
+
b: number;
|
|
111
|
+
};
|
|
112
|
+
/** Viewport CSS coordinates for fixed origins; button origins stay in the hook. */
|
|
113
|
+
declare const getAnimationPosition: (position: Exclude<AnimationPosition, "trigger">) => {
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
};
|
|
117
|
+
/** A half-plane wipe, including diagonals, with compatible four-point polygons. */
|
|
118
|
+
declare const createClipPathAnimation: (config: AnimationConfig) => Animation;
|
|
119
|
+
/** Feathered polygon/edge mask, without Gaussian filtering or scaling content. */
|
|
120
|
+
declare const createPolygonGradientAnimation: (config: AnimationConfig) => Animation;
|
|
121
|
+
/** Upright triangle; its final incircle contains all four snapshot corners. */
|
|
122
|
+
declare const createTriangleAnimation: (config: AnimationConfig) => Animation;
|
|
123
|
+
/** The fixed logo has its own snapshot; only the page reveal grows beneath it. */
|
|
124
|
+
declare const createSvgLogoAnimation: (config: AnimationConfig) => Animation;
|
|
125
|
+
/** Native circular clip; browser compositor support varies by engine. */
|
|
126
|
+
declare const createCircleAnimation: (config: AnimationConfig) => Animation;
|
|
127
|
+
/** Predetermined translation uses WAAPI rather than a timer-owned stylesheet. */
|
|
128
|
+
declare const createSlideAnimation: (config: AnimationConfig) => Animation;
|
|
129
|
+
/**
|
|
130
|
+
* A bounded radial gradient feathers only the reveal edge. Unlike the old SVG
|
|
131
|
+
* Gaussian mask, it needs no huge filtered surface or animation on the old view.
|
|
132
|
+
* Mask animation can still paint; this is not a compositor-only guarantee.
|
|
133
|
+
*/
|
|
134
|
+
declare const createBlurCircleAnimation: (config: AnimationConfig) => Animation;
|
|
135
|
+
|
|
136
|
+
declare const STORAGE_KEY = "theme";
|
|
137
|
+
declare const COLOR_STORAGE_KEY = "color-theme";
|
|
138
|
+
declare const GLOBAL_CLASS_NAME = "dark";
|
|
139
|
+
declare const COLOR_THEME_PREFIX = "theme-";
|
|
140
|
+
declare const DEFAULT_DURATION = 400;
|
|
141
|
+
declare const DEFAULT_EASING = "cubic-bezier(0.32, 0.72, 0, 1)";
|
|
142
|
+
declare const DEFAULT_BLUR_AMOUNT = 2;
|
|
143
|
+
declare const DEFAULT_STYLE_ID = "ui-theme-style";
|
|
144
|
+
|
|
145
|
+
export { type AnimationConfig as A, prefersReducedMotion as B, type ColorTheme as C, DEFAULT_BLUR_AMOUNT as D, resolveTheme as E, supportsViewTransitions as F, GLOBAL_CLASS_NAME as G, resolveThemeForServer as H, STORAGE_KEY as S, type Theme as T, type AnimationPosition as a, COLOR_STORAGE_KEY as b, COLOR_THEME_PREFIX as c, DEFAULT_DURATION as d, DEFAULT_EASING as e, DEFAULT_STYLE_ID as f, type SlideDirection as g, TRANSITION_DIRECTIONS as h, type ThemeAnimationOptions as i, ThemeAnimationType as j, type ThemeConfig as k, type ThemeLogoOptions as l, type ThemeState as m, type TransitionDirection as n, createBlurCircleAnimation as o, createBlurCircleMask as p, createCircleAnimation as q, createClipPathAnimation as r, createPolygonGradientAnimation as s, createSlideAnimation as t, createSvgLogoAnimation as u, createTriangleAnimation as v, getAnimationPosition as w, getSlideFromCoords as x, getSystemTheme as y, injectBaseStyles as z };
|