@space-man/react-theme-animation 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +623 -0
- package/dist/cjs/components/SpacemanThemeProvider.d.ts +51 -0
- package/dist/cjs/components/SpacemanThemeProvider.js +93 -0
- package/dist/cjs/components/ThemeSelector.d.ts +3 -0
- package/dist/cjs/components/ThemeSelector.js +39 -0
- package/dist/cjs/components/ThemeSwitcher.d.ts +3 -0
- package/dist/cjs/components/ThemeSwitcher.js +100 -0
- package/dist/cjs/components/ui/select.d.ts +15 -0
- package/dist/cjs/components/ui/select.js +83 -0
- package/dist/cjs/hooks/use-theme-animation.d.ts +2 -0
- package/dist/cjs/hooks/use-theme-animation.js +149 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/types/index.d.ts +65 -0
- package/dist/cjs/types/index.js +8 -0
- package/dist/cjs/utils/animations.d.ts +18 -0
- package/dist/cjs/utils/animations.js +156 -0
- package/dist/components/SpacemanThemeProvider.d.ts +51 -0
- package/dist/components/SpacemanThemeProvider.js +88 -0
- package/dist/components/ThemeSelector.d.ts +3 -0
- package/dist/components/ThemeSelector.js +35 -0
- package/dist/components/ThemeSwitcher.d.ts +3 -0
- package/dist/components/ThemeSwitcher.js +96 -0
- package/dist/components/ui/select.d.ts +15 -0
- package/dist/components/ui/select.js +39 -0
- package/dist/esm/components/SpacemanThemeProvider.d.ts +51 -0
- package/dist/esm/components/SpacemanThemeProvider.js +88 -0
- package/dist/esm/components/ThemeSelector.d.ts +3 -0
- package/dist/esm/components/ThemeSelector.js +35 -0
- package/dist/esm/components/ThemeSwitcher.d.ts +3 -0
- package/dist/esm/components/ThemeSwitcher.js +96 -0
- package/dist/esm/components/ui/select.d.ts +15 -0
- package/dist/esm/components/ui/select.js +39 -0
- package/dist/esm/hooks/use-theme-animation.d.ts +2 -0
- package/dist/esm/hooks/use-theme-animation.js +145 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/types/index.d.ts +65 -0
- package/dist/esm/types/index.js +5 -0
- package/dist/esm/utils/animations.d.ts +18 -0
- package/dist/esm/utils/animations.js +145 -0
- package/dist/hooks/use-theme-animation.d.ts +2 -0
- package/dist/hooks/use-theme-animation.js +145 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/types/index.d.ts +65 -0
- package/dist/types/index.js +5 -0
- package/dist/utils/animations.d.ts +18 -0
- package/dist/utils/animations.js +145 -0
- package/package.json +74 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSpacemanTheme = exports.SpacemanThemeProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const use_theme_animation_1 = require("../hooks/use-theme-animation");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const SpacemanThemeContext = (0, react_1.createContext)(undefined);
|
|
9
|
+
/**
|
|
10
|
+
* Spaceman Theme Provider - Provides centralized theme state management
|
|
11
|
+
*
|
|
12
|
+
* This provider creates a single source of truth for theme state using the useThemeAnimation hook.
|
|
13
|
+
* All theme-related components should consume from this context to ensure synchronization.
|
|
14
|
+
*
|
|
15
|
+
* @param children - React children to wrap with theme context
|
|
16
|
+
* @param themes - Available theme options (default: ['light', 'dark', 'system'])
|
|
17
|
+
* @param colorThemes - Available color theme options (default: ['default'])
|
|
18
|
+
* @param defaultTheme - Default theme to use (default: 'system')
|
|
19
|
+
* @param defaultColorTheme - Default color theme to use (default: 'default')
|
|
20
|
+
* @param animationType - Animation type for theme transitions (default: CIRCLE)
|
|
21
|
+
* @param duration - Animation duration in milliseconds (default: 750)
|
|
22
|
+
*/
|
|
23
|
+
const SpacemanThemeProvider = ({ children, themes = ['light', 'dark', 'system'], colorThemes = ['default'], defaultTheme = 'system', defaultColorTheme = 'default', animationType = types_1.ThemeAnimationType.CIRCLE, duration = 750, }) => {
|
|
24
|
+
// This is our master hook instance - the single source of truth
|
|
25
|
+
const themeState = (0, use_theme_animation_1.useThemeAnimation)({
|
|
26
|
+
themes,
|
|
27
|
+
colorThemes,
|
|
28
|
+
defaultTheme,
|
|
29
|
+
defaultColorTheme,
|
|
30
|
+
animationType,
|
|
31
|
+
duration,
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Switch theme with animation originating from a specific element
|
|
35
|
+
*
|
|
36
|
+
* @param theme - Theme to switch to
|
|
37
|
+
* @param element - HTML button element to use as animation origin
|
|
38
|
+
*/
|
|
39
|
+
const switchThemeFromElement = async (theme, element) => {
|
|
40
|
+
// Temporarily set the ref to the clicked element
|
|
41
|
+
if (themeState.ref.current) {
|
|
42
|
+
const originalRef = themeState.ref.current;
|
|
43
|
+
// Use Object.defineProperty to temporarily override the ref
|
|
44
|
+
Object.defineProperty(themeState.ref, 'current', {
|
|
45
|
+
value: element,
|
|
46
|
+
writable: true,
|
|
47
|
+
configurable: true
|
|
48
|
+
});
|
|
49
|
+
await themeState.switchTheme(theme);
|
|
50
|
+
// Restore the original ref after animation
|
|
51
|
+
Object.defineProperty(themeState.ref, 'current', {
|
|
52
|
+
value: originalRef,
|
|
53
|
+
writable: true,
|
|
54
|
+
configurable: true
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
Object.defineProperty(themeState.ref, 'current', {
|
|
59
|
+
value: element,
|
|
60
|
+
writable: true,
|
|
61
|
+
configurable: true
|
|
62
|
+
});
|
|
63
|
+
await themeState.switchTheme(theme);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const contextValue = {
|
|
67
|
+
theme: themeState.theme,
|
|
68
|
+
colorTheme: themeState.colorTheme,
|
|
69
|
+
resolvedTheme: themeState.resolvedTheme,
|
|
70
|
+
setTheme: themeState.setTheme,
|
|
71
|
+
setColorTheme: themeState.setColorTheme,
|
|
72
|
+
toggleTheme: themeState.toggleTheme,
|
|
73
|
+
switchTheme: themeState.switchTheme,
|
|
74
|
+
switchThemeFromElement,
|
|
75
|
+
ref: themeState.ref,
|
|
76
|
+
};
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)(SpacemanThemeContext.Provider, { value: contextValue, children: children }));
|
|
78
|
+
};
|
|
79
|
+
exports.SpacemanThemeProvider = SpacemanThemeProvider;
|
|
80
|
+
/**
|
|
81
|
+
* Hook to consume the Spaceman Theme context
|
|
82
|
+
*
|
|
83
|
+
* @returns Theme context value with all theme state and methods
|
|
84
|
+
* @throws Error if used outside of SpacemanThemeProvider
|
|
85
|
+
*/
|
|
86
|
+
const useSpacemanTheme = () => {
|
|
87
|
+
const context = (0, react_1.useContext)(SpacemanThemeContext);
|
|
88
|
+
if (context === undefined) {
|
|
89
|
+
throw new Error('useSpacemanTheme must be used within a SpacemanThemeProvider');
|
|
90
|
+
}
|
|
91
|
+
return context;
|
|
92
|
+
};
|
|
93
|
+
exports.useSpacemanTheme = useSpacemanTheme;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThemeSelector = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const use_theme_animation_1 = require("../hooks/use-theme-animation");
|
|
6
|
+
const SpacemanThemeProvider_1 = require("./SpacemanThemeProvider");
|
|
7
|
+
const select_1 = require("./ui/select");
|
|
8
|
+
const ThemeSelector = ({ themes = ['light', 'dark', 'system'], colorThemes = ['default'], currentColorTheme, onColorThemeChange, animationType, duration, }) => {
|
|
9
|
+
// Try to use SpacemanTheme context if available (controlled mode)
|
|
10
|
+
let contextTheme = null;
|
|
11
|
+
try {
|
|
12
|
+
contextTheme = (0, SpacemanThemeProvider_1.useSpacemanTheme)();
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// Context not available, use standalone mode
|
|
16
|
+
}
|
|
17
|
+
// Use context if available, otherwise fall back to standalone hook
|
|
18
|
+
const standaloneHook = (0, use_theme_animation_1.useThemeAnimation)({
|
|
19
|
+
animationType,
|
|
20
|
+
duration,
|
|
21
|
+
themes,
|
|
22
|
+
colorThemes,
|
|
23
|
+
...(currentColorTheme !== undefined && { colorTheme: currentColorTheme }),
|
|
24
|
+
onColorThemeChange,
|
|
25
|
+
});
|
|
26
|
+
const isControlled = contextTheme !== null;
|
|
27
|
+
const { colorTheme, setColorTheme } = isControlled ?
|
|
28
|
+
{ colorTheme: contextTheme.colorTheme, setColorTheme: contextTheme.setColorTheme } :
|
|
29
|
+
standaloneHook;
|
|
30
|
+
const handleColorThemeChange = (newColorTheme) => {
|
|
31
|
+
setColorTheme(newColorTheme);
|
|
32
|
+
// Also call the callback if provided
|
|
33
|
+
if (onColorThemeChange) {
|
|
34
|
+
onColorThemeChange(newColorTheme);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: colorThemes.length > 1 && ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-2", children: (0, jsx_runtime_1.jsxs)(select_1.Select, { value: colorTheme, onValueChange: (v) => handleColorThemeChange(v), children: [(0, jsx_runtime_1.jsx)(select_1.SelectTrigger, { className: "capitalize", children: (0, jsx_runtime_1.jsx)(select_1.SelectValue, { placeholder: "Choose a color theme" }) }), (0, jsx_runtime_1.jsx)(select_1.SelectContent, { children: colorThemes.map(theme => ((0, jsx_runtime_1.jsx)(select_1.SelectItem, { className: "capitalize", value: theme, children: theme }, theme))) })] }) })) }));
|
|
38
|
+
};
|
|
39
|
+
exports.ThemeSelector = ThemeSelector;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThemeSwitcher = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("motion/react");
|
|
7
|
+
const clsx_1 = require("clsx");
|
|
8
|
+
const use_theme_animation_1 = require("../hooks/use-theme-animation");
|
|
9
|
+
const SpacemanThemeProvider_1 = require("./SpacemanThemeProvider");
|
|
10
|
+
const SunIcon = () => ((0, jsx_runtime_1.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [(0, jsx_runtime_1.jsx)("circle", { cx: "12", cy: "12", r: "5" }), (0, jsx_runtime_1.jsx)("path", { d: "M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42" })] }));
|
|
11
|
+
const MoonIcon = () => ((0, jsx_runtime_1.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: (0, jsx_runtime_1.jsx)("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }) }));
|
|
12
|
+
const MonitorIcon = () => ((0, jsx_runtime_1.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [(0, jsx_runtime_1.jsx)("rect", { width: "20", height: "14", x: "2", y: "3", rx: "2" }), (0, jsx_runtime_1.jsx)("line", { x1: "8", x2: "16", y1: "21", y2: "21" }), (0, jsx_runtime_1.jsx)("line", { x1: "12", x2: "12", y1: "17", y2: "21" })] }));
|
|
13
|
+
const ThemeOption = ({ icon, value, isActive, isHovered, onClick, onMouseEnter, onMouseLeave, buttonRef, }) => {
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)("button", { ref: isActive ? buttonRef : undefined, className: (0, clsx_1.clsx)('relative flex h-9 w-12 cursor-pointer items-center justify-center transition-all duration-200 ease-in-out', 'text-muted-foreground hover:text-foreground', isActive && 'text-foreground font-medium'), role: "radio", "aria-checked": isActive, "aria-label": `Switch to ${value} theme`, onClick: (event) => onClick(value, event), onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, style: {
|
|
15
|
+
borderRadius: 'var(--radius)',
|
|
16
|
+
}, children: [isHovered && ((0, jsx_runtime_1.jsx)(react_2.motion.div, { layoutId: "theme-hover-bg", className: "absolute inset-0 bg-muted backdrop-blur-sm", style: {
|
|
17
|
+
borderRadius: 'var(--radius)',
|
|
18
|
+
}, transition: {
|
|
19
|
+
type: 'spring',
|
|
20
|
+
bounce: 0,
|
|
21
|
+
stiffness: 100,
|
|
22
|
+
damping: 10,
|
|
23
|
+
duration: 0.3,
|
|
24
|
+
} })), (0, jsx_runtime_1.jsx)(react_2.motion.div, { className: "relative z-10 flex items-center justify-center", animate: {
|
|
25
|
+
scale: isActive ? 1.1 : 1,
|
|
26
|
+
}, transition: {
|
|
27
|
+
type: 'spring',
|
|
28
|
+
bounce: 0.2,
|
|
29
|
+
duration: 0.4,
|
|
30
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: "[&_svg]:size-4", children: icon }) }), isActive && ((0, jsx_runtime_1.jsx)(react_2.motion.div, { layoutId: "theme-active-indicator", className: "absolute bottom-0 left-1/2 h-0.5 w-6 -translate-x-1/2 rounded-full", style: {
|
|
31
|
+
backgroundColor: 'hsl(var(--primary))',
|
|
32
|
+
}, transition: {
|
|
33
|
+
type: 'spring',
|
|
34
|
+
bounce: 0.3,
|
|
35
|
+
duration: 0.6,
|
|
36
|
+
} }))] }));
|
|
37
|
+
};
|
|
38
|
+
const THEME_OPTIONS = [
|
|
39
|
+
{
|
|
40
|
+
icon: (0, jsx_runtime_1.jsx)(MonitorIcon, {}),
|
|
41
|
+
value: 'system',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
icon: (0, jsx_runtime_1.jsx)(SunIcon, {}),
|
|
45
|
+
value: 'light',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
icon: (0, jsx_runtime_1.jsx)(MoonIcon, {}),
|
|
49
|
+
value: 'dark',
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
const ThemeSwitcher = ({ themes = ['light', 'dark', 'system'], currentTheme, onThemeChange, animationType, duration, className, }) => {
|
|
53
|
+
// Try to use SpacemanTheme context if available (controlled mode)
|
|
54
|
+
let contextTheme = null;
|
|
55
|
+
try {
|
|
56
|
+
contextTheme = (0, SpacemanThemeProvider_1.useSpacemanTheme)();
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Context not available, use standalone mode
|
|
60
|
+
}
|
|
61
|
+
// Use context if available, otherwise fall back to standalone hook
|
|
62
|
+
const standaloneHook = (0, use_theme_animation_1.useThemeAnimation)({
|
|
63
|
+
animationType,
|
|
64
|
+
duration,
|
|
65
|
+
themes,
|
|
66
|
+
...(currentTheme !== undefined && { theme: currentTheme }),
|
|
67
|
+
onThemeChange,
|
|
68
|
+
});
|
|
69
|
+
const isControlled = contextTheme !== null;
|
|
70
|
+
const { ref, theme, switchTheme } = isControlled ?
|
|
71
|
+
{ ref: contextTheme.ref, theme: contextTheme.theme, switchTheme: contextTheme.switchTheme } :
|
|
72
|
+
standaloneHook;
|
|
73
|
+
const [isMounted, setIsMounted] = (0, react_1.useState)(false);
|
|
74
|
+
(0, react_1.useEffect)(() => {
|
|
75
|
+
setIsMounted(true);
|
|
76
|
+
}, []);
|
|
77
|
+
const handleThemeChange = async (newTheme, event) => {
|
|
78
|
+
if (isControlled && contextTheme.switchThemeFromElement && event) {
|
|
79
|
+
// Use controlled mode with animation from clicked element
|
|
80
|
+
await contextTheme.switchThemeFromElement(newTheme, event.currentTarget);
|
|
81
|
+
// Also call the callback if provided
|
|
82
|
+
if (onThemeChange) {
|
|
83
|
+
onThemeChange(newTheme);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// Use standalone mode
|
|
88
|
+
await switchTheme(newTheme);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
if (!isMounted) {
|
|
92
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "flex h-9 w-fit" });
|
|
93
|
+
}
|
|
94
|
+
const filteredOptions = THEME_OPTIONS.filter(option => themes.includes(option.value));
|
|
95
|
+
return ((0, jsx_runtime_1.jsx)(react_2.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3 }, className: (0, clsx_1.clsx)('inline-flex items-center overflow-hidden bg-background shadow-sm border border-border', 'transition-all duration-200 ease-in-out', className), style: {
|
|
96
|
+
borderRadius: 'var(--radius)',
|
|
97
|
+
backgroundColor: 'hsl(var(--background))',
|
|
98
|
+
}, role: "radiogroup", children: filteredOptions.map(option => ((0, jsx_runtime_1.jsx)(ThemeOption, { icon: option.icon, value: option.value, isActive: theme === option.value, isHovered: false, onClick: handleThemeChange, onMouseEnter: () => { }, onMouseLeave: () => { }, buttonRef: theme === option.value ? ref : undefined }, option.value))) }, String(isMounted)));
|
|
99
|
+
};
|
|
100
|
+
exports.ThemeSwitcher = ThemeSwitcher;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
3
|
+
declare function Select({ ...props }: React.ComponentProps<typeof SelectPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function SelectGroup({ ...props }: React.ComponentProps<typeof SelectPrimitive.Group>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function SelectTrigger({ className, size, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
|
7
|
+
size?: "sm" | "default";
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare function SelectContent({ className, children, position, ...props }: React.ComponentProps<typeof SelectPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Label>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare function SelectItem({ className, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Item>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare function SelectSeparator({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Separator>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare function SelectScrollUpButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare function SelectScrollDownButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Select = Select;
|
|
37
|
+
exports.SelectContent = SelectContent;
|
|
38
|
+
exports.SelectGroup = SelectGroup;
|
|
39
|
+
exports.SelectItem = SelectItem;
|
|
40
|
+
exports.SelectLabel = SelectLabel;
|
|
41
|
+
exports.SelectScrollDownButton = SelectScrollDownButton;
|
|
42
|
+
exports.SelectScrollUpButton = SelectScrollUpButton;
|
|
43
|
+
exports.SelectSeparator = SelectSeparator;
|
|
44
|
+
exports.SelectTrigger = SelectTrigger;
|
|
45
|
+
exports.SelectValue = SelectValue;
|
|
46
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
47
|
+
const SelectPrimitive = __importStar(require("@radix-ui/react-select"));
|
|
48
|
+
const clsx_1 = require("clsx");
|
|
49
|
+
function Select({ ...props }) {
|
|
50
|
+
return (0, jsx_runtime_1.jsx)(SelectPrimitive.Root, { "data-slot": "select", ...props });
|
|
51
|
+
}
|
|
52
|
+
function SelectGroup({ ...props }) {
|
|
53
|
+
return (0, jsx_runtime_1.jsx)(SelectPrimitive.Group, { "data-slot": "select-group", ...props });
|
|
54
|
+
}
|
|
55
|
+
function SelectValue({ ...props }) {
|
|
56
|
+
return (0, jsx_runtime_1.jsx)(SelectPrimitive.Value, { "data-slot": "select-value", ...props });
|
|
57
|
+
}
|
|
58
|
+
const ChevronDownIcon = () => ((0, jsx_runtime_1.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: (0, jsx_runtime_1.jsx)("path", { d: "m6 9 6 6 6-6" }) }));
|
|
59
|
+
const ChevronUpIcon = () => ((0, jsx_runtime_1.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: (0, jsx_runtime_1.jsx)("path", { d: "m18 15-6-6-6 6" }) }));
|
|
60
|
+
const CheckIcon = () => ((0, jsx_runtime_1.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: (0, jsx_runtime_1.jsx)("path", { d: "M20 6 9 17l-5-5" }) }));
|
|
61
|
+
function SelectTrigger({ className, size = "default", children, ...props }) {
|
|
62
|
+
return ((0, jsx_runtime_1.jsxs)(SelectPrimitive.Trigger, { "data-slot": "select-trigger", "data-size": size, className: (0, clsx_1.clsx)("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), ...props, children: [children, (0, jsx_runtime_1.jsx)(SelectPrimitive.Icon, { asChild: true, children: (0, jsx_runtime_1.jsx)(ChevronDownIcon, {}) })] }));
|
|
63
|
+
}
|
|
64
|
+
function SelectContent({ className, children, position = "popper", ...props }) {
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(SelectPrimitive.Portal, { children: (0, jsx_runtime_1.jsx)(SelectPrimitive.Content, { "data-slot": "select-content", className: (0, clsx_1.clsx)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md", position === "popper" &&
|
|
66
|
+
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className), position: position, ...props, children: (0, jsx_runtime_1.jsx)(SelectPrimitive.Viewport, { className: (0, clsx_1.clsx)("p-1", position === "popper" &&
|
|
67
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"), children: children }) }) }));
|
|
68
|
+
}
|
|
69
|
+
function SelectLabel({ className, ...props }) {
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)(SelectPrimitive.Label, { "data-slot": "select-label", className: (0, clsx_1.clsx)("py-1.5 pl-8 pr-2 text-sm font-semibold", className), ...props }));
|
|
71
|
+
}
|
|
72
|
+
function SelectItem({ className, children, ...props }) {
|
|
73
|
+
return ((0, jsx_runtime_1.jsxs)(SelectPrimitive.Item, { "data-slot": "select-item", className: (0, clsx_1.clsx)("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className), ...props, children: [(0, jsx_runtime_1.jsx)("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: (0, jsx_runtime_1.jsx)(SelectPrimitive.ItemIndicator, { children: (0, jsx_runtime_1.jsx)(CheckIcon, {}) }) }), (0, jsx_runtime_1.jsx)(SelectPrimitive.ItemText, { children: children })] }));
|
|
74
|
+
}
|
|
75
|
+
function SelectSeparator({ className, ...props }) {
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)(SelectPrimitive.Separator, { "data-slot": "select-separator", className: (0, clsx_1.clsx)("-mx-1 my-1 h-px bg-muted", className), ...props }));
|
|
77
|
+
}
|
|
78
|
+
function SelectScrollUpButton({ className, ...props }) {
|
|
79
|
+
return ((0, jsx_runtime_1.jsx)(SelectPrimitive.ScrollUpButton, { "data-slot": "select-scroll-up-button", className: (0, clsx_1.clsx)("flex cursor-default items-center justify-center py-1", className), ...props, children: (0, jsx_runtime_1.jsx)(ChevronUpIcon, {}) }));
|
|
80
|
+
}
|
|
81
|
+
function SelectScrollDownButton({ className, ...props }) {
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(SelectPrimitive.ScrollDownButton, { "data-slot": "select-scroll-down-button", className: (0, clsx_1.clsx)("flex cursor-default items-center justify-center py-1", className), ...props, children: (0, jsx_runtime_1.jsx)(ChevronDownIcon, {}) }));
|
|
83
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useThemeAnimation = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_dom_1 = require("react-dom");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const animations_1 = require("../utils/animations");
|
|
8
|
+
const isBrowser = typeof window !== 'undefined';
|
|
9
|
+
const useThemeAnimation = (props = {}) => {
|
|
10
|
+
const { duration: propsDuration = 750, easing = 'ease-in-out', animationType = types_1.ThemeAnimationType.CIRCLE, blurAmount = 2, styleId = 'spaceman-theme-style', themes = ['light', 'dark', 'system'], colorThemes = ['default'], defaultTheme = 'system', defaultColorTheme = 'default', globalClassName = 'dark', colorThemePrefix = 'theme-', storageKey = 'theme', colorStorageKey = 'color-theme', theme: externalTheme, colorTheme: externalColorTheme, onThemeChange, onColorThemeChange, } = props;
|
|
11
|
+
const isHighResolution = isBrowser && (window.innerWidth >= 3000 || window.innerHeight >= 2000);
|
|
12
|
+
const duration = isHighResolution ? Math.max(propsDuration * 0.8, 500) : propsDuration;
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
(0, animations_1.injectBaseStyles)();
|
|
15
|
+
}, []);
|
|
16
|
+
const [internalTheme, setInternalTheme] = (0, react_1.useState)(() => {
|
|
17
|
+
if (!isBrowser)
|
|
18
|
+
return defaultTheme;
|
|
19
|
+
const saved = localStorage.getItem(storageKey);
|
|
20
|
+
return saved && themes.indexOf(saved) !== -1 ? saved : defaultTheme;
|
|
21
|
+
});
|
|
22
|
+
const [internalColorTheme, setInternalColorTheme] = (0, react_1.useState)(() => {
|
|
23
|
+
if (!isBrowser)
|
|
24
|
+
return defaultColorTheme;
|
|
25
|
+
const saved = localStorage.getItem(colorStorageKey);
|
|
26
|
+
return saved && colorThemes.indexOf(saved) !== -1 ? saved : defaultColorTheme;
|
|
27
|
+
});
|
|
28
|
+
const currentTheme = externalTheme ?? internalTheme;
|
|
29
|
+
const currentColorTheme = externalColorTheme ?? internalColorTheme;
|
|
30
|
+
const [, setSystemTheme] = (0, react_1.useState)(() => (0, animations_1.getSystemTheme)());
|
|
31
|
+
const resolvedTheme = (0, animations_1.resolveTheme)(currentTheme);
|
|
32
|
+
(0, react_1.useEffect)(() => {
|
|
33
|
+
if (!isBrowser)
|
|
34
|
+
return;
|
|
35
|
+
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
36
|
+
const handleChange = () => setSystemTheme((0, animations_1.getSystemTheme)());
|
|
37
|
+
mediaQuery.addEventListener('change', handleChange);
|
|
38
|
+
return () => mediaQuery.removeEventListener('change', handleChange);
|
|
39
|
+
}, []);
|
|
40
|
+
// Apply theme classes to DOM
|
|
41
|
+
(0, react_1.useEffect)(() => {
|
|
42
|
+
if (!isBrowser)
|
|
43
|
+
return;
|
|
44
|
+
// Apply theme class (light/dark) - use resolvedTheme instead of manual resolution
|
|
45
|
+
if (resolvedTheme === 'dark') {
|
|
46
|
+
document.documentElement.classList.add(globalClassName);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
document.documentElement.classList.remove(globalClassName);
|
|
50
|
+
}
|
|
51
|
+
// Apply color theme classes
|
|
52
|
+
// Remove all existing color theme classes
|
|
53
|
+
colorThemes.forEach(theme => {
|
|
54
|
+
document.documentElement.classList.remove(`${colorThemePrefix}${theme}`);
|
|
55
|
+
});
|
|
56
|
+
// Add current color theme class
|
|
57
|
+
document.documentElement.classList.add(`${colorThemePrefix}${currentColorTheme}`);
|
|
58
|
+
}, [resolvedTheme, currentColorTheme, globalClassName, colorThemePrefix, colorThemes]);
|
|
59
|
+
const ref = (0, react_1.useRef)(null);
|
|
60
|
+
const setTheme = (0, react_1.useCallback)((newTheme) => {
|
|
61
|
+
// Always save to localStorage
|
|
62
|
+
if (isBrowser) {
|
|
63
|
+
localStorage.setItem(storageKey, newTheme);
|
|
64
|
+
}
|
|
65
|
+
// Update internal state if no external control
|
|
66
|
+
if (externalTheme === undefined) {
|
|
67
|
+
setInternalTheme(newTheme);
|
|
68
|
+
}
|
|
69
|
+
// Call external callback if provided
|
|
70
|
+
if (onThemeChange) {
|
|
71
|
+
onThemeChange(newTheme);
|
|
72
|
+
}
|
|
73
|
+
}, [onThemeChange, externalTheme, storageKey]);
|
|
74
|
+
const setColorTheme = (0, react_1.useCallback)((newColorTheme) => {
|
|
75
|
+
// Always save to localStorage
|
|
76
|
+
if (isBrowser) {
|
|
77
|
+
localStorage.setItem(colorStorageKey, newColorTheme);
|
|
78
|
+
}
|
|
79
|
+
// Update internal state if no external control
|
|
80
|
+
if (externalColorTheme === undefined) {
|
|
81
|
+
setInternalColorTheme(newColorTheme);
|
|
82
|
+
}
|
|
83
|
+
// Call external callback if provided
|
|
84
|
+
if (onColorThemeChange) {
|
|
85
|
+
onColorThemeChange(newColorTheme);
|
|
86
|
+
}
|
|
87
|
+
}, [onColorThemeChange, externalColorTheme, colorStorageKey]);
|
|
88
|
+
const switchTheme = (0, react_1.useCallback)(async (newTheme) => {
|
|
89
|
+
if (!ref.current || !(0, animations_1.supportsViewTransitions)() || (0, animations_1.prefersReducedMotion)()) {
|
|
90
|
+
setTheme(newTheme);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const { top, left, width, height } = ref.current.getBoundingClientRect();
|
|
94
|
+
const x = left + width / 2;
|
|
95
|
+
const y = top + height / 2;
|
|
96
|
+
const animationConfig = {
|
|
97
|
+
x,
|
|
98
|
+
y,
|
|
99
|
+
duration,
|
|
100
|
+
easing,
|
|
101
|
+
animationType,
|
|
102
|
+
blurAmount,
|
|
103
|
+
styleId,
|
|
104
|
+
};
|
|
105
|
+
if (animationType === types_1.ThemeAnimationType.BLUR_CIRCLE) {
|
|
106
|
+
(0, animations_1.createBlurCircleAnimation)(animationConfig);
|
|
107
|
+
}
|
|
108
|
+
await document.startViewTransition(() => {
|
|
109
|
+
(0, react_dom_1.flushSync)(() => {
|
|
110
|
+
setTheme(newTheme);
|
|
111
|
+
});
|
|
112
|
+
}).ready;
|
|
113
|
+
if (animationType === types_1.ThemeAnimationType.CIRCLE) {
|
|
114
|
+
(0, animations_1.createCircleAnimation)(animationConfig);
|
|
115
|
+
}
|
|
116
|
+
}, [setTheme, duration, easing, animationType, blurAmount, styleId]);
|
|
117
|
+
const toggleTheme = (0, react_1.useCallback)(async () => {
|
|
118
|
+
const newTheme = resolvedTheme === 'dark' ? 'light' : 'dark';
|
|
119
|
+
await switchTheme(newTheme);
|
|
120
|
+
}, [resolvedTheme, switchTheme]);
|
|
121
|
+
(0, react_1.useEffect)(() => {
|
|
122
|
+
if (!isBrowser)
|
|
123
|
+
return;
|
|
124
|
+
const root = document.documentElement;
|
|
125
|
+
if (resolvedTheme === 'dark') {
|
|
126
|
+
root.classList.add(globalClassName);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
root.classList.remove(globalClassName);
|
|
130
|
+
}
|
|
131
|
+
colorThemes.forEach(theme => {
|
|
132
|
+
root.classList.remove(`${colorThemePrefix}${theme}`);
|
|
133
|
+
});
|
|
134
|
+
if (currentColorTheme !== 'default') {
|
|
135
|
+
root.classList.add(`${colorThemePrefix}${currentColorTheme}`);
|
|
136
|
+
}
|
|
137
|
+
}, [resolvedTheme, currentColorTheme, globalClassName, colorThemePrefix, colorThemes]);
|
|
138
|
+
return {
|
|
139
|
+
ref,
|
|
140
|
+
theme: currentTheme,
|
|
141
|
+
colorTheme: currentColorTheme,
|
|
142
|
+
resolvedTheme,
|
|
143
|
+
setTheme,
|
|
144
|
+
setColorTheme,
|
|
145
|
+
toggleTheme,
|
|
146
|
+
switchTheme,
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
exports.useThemeAnimation = useThemeAnimation;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { useThemeAnimation } from './hooks/use-theme-animation';
|
|
2
|
+
export { ThemeSwitcher } from './components/ThemeSwitcher';
|
|
3
|
+
export { ThemeSelector } from './components/ThemeSelector';
|
|
4
|
+
export { SpacemanThemeProvider, useSpacemanTheme } from './components/SpacemanThemeProvider';
|
|
5
|
+
export type { UseThemeAnimationProps, UseThemeAnimationReturn, ThemeSwitcherProps, ThemeSelectorProps, Theme, ColorTheme, } from './types';
|
|
6
|
+
export { ThemeAnimationType } from './types';
|
|
7
|
+
export { injectBaseStyles, getSystemTheme, resolveTheme, supportsViewTransitions, prefersReducedMotion, } from './utils/animations';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prefersReducedMotion = exports.supportsViewTransitions = exports.resolveTheme = exports.getSystemTheme = exports.injectBaseStyles = exports.ThemeAnimationType = exports.useSpacemanTheme = exports.SpacemanThemeProvider = exports.ThemeSelector = exports.ThemeSwitcher = exports.useThemeAnimation = void 0;
|
|
4
|
+
var use_theme_animation_1 = require("./hooks/use-theme-animation");
|
|
5
|
+
Object.defineProperty(exports, "useThemeAnimation", { enumerable: true, get: function () { return use_theme_animation_1.useThemeAnimation; } });
|
|
6
|
+
var ThemeSwitcher_1 = require("./components/ThemeSwitcher");
|
|
7
|
+
Object.defineProperty(exports, "ThemeSwitcher", { enumerable: true, get: function () { return ThemeSwitcher_1.ThemeSwitcher; } });
|
|
8
|
+
var ThemeSelector_1 = require("./components/ThemeSelector");
|
|
9
|
+
Object.defineProperty(exports, "ThemeSelector", { enumerable: true, get: function () { return ThemeSelector_1.ThemeSelector; } });
|
|
10
|
+
var SpacemanThemeProvider_1 = require("./components/SpacemanThemeProvider");
|
|
11
|
+
Object.defineProperty(exports, "SpacemanThemeProvider", { enumerable: true, get: function () { return SpacemanThemeProvider_1.SpacemanThemeProvider; } });
|
|
12
|
+
Object.defineProperty(exports, "useSpacemanTheme", { enumerable: true, get: function () { return SpacemanThemeProvider_1.useSpacemanTheme; } });
|
|
13
|
+
var types_1 = require("./types");
|
|
14
|
+
Object.defineProperty(exports, "ThemeAnimationType", { enumerable: true, get: function () { return types_1.ThemeAnimationType; } });
|
|
15
|
+
var animations_1 = require("./utils/animations");
|
|
16
|
+
Object.defineProperty(exports, "injectBaseStyles", { enumerable: true, get: function () { return animations_1.injectBaseStyles; } });
|
|
17
|
+
Object.defineProperty(exports, "getSystemTheme", { enumerable: true, get: function () { return animations_1.getSystemTheme; } });
|
|
18
|
+
Object.defineProperty(exports, "resolveTheme", { enumerable: true, get: function () { return animations_1.resolveTheme; } });
|
|
19
|
+
Object.defineProperty(exports, "supportsViewTransitions", { enumerable: true, get: function () { return animations_1.supportsViewTransitions; } });
|
|
20
|
+
Object.defineProperty(exports, "prefersReducedMotion", { enumerable: true, get: function () { return animations_1.prefersReducedMotion; } });
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export declare enum ThemeAnimationType {
|
|
3
|
+
CIRCLE = "circle",
|
|
4
|
+
BLUR_CIRCLE = "blur-circle"
|
|
5
|
+
}
|
|
6
|
+
export type Theme = 'light' | 'dark' | 'system';
|
|
7
|
+
export type ColorTheme = string;
|
|
8
|
+
export interface UseThemeAnimationProps {
|
|
9
|
+
duration?: number;
|
|
10
|
+
easing?: string;
|
|
11
|
+
animationType?: ThemeAnimationType;
|
|
12
|
+
blurAmount?: number;
|
|
13
|
+
styleId?: string;
|
|
14
|
+
themes?: Theme[];
|
|
15
|
+
colorThemes?: ColorTheme[];
|
|
16
|
+
defaultTheme?: Theme;
|
|
17
|
+
defaultColorTheme?: ColorTheme;
|
|
18
|
+
globalClassName?: string;
|
|
19
|
+
colorThemePrefix?: string;
|
|
20
|
+
storageKey?: string;
|
|
21
|
+
colorStorageKey?: string;
|
|
22
|
+
theme?: Theme;
|
|
23
|
+
colorTheme?: ColorTheme;
|
|
24
|
+
onThemeChange?: (theme: Theme) => void;
|
|
25
|
+
onColorThemeChange?: (colorTheme: ColorTheme) => void;
|
|
26
|
+
}
|
|
27
|
+
export interface UseThemeAnimationReturn {
|
|
28
|
+
ref: RefObject<HTMLButtonElement | null>;
|
|
29
|
+
theme: Theme;
|
|
30
|
+
colorTheme: ColorTheme;
|
|
31
|
+
resolvedTheme: 'light' | 'dark';
|
|
32
|
+
setTheme: (theme: Theme) => void;
|
|
33
|
+
setColorTheme: (colorTheme: ColorTheme) => void;
|
|
34
|
+
toggleTheme: () => Promise<void>;
|
|
35
|
+
switchTheme: (theme: Theme) => Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export interface ThemeSwitcherProps {
|
|
38
|
+
themes?: Theme[];
|
|
39
|
+
currentTheme?: Theme;
|
|
40
|
+
onThemeChange?: (theme: Theme) => void;
|
|
41
|
+
animationType?: ThemeAnimationType;
|
|
42
|
+
duration?: number;
|
|
43
|
+
className?: string;
|
|
44
|
+
size?: 'sm' | 'md' | 'lg';
|
|
45
|
+
variant?: 'default' | 'outline' | 'ghost';
|
|
46
|
+
icons?: {
|
|
47
|
+
light?: React.ReactNode;
|
|
48
|
+
dark?: React.ReactNode;
|
|
49
|
+
system?: React.ReactNode;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export interface ThemeSelectorProps {
|
|
53
|
+
themes?: Theme[];
|
|
54
|
+
colorThemes?: ColorTheme[];
|
|
55
|
+
currentTheme?: Theme;
|
|
56
|
+
currentColorTheme?: ColorTheme;
|
|
57
|
+
onThemeChange?: (theme: Theme) => void;
|
|
58
|
+
onColorThemeChange?: (colorTheme: ColorTheme) => void;
|
|
59
|
+
animationType?: ThemeAnimationType;
|
|
60
|
+
duration?: number;
|
|
61
|
+
className?: string;
|
|
62
|
+
placeholder?: string;
|
|
63
|
+
themeLabel?: string;
|
|
64
|
+
colorThemeLabel?: string;
|
|
65
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThemeAnimationType = void 0;
|
|
4
|
+
var ThemeAnimationType;
|
|
5
|
+
(function (ThemeAnimationType) {
|
|
6
|
+
ThemeAnimationType["CIRCLE"] = "circle";
|
|
7
|
+
ThemeAnimationType["BLUR_CIRCLE"] = "blur-circle";
|
|
8
|
+
})(ThemeAnimationType || (exports.ThemeAnimationType = ThemeAnimationType = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ThemeAnimationType } from '../types';
|
|
2
|
+
export declare const injectBaseStyles: () => void;
|
|
3
|
+
export declare const createBlurCircleMask: (blur: number) => string;
|
|
4
|
+
export declare const getSystemTheme: () => "light" | "dark";
|
|
5
|
+
export declare const resolveTheme: (theme: string) => "light" | "dark";
|
|
6
|
+
export declare const supportsViewTransitions: () => boolean;
|
|
7
|
+
export declare const prefersReducedMotion: () => boolean;
|
|
8
|
+
export interface AnimationConfig {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
duration: number;
|
|
12
|
+
easing: string;
|
|
13
|
+
animationType: ThemeAnimationType;
|
|
14
|
+
blurAmount: number;
|
|
15
|
+
styleId: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const createCircleAnimation: (config: AnimationConfig) => void;
|
|
18
|
+
export declare const createBlurCircleAnimation: (config: AnimationConfig) => void;
|