@kbach/react 0.1.3 → 0.1.5

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 CHANGED
@@ -12,7 +12,7 @@ Tailwind-like utility classes for **React (web)**. Classes are converted to inli
12
12
 
13
13
  ## Install
14
14
 
15
- ```bash
15
+ ```
16
16
  npm install @kbach/react
17
17
  ```
18
18
 
@@ -22,7 +22,7 @@ npm install @kbach/react
22
22
 
23
23
  **tsconfig.json**
24
24
 
25
- ```jsonc
25
+ ```
26
26
  {
27
27
  "compilerOptions": {
28
28
  "jsx": "react-jsx",
@@ -33,7 +33,7 @@ npm install @kbach/react
33
33
 
34
34
  **Vite**
35
35
 
36
- ```js
36
+ ```
37
37
  // vite.config.ts
38
38
  import { defineConfig } from 'vite';
39
39
  import react from '@vitejs/plugin-react';
@@ -45,7 +45,7 @@ export default defineConfig({
45
45
 
46
46
  **Babel**
47
47
 
48
- ```js
48
+ ```
49
49
  // babel.config.js
50
50
  module.exports = {
51
51
  presets: [
@@ -232,7 +232,7 @@ Available families: slate, gray, zinc, neutral, stone, red, orange, amber, yello
232
232
 
233
233
  ## Configuration
234
234
 
235
- ```js
235
+ ```
236
236
  // kbach.config.js
237
237
  module.exports = {
238
238
  darkMode: 'attribute', // 'attribute' | 'class' | 'media'
package/dist/index.js CHANGED
@@ -115,7 +115,8 @@ function ThemeProvider({
115
115
  return window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
116
116
  }
117
117
  if (Appearance) {
118
- return Appearance.getColorScheme() === "dark" ? "dark" : "light";
118
+ const scheme = Appearance.getColorScheme();
119
+ return scheme === "dark" ? "dark" : "light";
119
120
  }
120
121
  return "light";
121
122
  }, []);
@@ -143,6 +144,14 @@ function ThemeProvider({
143
144
  }, [isDark, resolvedMode, resolvedConfig.darkMode]);
144
145
  const setSystemSchemeRef = (0, import_react2.useRef)(setSystemScheme);
145
146
  setSystemSchemeRef.current = setSystemScheme;
147
+ (0, import_react2.useEffect)(() => {
148
+ if (Appearance) {
149
+ const scheme = Appearance.getColorScheme();
150
+ if (scheme != null) {
151
+ setSystemSchemeRef.current(scheme === "dark" ? "dark" : "light");
152
+ }
153
+ }
154
+ }, []);
146
155
  (0, import_react2.useEffect)(() => {
147
156
  if (import_core.isWeb && typeof window !== "undefined") {
148
157
  const mq = window.matchMedia?.("(prefers-color-scheme: dark)");
package/dist/index.mjs CHANGED
@@ -80,7 +80,8 @@ function ThemeProvider({
80
80
  return window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
81
81
  }
82
82
  if (Appearance) {
83
- return Appearance.getColorScheme() === "dark" ? "dark" : "light";
83
+ const scheme = Appearance.getColorScheme();
84
+ return scheme === "dark" ? "dark" : "light";
84
85
  }
85
86
  return "light";
86
87
  }, []);
@@ -108,6 +109,14 @@ function ThemeProvider({
108
109
  }, [isDark, resolvedMode, resolvedConfig.darkMode]);
109
110
  const setSystemSchemeRef = useRef(setSystemScheme);
110
111
  setSystemSchemeRef.current = setSystemScheme;
112
+ useEffect(() => {
113
+ if (Appearance) {
114
+ const scheme = Appearance.getColorScheme();
115
+ if (scheme != null) {
116
+ setSystemSchemeRef.current(scheme === "dark" ? "dark" : "light");
117
+ }
118
+ }
119
+ }, []);
111
120
  useEffect(() => {
112
121
  if (isWeb && typeof window !== "undefined") {
113
122
  const mq = window.matchMedia?.("(prefers-color-scheme: dark)");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "React / React Native components and hooks for the Kbach framework",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.js",
@@ -36,7 +36,7 @@
36
36
  "lint": "tsc --noEmit"
37
37
  },
38
38
  "dependencies": {
39
- "@kbach/core": "0.1.0"
39
+ "@kbach/core": "0.1.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/react": "^19.2.0",