uitheme-web 1.1.0 → 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 +149 -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 +22 -294
- 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 +18 -14
- package/dist/constants-n21pnuRC.d.cts +0 -106
- package/dist/constants-n21pnuRC.d.ts +0 -106
package/dist/tanstack/index.cjs
CHANGED
|
@@ -1,30 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// src/core/constants.ts
|
|
4
|
-
var STORAGE_KEY = "theme";
|
|
5
|
-
var COLOR_STORAGE_KEY = "color-theme";
|
|
6
|
-
|
|
7
|
-
// src/core/animations.ts
|
|
8
|
-
var resolveThemeForServer = (theme) => {
|
|
9
|
-
if (theme === "system") {
|
|
10
|
-
return "system";
|
|
11
|
-
}
|
|
12
|
-
return theme === "dark" ? "dark" : "light";
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/tanstack/index.ts
|
|
16
|
-
function buildServerThemeData(themeCookie, colorThemeCookie, options = {}) {
|
|
17
|
-
const { defaultTheme = "system", defaultColorTheme = "default" } = options;
|
|
18
|
-
const themePreference = themeCookie ?? defaultTheme;
|
|
19
|
-
const colorTheme = colorThemeCookie ?? defaultColorTheme;
|
|
20
|
-
return {
|
|
21
|
-
theme: resolveThemeForServer(themePreference),
|
|
22
|
-
themePreference,
|
|
23
|
-
colorTheme
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
exports.COLOR_STORAGE_KEY = COLOR_STORAGE_KEY;
|
|
28
|
-
exports.STORAGE_KEY = STORAGE_KEY;
|
|
29
|
-
exports.buildServerThemeData = buildServerThemeData;
|
|
30
|
-
exports.resolveThemeForServer = resolveThemeForServer;
|
|
1
|
+
'use strict';var chunkW4YFUPGE_cjs=require('../chunk-W4YFUPGE.cjs');function a(e,m,o={}){let{defaultTheme:h="system",defaultColorTheme:T="default"}=o,t=e==="light"||e==="dark"||e==="system"?e:h,s=m??T;return {theme:chunkW4YFUPGE_cjs.e(t),themePreference:t,colorTheme:s}}Object.defineProperty(exports,"COLOR_STORAGE_KEY",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.r}});Object.defineProperty(exports,"STORAGE_KEY",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.q}});Object.defineProperty(exports,"resolveThemeForServer",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.e}});exports.buildServerThemeData=a;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as Theme } from '../constants-
|
|
2
|
-
export {
|
|
1
|
+
import { T as Theme } from '../constants-DmZ7yAIL.cjs';
|
|
2
|
+
export { b as COLOR_STORAGE_KEY, C as ColorTheme, S as STORAGE_KEY, H as resolveThemeForServer } from '../constants-DmZ7yAIL.cjs';
|
|
3
3
|
|
|
4
4
|
/** Resolved theme class to apply on <html> */
|
|
5
5
|
type ServerResolvedTheme = 'light' | 'dark' | 'system';
|
package/dist/tanstack/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as Theme } from '../constants-
|
|
2
|
-
export {
|
|
1
|
+
import { T as Theme } from '../constants-DmZ7yAIL.js';
|
|
2
|
+
export { b as COLOR_STORAGE_KEY, C as ColorTheme, S as STORAGE_KEY, H as resolveThemeForServer } from '../constants-DmZ7yAIL.js';
|
|
3
3
|
|
|
4
4
|
/** Resolved theme class to apply on <html> */
|
|
5
5
|
type ServerResolvedTheme = 'light' | 'dark' | 'system';
|
package/dist/tanstack/index.js
CHANGED
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var STORAGE_KEY = "theme";
|
|
3
|
-
var COLOR_STORAGE_KEY = "color-theme";
|
|
4
|
-
|
|
5
|
-
// src/core/animations.ts
|
|
6
|
-
var resolveThemeForServer = (theme) => {
|
|
7
|
-
if (theme === "system") {
|
|
8
|
-
return "system";
|
|
9
|
-
}
|
|
10
|
-
return theme === "dark" ? "dark" : "light";
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// src/tanstack/index.ts
|
|
14
|
-
function buildServerThemeData(themeCookie, colorThemeCookie, options = {}) {
|
|
15
|
-
const { defaultTheme = "system", defaultColorTheme = "default" } = options;
|
|
16
|
-
const themePreference = themeCookie ?? defaultTheme;
|
|
17
|
-
const colorTheme = colorThemeCookie ?? defaultColorTheme;
|
|
18
|
-
return {
|
|
19
|
-
theme: resolveThemeForServer(themePreference),
|
|
20
|
-
themePreference,
|
|
21
|
-
colorTheme
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { COLOR_STORAGE_KEY, STORAGE_KEY, buildServerThemeData, resolveThemeForServer };
|
|
1
|
+
import {e}from'../chunk-WFG34KG5.js';export{r as COLOR_STORAGE_KEY,q as STORAGE_KEY,e as resolveThemeForServer}from'../chunk-WFG34KG5.js';function a(e$1,m,o={}){let{defaultTheme:h="system",defaultColorTheme:T="default"}=o,t=e$1==="light"||e$1==="dark"||e$1==="system"?e$1:h,s=m??T;return {theme:e(t),themePreference:t,colorTheme:s}}export{a as buildServerThemeData};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uitheme-web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Cross-framework UI theme switching library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -84,23 +84,27 @@
|
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@
|
|
88
|
-
"@
|
|
89
|
-
"@
|
|
90
|
-
"@types/react": "^19.
|
|
91
|
-
"@types/react-dom": "^19.0.0",
|
|
87
|
+
"@playwright/test": "1.62.1",
|
|
88
|
+
"@radix-ui/react-select": "^2.3.7",
|
|
89
|
+
"@types/react": "^19.3.0",
|
|
90
|
+
"@types/react-dom": "^19.3.0",
|
|
92
91
|
"kleur": "^4.1.5",
|
|
93
|
-
"react": "^19.
|
|
94
|
-
"react-dom": "^19.
|
|
95
|
-
"
|
|
96
|
-
"vue": "^3.5.0"
|
|
92
|
+
"react": "^19.3.0",
|
|
93
|
+
"react-dom": "^19.3.0",
|
|
94
|
+
"vite": "^7.3.7"
|
|
97
95
|
},
|
|
98
96
|
"scripts": {
|
|
99
|
-
"build": "rm -rf dist && tsup",
|
|
97
|
+
"build": "rm -rf dist && tsup && node scripts/mark-react-client.mjs",
|
|
100
98
|
"dev": "tsup --watch",
|
|
101
99
|
"typecheck": "tsc --noEmit",
|
|
102
|
-
"test": "vitest run --passWithNoTests",
|
|
103
|
-
"test:watch": "vitest",
|
|
104
|
-
"clean": "rm -rf dist"
|
|
100
|
+
"test": "vitest run --passWithNoTests --exclude \"tests/browser/**\"",
|
|
101
|
+
"test:watch": "vitest --exclude \"tests/browser/**\"",
|
|
102
|
+
"clean": "rm -rf dist",
|
|
103
|
+
"test:browser": "playwright test",
|
|
104
|
+
"test:browser:serve": "vite tests/browser --host 127.0.0.1 --port 4179 --strictPort",
|
|
105
|
+
"lint": "eslint .",
|
|
106
|
+
"lint:fix": "eslint . --fix",
|
|
107
|
+
"test:types": "tsc --noEmit -p tests/types/tsconfig.json",
|
|
108
|
+
"test:package": "node scripts/smoke-package.mjs"
|
|
105
109
|
}
|
|
106
110
|
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
declare enum ThemeAnimationType {
|
|
2
|
-
CIRCLE = "circle",
|
|
3
|
-
BLUR_CIRCLE = "blur-circle",
|
|
4
|
-
SLIDE = "slide"
|
|
5
|
-
}
|
|
6
|
-
type Theme = 'light' | 'dark' | 'system';
|
|
7
|
-
type ColorTheme = string;
|
|
8
|
-
type SlideDirection = 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
9
|
-
interface AnimationConfig {
|
|
10
|
-
a?: number;
|
|
11
|
-
b?: number;
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
duration: number;
|
|
15
|
-
easing: string;
|
|
16
|
-
animationType: ThemeAnimationType;
|
|
17
|
-
blurAmount: number;
|
|
18
|
-
styleId: string;
|
|
19
|
-
}
|
|
20
|
-
interface ThemeConfig {
|
|
21
|
-
themes?: Theme[];
|
|
22
|
-
colorThemes?: ColorTheme[];
|
|
23
|
-
defaultTheme?: Theme;
|
|
24
|
-
defaultColorTheme?: ColorTheme;
|
|
25
|
-
globalClassName?: string;
|
|
26
|
-
colorThemePrefix?: string;
|
|
27
|
-
storageKey?: string;
|
|
28
|
-
colorStorageKey?: string;
|
|
29
|
-
}
|
|
30
|
-
interface ThemeState {
|
|
31
|
-
theme: Theme;
|
|
32
|
-
colorTheme: ColorTheme;
|
|
33
|
-
resolvedTheme: 'light' | 'dark';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Injects base styles required for view transitions
|
|
38
|
-
*/
|
|
39
|
-
declare const injectBaseStyles: () => void;
|
|
40
|
-
/**
|
|
41
|
-
* Creates an SVG blur circle mask for animations
|
|
42
|
-
* @param blur - Blur amount for the gaussian filter
|
|
43
|
-
* @returns Data URI string for the SVG mask
|
|
44
|
-
*/
|
|
45
|
-
declare const createBlurCircleMask: (blur: number) => string;
|
|
46
|
-
/**
|
|
47
|
-
* Gets the system theme preference
|
|
48
|
-
* @returns 'light' or 'dark' based on system preference
|
|
49
|
-
*/
|
|
50
|
-
declare const getSystemTheme: () => "light" | "dark";
|
|
51
|
-
/**
|
|
52
|
-
* Resolves a theme value to its actual light/dark value
|
|
53
|
-
* @param theme - Theme to resolve ('light', 'dark', or 'system')
|
|
54
|
-
* @returns Resolved theme ('light' or 'dark')
|
|
55
|
-
*/
|
|
56
|
-
declare const resolveTheme: (theme: string) => "light" | "dark";
|
|
57
|
-
/**
|
|
58
|
-
* Resolves a stored theme to the server-side class to apply on <html>.
|
|
59
|
-
* CSS mode uses the 'system' class so media queries can respond before hydration.
|
|
60
|
-
*/
|
|
61
|
-
declare const resolveThemeForServer: (theme: string) => "light" | "dark" | "system";
|
|
62
|
-
/**
|
|
63
|
-
* Checks if the browser supports View Transitions API
|
|
64
|
-
* @returns true if view transitions are supported
|
|
65
|
-
*/
|
|
66
|
-
declare const supportsViewTransitions: () => boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Checks if user prefers reduced motion
|
|
69
|
-
* @returns true if user prefers reduced motion
|
|
70
|
-
*/
|
|
71
|
-
declare const prefersReducedMotion: () => boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Converts a slide direction to from coordinates
|
|
74
|
-
* @param direction - Slide direction
|
|
75
|
-
* @returns Object with a (x) and b (y) coordinates
|
|
76
|
-
*/
|
|
77
|
-
declare const getSlideFromCoords: (direction: SlideDirection) => {
|
|
78
|
-
a: number;
|
|
79
|
-
b: number;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Creates a circle expanding animation for theme transitions
|
|
83
|
-
* @param config - Animation configuration
|
|
84
|
-
*/
|
|
85
|
-
declare const createCircleAnimation: (config: AnimationConfig) => void;
|
|
86
|
-
/**
|
|
87
|
-
* Creates a slide animation for theme transitions
|
|
88
|
-
* @param config - Animation configuration
|
|
89
|
-
*/
|
|
90
|
-
declare const createSlideAnimation: (config: AnimationConfig) => void;
|
|
91
|
-
/**
|
|
92
|
-
* Creates a blur circle animation for theme transitions
|
|
93
|
-
* @param config - Animation configuration
|
|
94
|
-
*/
|
|
95
|
-
declare const createBlurCircleAnimation: (config: AnimationConfig) => void;
|
|
96
|
-
|
|
97
|
-
declare const STORAGE_KEY = "theme";
|
|
98
|
-
declare const COLOR_STORAGE_KEY = "color-theme";
|
|
99
|
-
declare const GLOBAL_CLASS_NAME = "dark";
|
|
100
|
-
declare const COLOR_THEME_PREFIX = "theme-";
|
|
101
|
-
declare const DEFAULT_DURATION = 750;
|
|
102
|
-
declare const DEFAULT_EASING = "ease-in-out";
|
|
103
|
-
declare const DEFAULT_BLUR_AMOUNT = 2;
|
|
104
|
-
declare const DEFAULT_STYLE_ID = "ui-theme-style";
|
|
105
|
-
|
|
106
|
-
export { type AnimationConfig as A, type ColorTheme as C, DEFAULT_DURATION as D, GLOBAL_CLASS_NAME as G, type SlideDirection as S, type Theme as T, ThemeAnimationType as a, type ThemeConfig as b, type ThemeState as c, createCircleAnimation as d, createBlurCircleAnimation as e, createSlideAnimation as f, getSystemTheme as g, createBlurCircleMask as h, injectBaseStyles as i, getSlideFromCoords as j, STORAGE_KEY as k, COLOR_STORAGE_KEY as l, COLOR_THEME_PREFIX as m, DEFAULT_EASING as n, DEFAULT_BLUR_AMOUNT as o, prefersReducedMotion as p, DEFAULT_STYLE_ID as q, resolveTheme as r, supportsViewTransitions as s, resolveThemeForServer as t };
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
declare enum ThemeAnimationType {
|
|
2
|
-
CIRCLE = "circle",
|
|
3
|
-
BLUR_CIRCLE = "blur-circle",
|
|
4
|
-
SLIDE = "slide"
|
|
5
|
-
}
|
|
6
|
-
type Theme = 'light' | 'dark' | 'system';
|
|
7
|
-
type ColorTheme = string;
|
|
8
|
-
type SlideDirection = 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
9
|
-
interface AnimationConfig {
|
|
10
|
-
a?: number;
|
|
11
|
-
b?: number;
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
duration: number;
|
|
15
|
-
easing: string;
|
|
16
|
-
animationType: ThemeAnimationType;
|
|
17
|
-
blurAmount: number;
|
|
18
|
-
styleId: string;
|
|
19
|
-
}
|
|
20
|
-
interface ThemeConfig {
|
|
21
|
-
themes?: Theme[];
|
|
22
|
-
colorThemes?: ColorTheme[];
|
|
23
|
-
defaultTheme?: Theme;
|
|
24
|
-
defaultColorTheme?: ColorTheme;
|
|
25
|
-
globalClassName?: string;
|
|
26
|
-
colorThemePrefix?: string;
|
|
27
|
-
storageKey?: string;
|
|
28
|
-
colorStorageKey?: string;
|
|
29
|
-
}
|
|
30
|
-
interface ThemeState {
|
|
31
|
-
theme: Theme;
|
|
32
|
-
colorTheme: ColorTheme;
|
|
33
|
-
resolvedTheme: 'light' | 'dark';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Injects base styles required for view transitions
|
|
38
|
-
*/
|
|
39
|
-
declare const injectBaseStyles: () => void;
|
|
40
|
-
/**
|
|
41
|
-
* Creates an SVG blur circle mask for animations
|
|
42
|
-
* @param blur - Blur amount for the gaussian filter
|
|
43
|
-
* @returns Data URI string for the SVG mask
|
|
44
|
-
*/
|
|
45
|
-
declare const createBlurCircleMask: (blur: number) => string;
|
|
46
|
-
/**
|
|
47
|
-
* Gets the system theme preference
|
|
48
|
-
* @returns 'light' or 'dark' based on system preference
|
|
49
|
-
*/
|
|
50
|
-
declare const getSystemTheme: () => "light" | "dark";
|
|
51
|
-
/**
|
|
52
|
-
* Resolves a theme value to its actual light/dark value
|
|
53
|
-
* @param theme - Theme to resolve ('light', 'dark', or 'system')
|
|
54
|
-
* @returns Resolved theme ('light' or 'dark')
|
|
55
|
-
*/
|
|
56
|
-
declare const resolveTheme: (theme: string) => "light" | "dark";
|
|
57
|
-
/**
|
|
58
|
-
* Resolves a stored theme to the server-side class to apply on <html>.
|
|
59
|
-
* CSS mode uses the 'system' class so media queries can respond before hydration.
|
|
60
|
-
*/
|
|
61
|
-
declare const resolveThemeForServer: (theme: string) => "light" | "dark" | "system";
|
|
62
|
-
/**
|
|
63
|
-
* Checks if the browser supports View Transitions API
|
|
64
|
-
* @returns true if view transitions are supported
|
|
65
|
-
*/
|
|
66
|
-
declare const supportsViewTransitions: () => boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Checks if user prefers reduced motion
|
|
69
|
-
* @returns true if user prefers reduced motion
|
|
70
|
-
*/
|
|
71
|
-
declare const prefersReducedMotion: () => boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Converts a slide direction to from coordinates
|
|
74
|
-
* @param direction - Slide direction
|
|
75
|
-
* @returns Object with a (x) and b (y) coordinates
|
|
76
|
-
*/
|
|
77
|
-
declare const getSlideFromCoords: (direction: SlideDirection) => {
|
|
78
|
-
a: number;
|
|
79
|
-
b: number;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Creates a circle expanding animation for theme transitions
|
|
83
|
-
* @param config - Animation configuration
|
|
84
|
-
*/
|
|
85
|
-
declare const createCircleAnimation: (config: AnimationConfig) => void;
|
|
86
|
-
/**
|
|
87
|
-
* Creates a slide animation for theme transitions
|
|
88
|
-
* @param config - Animation configuration
|
|
89
|
-
*/
|
|
90
|
-
declare const createSlideAnimation: (config: AnimationConfig) => void;
|
|
91
|
-
/**
|
|
92
|
-
* Creates a blur circle animation for theme transitions
|
|
93
|
-
* @param config - Animation configuration
|
|
94
|
-
*/
|
|
95
|
-
declare const createBlurCircleAnimation: (config: AnimationConfig) => void;
|
|
96
|
-
|
|
97
|
-
declare const STORAGE_KEY = "theme";
|
|
98
|
-
declare const COLOR_STORAGE_KEY = "color-theme";
|
|
99
|
-
declare const GLOBAL_CLASS_NAME = "dark";
|
|
100
|
-
declare const COLOR_THEME_PREFIX = "theme-";
|
|
101
|
-
declare const DEFAULT_DURATION = 750;
|
|
102
|
-
declare const DEFAULT_EASING = "ease-in-out";
|
|
103
|
-
declare const DEFAULT_BLUR_AMOUNT = 2;
|
|
104
|
-
declare const DEFAULT_STYLE_ID = "ui-theme-style";
|
|
105
|
-
|
|
106
|
-
export { type AnimationConfig as A, type ColorTheme as C, DEFAULT_DURATION as D, GLOBAL_CLASS_NAME as G, type SlideDirection as S, type Theme as T, ThemeAnimationType as a, type ThemeConfig as b, type ThemeState as c, createCircleAnimation as d, createBlurCircleAnimation as e, createSlideAnimation as f, getSystemTheme as g, createBlurCircleMask as h, injectBaseStyles as i, getSlideFromCoords as j, STORAGE_KEY as k, COLOR_STORAGE_KEY as l, COLOR_THEME_PREFIX as m, DEFAULT_EASING as n, DEFAULT_BLUR_AMOUNT as o, prefersReducedMotion as p, DEFAULT_STYLE_ID as q, resolveTheme as r, supportsViewTransitions as s, resolveThemeForServer as t };
|