@xaui/hybrid 0.0.4 → 0.0.6

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 bamory grams
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,9 +1,82 @@
1
- import {
2
- XUIProvider,
3
- useColorMode,
4
- useXUIColors,
5
- useXUITheme
6
- } from "../chunk-4GTYR4N2.js";
1
+ // src/core/theme-context.tsx
2
+ import React, { createContext } from "react";
3
+
4
+ // src/core/theme-hooks.ts
5
+ import { useContext, useEffect, useState } from "react";
6
+ var getWebColorMode = () => {
7
+ if (typeof globalThis === "undefined") return "light";
8
+ const globalScope = globalThis;
9
+ if (!globalScope.matchMedia) {
10
+ return "light";
11
+ }
12
+ return globalScope.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
13
+ };
14
+ function useColorMode() {
15
+ const [webScheme, setWebScheme] = useState(() => getWebColorMode());
16
+ useEffect(() => {
17
+ if (typeof globalThis === "undefined") return;
18
+ const globalScope = globalThis;
19
+ if (!globalScope.matchMedia) return;
20
+ const media = globalScope.matchMedia("(prefers-color-scheme: dark)");
21
+ const handleChange = () => {
22
+ setWebScheme(media.matches ? "dark" : "light");
23
+ };
24
+ handleChange();
25
+ if (typeof media.addEventListener === "function") {
26
+ media.addEventListener("change", handleChange);
27
+ return () => media.removeEventListener?.("change", handleChange);
28
+ }
29
+ const legacyMedia = media;
30
+ legacyMedia.addListener?.(handleChange);
31
+ return () => legacyMedia.removeListener?.(handleChange);
32
+ }, []);
33
+ return webScheme;
34
+ }
35
+ function useXUITheme() {
36
+ const theme = useContext(XUIThemeContext);
37
+ if (!theme) {
38
+ throw new Error("useXUITheme must be used within XUIProvider");
39
+ }
40
+ return theme;
41
+ }
42
+ function useXUIColors() {
43
+ const theme = useXUITheme();
44
+ return theme.colors;
45
+ }
46
+
47
+ // src/core/theme-context.tsx
48
+ import { defaultTheme } from "@xaui/core/theme";
49
+ import { jsx } from "react/jsx-runtime";
50
+ var XUIThemeContext = createContext(null);
51
+ function XUIProvider({
52
+ children,
53
+ theme: lightTheme,
54
+ darkTheme
55
+ }) {
56
+ const colorScheme = useColorMode();
57
+ const theme = React.useMemo(() => {
58
+ if (!darkTheme && !lightTheme) return defaultTheme;
59
+ const activeTheme = colorScheme === "dark" && darkTheme ? darkTheme : lightTheme;
60
+ if (!activeTheme) return defaultTheme;
61
+ return {
62
+ ...defaultTheme,
63
+ ...activeTheme,
64
+ colors: {
65
+ ...defaultTheme.colors,
66
+ ...activeTheme.colors
67
+ },
68
+ fontFamilies: {
69
+ ...defaultTheme.fontFamilies,
70
+ ...activeTheme.fontFamilies
71
+ },
72
+ fontSizes: {
73
+ ...defaultTheme.fontSizes,
74
+ ...activeTheme.fontSizes
75
+ }
76
+ };
77
+ }, [lightTheme, darkTheme, colorScheme]);
78
+ return /* @__PURE__ */ jsx(XUIThemeContext.Provider, { value: theme, children });
79
+ }
7
80
  export {
8
81
  XUIProvider,
9
82
  useColorMode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaui/hybrid",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Flutter-inspired React UI components for web and mobile webview applications with Framer Motion animations and Tailwind CSS styling",
5
5
  "keywords": [
6
6
  "react",
@@ -58,10 +58,9 @@
58
58
  "clsx": "^2.1.1",
59
59
  "tailwind-merge": "^3.4.0",
60
60
  "tailwind-variants": "^0.3.1",
61
- "@xaui/core": "0.1.7"
61
+ "@xaui/core": "0.1.9"
62
62
  },
63
63
  "peerDependencies": {
64
- "framer-motion": "^11.0.0",
65
64
  "react": "^18.0.0 || ^19.0.0",
66
65
  "react-dom": "^18.0.0 || ^19.0.0",
67
66
  "tailwindcss": "^4.0.0"