@gx-design-vue/context 0.0.3 → 0.0.5-alpha.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 +71 -5
- package/dist/context/ContextProvider.d.ts +45 -0
- package/dist/context/ContextProvider.js +39 -0
- package/dist/context/index.d.ts +10 -0
- package/dist/context/index.js +20 -0
- package/dist/context.esm.js +506 -0
- package/dist/context.js +1 -107
- package/dist/index.d.ts +9 -1
- package/dist/index.js +9 -0
- package/dist/theme-context/ThemeContext.d.ts +77 -46
- package/dist/theme-context/ThemeContext.js +68 -0
- package/dist/theme-context/context.d.ts +6 -2
- package/dist/theme-context/context.js +7 -0
- package/dist/theme-context/dark.d.ts +7 -2
- package/dist/theme-context/dark.js +8 -0
- package/dist/theme-context/index.d.ts +6 -6
- package/dist/theme-context/index.js +6 -0
- package/dist/theme-context/types.d.ts +12 -8
- package/dist/theme-context/types.js +1 -0
- package/dist/theme-context/utils.d.ts +8 -4
- package/dist/theme-context/utils.js +32 -0
- package/global.d.ts +8 -0
- package/package.json +47 -29
- package/dist/context.umd.cjs +0 -12
|
@@ -1,46 +1,77 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
import { BaseTheme, ThemeValue } from "./types.js";
|
|
2
|
+
import * as vue6 from "vue";
|
|
3
|
+
import { PropType, SlotsType } from "vue";
|
|
4
|
+
|
|
5
|
+
//#region src/theme-context/ThemeContext.d.ts
|
|
6
|
+
interface ThemeContextProps {
|
|
7
|
+
theme?: ThemeValue;
|
|
8
|
+
defaultTheme?: ThemeValue;
|
|
9
|
+
onChange?: (theme: ThemeValue) => void;
|
|
10
|
+
onChangeBase?: (theme: BaseTheme) => void;
|
|
11
|
+
onUpdateTheme?: (theme: ThemeValue) => void;
|
|
12
|
+
}
|
|
13
|
+
interface ThemeContextEmits {
|
|
14
|
+
change: (value: ThemeValue) => void;
|
|
15
|
+
changeBase: (value: BaseTheme) => void;
|
|
16
|
+
'update:theme': (value: ThemeValue) => void;
|
|
17
|
+
}
|
|
18
|
+
interface ThemeContextSlots {
|
|
19
|
+
default?: () => any;
|
|
20
|
+
}
|
|
21
|
+
declare const themeContextProps: {
|
|
22
|
+
theme: {
|
|
23
|
+
type: PropType<ThemeValue>;
|
|
24
|
+
};
|
|
25
|
+
defaultTheme: {
|
|
26
|
+
type: PropType<ThemeValue>;
|
|
27
|
+
default: string;
|
|
28
|
+
};
|
|
29
|
+
onChange: {
|
|
30
|
+
type: PropType<(theme: ThemeValue) => void>;
|
|
31
|
+
};
|
|
32
|
+
onChangeBase: {
|
|
33
|
+
type: PropType<(theme: BaseTheme) => void>;
|
|
34
|
+
};
|
|
35
|
+
onUpdateTheme: {
|
|
36
|
+
type: PropType<(theme: ThemeValue) => void>;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
declare const ThemeContext: vue6.DefineComponent<vue6.ExtractPropTypes<{
|
|
40
|
+
theme: {
|
|
41
|
+
type: PropType<ThemeValue>;
|
|
42
|
+
};
|
|
43
|
+
defaultTheme: {
|
|
44
|
+
type: PropType<ThemeValue>;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
onChange: {
|
|
48
|
+
type: PropType<(theme: ThemeValue) => void>;
|
|
49
|
+
};
|
|
50
|
+
onChangeBase: {
|
|
51
|
+
type: PropType<(theme: BaseTheme) => void>;
|
|
52
|
+
};
|
|
53
|
+
onUpdateTheme: {
|
|
54
|
+
type: PropType<(theme: ThemeValue) => void>;
|
|
55
|
+
};
|
|
56
|
+
}>, () => any, {}, {}, {}, vue6.ComponentOptionsMixin, vue6.ComponentOptionsMixin, {}, string, vue6.PublicProps, Readonly<vue6.ExtractPropTypes<{
|
|
57
|
+
theme: {
|
|
58
|
+
type: PropType<ThemeValue>;
|
|
59
|
+
};
|
|
60
|
+
defaultTheme: {
|
|
61
|
+
type: PropType<ThemeValue>;
|
|
62
|
+
default: string;
|
|
63
|
+
};
|
|
64
|
+
onChange: {
|
|
65
|
+
type: PropType<(theme: ThemeValue) => void>;
|
|
66
|
+
};
|
|
67
|
+
onChangeBase: {
|
|
68
|
+
type: PropType<(theme: BaseTheme) => void>;
|
|
69
|
+
};
|
|
70
|
+
onUpdateTheme: {
|
|
71
|
+
type: PropType<(theme: ThemeValue) => void>;
|
|
72
|
+
};
|
|
73
|
+
}>> & Readonly<{}>, {
|
|
74
|
+
defaultTheme: ThemeValue;
|
|
75
|
+
}, SlotsType<ThemeContextSlots>, {}, {}, string, vue6.ComponentProvideOptions, true, {}, any>;
|
|
76
|
+
//#endregion
|
|
77
|
+
export { ThemeContextEmits, ThemeContextProps, ThemeContextSlots, ThemeContext as default, themeContextProps };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createThemeContext } from "./context.js";
|
|
2
|
+
import { computed, defineComponent, ref, watch } from "vue";
|
|
3
|
+
import { useColorMode } from "@vueuse/core";
|
|
4
|
+
|
|
5
|
+
//#region src/theme-context/ThemeContext.tsx
|
|
6
|
+
const themeContextProps = {
|
|
7
|
+
theme: { type: String },
|
|
8
|
+
defaultTheme: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: "system"
|
|
11
|
+
},
|
|
12
|
+
onChange: { type: Function },
|
|
13
|
+
onChangeBase: { type: Function },
|
|
14
|
+
onUpdateTheme: { type: Function }
|
|
15
|
+
};
|
|
16
|
+
const ThemeContext = /* @__PURE__ */ defineComponent({
|
|
17
|
+
name: "ThemeContext",
|
|
18
|
+
inheritAttrs: false,
|
|
19
|
+
props: themeContextProps,
|
|
20
|
+
slots: Object,
|
|
21
|
+
setup: (props, { slots, emit }) => {
|
|
22
|
+
const html = document.querySelector("html");
|
|
23
|
+
const theme = ref();
|
|
24
|
+
const systemTheme = ref(props.theme || props.defaultTheme || "system");
|
|
25
|
+
watch(() => props.theme, (val) => {
|
|
26
|
+
if (val) systemTheme.value = val;
|
|
27
|
+
});
|
|
28
|
+
const { system, store } = useColorMode();
|
|
29
|
+
watch(() => system.value, () => {
|
|
30
|
+
updateSystemThem();
|
|
31
|
+
}, { immediate: true });
|
|
32
|
+
watch(() => theme.value, (val) => {
|
|
33
|
+
if (val) props.onChangeBase?.(val);
|
|
34
|
+
}, { immediate: true });
|
|
35
|
+
watch(systemTheme, (val) => {
|
|
36
|
+
props.onChange?.(val);
|
|
37
|
+
emit("update:theme", val);
|
|
38
|
+
updateSystemThem();
|
|
39
|
+
});
|
|
40
|
+
function updateSystemThem() {
|
|
41
|
+
if (html) {
|
|
42
|
+
if (systemTheme.value === "system") {
|
|
43
|
+
theme.value = system.value;
|
|
44
|
+
html.setAttribute("data-theme", theme.value);
|
|
45
|
+
} else {
|
|
46
|
+
theme.value = systemTheme.value;
|
|
47
|
+
html.setAttribute("data-theme", systemTheme.value);
|
|
48
|
+
}
|
|
49
|
+
store.value = theme.value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function setTheme(val) {
|
|
53
|
+
systemTheme.value = val;
|
|
54
|
+
updateSystemThem();
|
|
55
|
+
}
|
|
56
|
+
createThemeContext({
|
|
57
|
+
theme: systemTheme,
|
|
58
|
+
resolvedTheme: theme,
|
|
59
|
+
isDark: computed(() => theme.value === "dark"),
|
|
60
|
+
setTheme
|
|
61
|
+
});
|
|
62
|
+
return () => slots.default?.();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
var ThemeContext_default = ThemeContext;
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { ThemeContext_default as default, themeContextProps };
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { ThemeProviderContext } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/theme-context/context.d.ts
|
|
4
|
+
declare const createThemeContext: (value: ThemeProviderContext) => void, useThemeContext: (injectDefaultValue?: ThemeProviderContext | undefined) => ThemeProviderContext;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { createThemeContext, useThemeContext };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useContext } from "../context/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/theme-context/context.ts
|
|
4
|
+
const { provideContext: createThemeContext, useInjectContext: useThemeContext } = useContext("theme-provider");
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createThemeContext, useThemeContext };
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as _vueuse_core0 from "@vueuse/core";
|
|
2
|
+
|
|
3
|
+
//#region src/theme-context/dark.d.ts
|
|
4
|
+
declare const isDark: _vueuse_core0.UseDarkReturn;
|
|
5
|
+
declare const toggleDark: (value?: boolean | undefined) => boolean;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { isDark, toggleDark };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {
|
|
1
|
+
import { BaseTheme, ThemeProviderContext, ThemeValue } from "./types.js";
|
|
2
|
+
import { useThemeContext } from "./context.js";
|
|
3
|
+
import { toggleDark } from "./dark.js";
|
|
4
|
+
import ThemeContext, { ThemeContextEmits, ThemeContextProps, ThemeContextSlots, themeContextProps } from "./ThemeContext.js";
|
|
5
|
+
import { toggleAnimateTheme } from "./utils.js";
|
|
6
|
+
export { BaseTheme, ThemeContext, ThemeContextEmits, ThemeContextProps, ThemeContextSlots, ThemeProviderContext, ThemeValue, themeContextProps, toggleAnimateTheme, toggleDark, useThemeContext };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { useThemeContext } from "./context.js";
|
|
2
|
+
import { toggleDark } from "./dark.js";
|
|
3
|
+
import ThemeContext_default, { themeContextProps } from "./ThemeContext.js";
|
|
4
|
+
import { toggleAnimateTheme } from "./utils.js";
|
|
5
|
+
|
|
6
|
+
export { ThemeContext_default as ThemeContext, themeContextProps, toggleAnimateTheme, toggleDark, useThemeContext };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { ComputedRef, Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/theme-context/types.d.ts
|
|
4
|
+
type BaseTheme = 'light' | 'dark';
|
|
5
|
+
type ThemeValue = 'light' | 'dark' | 'system';
|
|
6
|
+
interface ThemeProviderContext {
|
|
7
|
+
theme: Ref<ThemeValue>;
|
|
8
|
+
resolvedTheme: Ref<BaseTheme>;
|
|
9
|
+
isDark: ComputedRef<boolean>;
|
|
10
|
+
setTheme: (theme: ThemeValue) => void;
|
|
9
11
|
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { BaseTheme, ThemeProviderContext, ThemeValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { BaseTheme } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/theme-context/utils.d.ts
|
|
4
|
+
declare function toggleAnimateTheme(el: HTMLElement, props: {
|
|
5
|
+
isDark: boolean;
|
|
6
|
+
setTheme?: (value: BaseTheme) => void;
|
|
5
7
|
}): void;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { toggleAnimateTheme };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { nextTick } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/theme-context/utils.ts
|
|
4
|
+
function toggleAnimateTheme(el, props) {
|
|
5
|
+
if (!(document.startViewTransition && !window.matchMedia("(prefers-reduced-motion: reduce)").matches)) {
|
|
6
|
+
props.setTheme?.(props.isDark ? "dark" : "light");
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const rect = el.getBoundingClientRect();
|
|
10
|
+
const x = rect.left + rect.width / 2;
|
|
11
|
+
const y = rect.top + rect.height / 2;
|
|
12
|
+
const endRadius = Math.hypot(Math.max(x, innerWidth - x), Math.max(y, innerHeight - y));
|
|
13
|
+
const ratioX = 100 * x / innerWidth;
|
|
14
|
+
const ratioY = 100 * y / innerHeight;
|
|
15
|
+
const referR = Math.hypot(innerWidth, innerHeight) / Math.SQRT2;
|
|
16
|
+
const ratioR = 100 * endRadius / referR;
|
|
17
|
+
document.startViewTransition(async () => {
|
|
18
|
+
props.setTheme?.(props.isDark ? "dark" : "light");
|
|
19
|
+
await nextTick();
|
|
20
|
+
}).ready.then(() => {
|
|
21
|
+
const clipPath = [`circle(0% at ${ratioX}% ${ratioY}%)`, `circle(${ratioR}% at ${ratioX}% ${ratioY}%)`];
|
|
22
|
+
document.documentElement.animate({ clipPath: props.isDark ? [...clipPath].reverse() : clipPath }, {
|
|
23
|
+
duration: 400,
|
|
24
|
+
fill: "forwards",
|
|
25
|
+
easing: "ease-in",
|
|
26
|
+
pseudoElement: props.isDark ? "::view-transition-old(root)" : "::view-transition-new(root)"
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { toggleAnimateTheme };
|
package/global.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,42 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gx-design-vue/context",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"description": "Gx Design
|
|
4
|
+
"version": "0.0.5-alpha.0",
|
|
5
|
+
"description": "Gx Design Context",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "gx12358",
|
|
8
|
+
"email": "gx12358@gmail.com",
|
|
9
|
+
"url": "https://github.com/gx12358"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/gx12358/pro-components-next.git",
|
|
15
|
+
"directory": "packages/context"
|
|
16
|
+
},
|
|
6
17
|
"exports": {
|
|
7
18
|
".": {
|
|
8
19
|
"types": "./dist/index.d.ts",
|
|
9
|
-
"import": "./dist/
|
|
10
|
-
"
|
|
11
|
-
}
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./dist/*": {
|
|
24
|
+
"types": "./dist/*.d.ts",
|
|
25
|
+
"import": "./dist/*.js",
|
|
26
|
+
"default": "./dist/*.js"
|
|
27
|
+
},
|
|
28
|
+
"./global.d.ts": "./global.d.ts",
|
|
29
|
+
"./global": "./global.d.ts",
|
|
30
|
+
"./package.json": "./package.json"
|
|
12
31
|
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"types": "./dist",
|
|
32
|
+
"unpkg": "dist/context.js",
|
|
33
|
+
"jsdelivr": "dist/context.js",
|
|
16
34
|
"files": [
|
|
17
|
-
"dist"
|
|
35
|
+
"dist",
|
|
36
|
+
"global.d.ts",
|
|
37
|
+
"package.json"
|
|
18
38
|
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"dev": "vite",
|
|
21
|
-
"build": "vite build",
|
|
22
|
-
"types": "vue-tsc --declaration --emitDeclarationOnly",
|
|
23
|
-
"preview": "vite preview --port 5050",
|
|
24
|
-
"test:unit": "vitest --environment jsdom",
|
|
25
|
-
"typecheck": "vue-tsc --noEmit && vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
|
|
26
|
-
"lint": "TIMING=1 eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
|
|
27
|
-
},
|
|
28
39
|
"peerDependencies": {
|
|
29
|
-
"vue": ">=3.
|
|
30
|
-
"ant-design-vue": "^4.2.6"
|
|
40
|
+
"vue": ">=3.2.0"
|
|
31
41
|
},
|
|
32
42
|
"dependencies": {
|
|
33
|
-
"@vueuse/core": "^14.
|
|
34
|
-
"@gx-design-vue/pro-
|
|
43
|
+
"@vueuse/core": "^14.2.0",
|
|
44
|
+
"@gx-design-vue/pro-utils": "0.2.0-alpha.0"
|
|
35
45
|
},
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
"browserslist": [
|
|
47
|
+
"> 1%",
|
|
48
|
+
"not ie 11",
|
|
49
|
+
"not op_mini all"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"build": "run-s build:esm build:vite:parallel",
|
|
54
|
+
"build:esm": "tsdown",
|
|
55
|
+
"build:vite:parallel": "run-p build:umd build:full-esm",
|
|
56
|
+
"build:full-esm": "vite build --config ./vite.esm.config.ts",
|
|
57
|
+
"build:umd": "vite build",
|
|
58
|
+
"prepublish": "pnpm build"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/dist/context.umd.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Gx Design Pro
|
|
3
|
-
* Version: 0.0.2
|
|
4
|
-
* Author: gx12358
|
|
5
|
-
* Copyright (C) 2024 gx12358
|
|
6
|
-
* License: MIT License
|
|
7
|
-
* Description: Gx Design context
|
|
8
|
-
* Date Created: 2025-11-23
|
|
9
|
-
* Homepage:
|
|
10
|
-
* Contact: gx12358@gmail.com
|
|
11
|
-
*/
|
|
12
|
-
(function(e,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@gx-design-vue/pro-provider"),require("@vueuse/core"),require("vue")):typeof define=="function"&&define.amd?define(["exports","@gx-design-vue/pro-provider","@vueuse/core","vue"],h):(e=typeof globalThis<"u"?globalThis:e||self,h(e.GContext={},e.proProvider,e.core,e.vue))})(this,(function(e,h,d,a){"use strict";const{provideContext:T,useInjectContext:y}=h.useContext("theme-provider"),p=d.useDark({storageKey:"gx-pro-theme-appearance"}),v=d.useToggle(p);function C(s,o){if(!(document.startViewTransition&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches)){o.setTheme?.(o.isDark?"dark":"light");return}const r=s.getBoundingClientRect(),n=r.left+r.width/2,i=r.top+r.height/2,c=Math.hypot(Math.max(n,innerWidth-n),Math.max(i,innerHeight-i)),m=100*n/innerWidth,u=100*i/innerHeight,l=Math.hypot(innerWidth,innerHeight)/Math.SQRT2,t=100*c/l;document.startViewTransition(async()=>{o.setTheme?.(o.isDark?"dark":"light"),await a.nextTick()}).ready.then(()=>{const g=[`circle(0% at ${m}% ${u}%)`,`circle(${t}% at ${m}% ${u}%)`];document.documentElement.animate({clipPath:o.isDark?[...g].reverse():g},{duration:400,fill:"forwards",easing:"ease-in",pseudoElement:o.isDark?"::view-transition-old(root)":"::view-transition-new(root)"})})}const x=a.defineComponent({name:"ThemeContext",inheritAttrs:!1,props:{theme:{type:String},defaultTheme:{type:String,default:"system"},onChange:{type:Function},"onUpdate:theme":{type:Function},onChangeBase:{type:Function}},emits:["change","changeBase","update:theme"],slots:Object,setup(s,{slots:o,emit:f}){const r=document.querySelector("html"),n=a.ref(),i=a.ref(s.theme||s.defaultTheme||"system");a.watch(()=>s.theme,t=>{t&&(i.value=t)});const{system:c,store:m}=d.useColorMode();a.watch(()=>c.value,()=>{u()},{immediate:!0}),a.watch(()=>n.value,t=>{t&&s.onChangeBase?.(t)},{immediate:!0}),a.watch(i,t=>{s.onChange?.(t),f("update:theme",t),u()});function u(){r&&(i.value==="system"?(n.value=c.value,r.setAttribute("data-theme",n.value)):(n.value=i.value,r.setAttribute("data-theme",i.value)),m.value=n.value)}function l(t){i.value=t,u()}return T({theme:i,resolvedTheme:n,isDark:a.computed(()=>n.value==="dark"),setTheme:l}),()=>o.default()}});e.ThemeContext=x,e.toggleAnimateTheme=C,e.toggleDark=v,e.useThemeContext=y,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|