@kbach/react-native 1.0.0-beta.45 → 1.0.0-beta.47
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 +73 -13
- package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
- package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
- package/dist/chunk-3KLOVONL.mjs +564 -0
- package/dist/{chunk-UFSVFF3V.mjs → chunk-SC3L5I7H.mjs} +1 -1
- package/dist/{chunk-KT6TQLWI.mjs → chunk-XOH25F3E.mjs} +1 -1
- package/dist/dynamicTokens.d.ts +18 -1
- package/dist/index.js +22 -2
- package/dist/index.web.js +1 -1
- package/dist/index.web.mjs +2 -2
- package/dist/jsx-dev-runtime.js +22 -2
- package/dist/jsx-dev-runtime.web.js +1 -1
- package/dist/jsx-dev-runtime.web.mjs +3 -3
- package/dist/jsx-runtime.js +22 -2
- package/dist/jsx-runtime.web.js +1 -1
- package/dist/jsx-runtime.web.mjs +2 -2
- package/package.json +1 -1
- package/dist/chunk-DKZM4NUU.mjs +0 -564
package/README.md
CHANGED
|
@@ -4,8 +4,10 @@ Utility-class styling for React Native — the same class names as
|
|
|
4
4
|
[`@kbach/react`](https://www.npmjs.com/package/@kbach/react), resolved to a
|
|
5
5
|
`StyleSheet`-ready style object instead of CSS.
|
|
6
6
|
|
|
7
|
-
> **Beta.** Native is Android-only (no iOS bridge yet)
|
|
8
|
-
>
|
|
7
|
+
> **Beta.** Native is Android-only (no iOS bridge yet) — on iOS, every
|
|
8
|
+
> build (dev client, CLI, EAS) runs the same reduced-coverage JS-fallback
|
|
9
|
+
> engine as Expo Go, not the full native engine. Ships a prebuilt native
|
|
10
|
+
> module — no Rust toolchain or manual linking.
|
|
9
11
|
|
|
10
12
|
## Install
|
|
11
13
|
|
|
@@ -15,12 +17,18 @@ npm install @kbach/react-native@beta
|
|
|
15
17
|
|
|
16
18
|
## Setup
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
The babel plugin (below) is **required on every target, including Expo
|
|
21
|
+
Go** — it's the only thing that makes `className` get intercepted at all;
|
|
22
|
+
without it, `className` is just an unrecognized prop RN silently ignores
|
|
23
|
+
(no styling, no warning). What differs per target is what happens *after*
|
|
24
|
+
that:
|
|
25
|
+
|
|
26
|
+
| Target | Setup |
|
|
19
27
|
| :-- | :-- |
|
|
20
|
-
| **Expo Go** |
|
|
21
|
-
| **Expo Web** / `react-native-web` |
|
|
28
|
+
| **Expo Go** | Add the babel plugin (below). A pure-JS fallback engine loads automatically after that — no other setup. |
|
|
29
|
+
| **Expo Web** / `react-native-web` | Add the babel plugin (below). Resolves through the same CSS engine `@kbach/react` uses after that — no other setup. |
|
|
22
30
|
| **Expo dev client / prebuild / EAS** | Add the babel plugin (below), then `npx expo prebuild && npx expo run:android`. |
|
|
23
|
-
| **React Native CLI** | Add the babel plugin (below), then rebuild the app. |
|
|
31
|
+
| **React Native CLI** | Add the babel plugin (below), then restart Metro with `--reset-cache` and rebuild the app. |
|
|
24
32
|
|
|
25
33
|
The babel plugin, added to your existing `babel.config.js`:
|
|
26
34
|
|
|
@@ -43,6 +51,11 @@ module.exports = {
|
|
|
43
51
|
};
|
|
44
52
|
```
|
|
45
53
|
|
|
54
|
+
A plain JS reload isn't enough after adding the plugin or editing
|
|
55
|
+
`kbach.config.js` — Metro's transform cache doesn't reliably pick up a
|
|
56
|
+
babel config change on its own. Restart with `--reset-cache` (`npx
|
|
57
|
+
react-native start --reset-cache` / `npx expo start --clear`).
|
|
58
|
+
|
|
46
59
|
Then write classes:
|
|
47
60
|
|
|
48
61
|
```tsx
|
|
@@ -90,6 +103,27 @@ const { mode, isDark, setMode, toggle } = useTheme();
|
|
|
90
103
|
|
|
91
104
|
Works anywhere, no provider. `<ThemeProvider>` is optional — for seeding a
|
|
92
105
|
startup default and opt-in persistence (`<ThemeProvider persist={AsyncStorage}>`).
|
|
106
|
+
Mount at most one — a second instance logs a dev warning, since dark mode
|
|
107
|
+
is one global store, not scoped per provider.
|
|
108
|
+
|
|
109
|
+
## Dynamic values
|
|
110
|
+
|
|
111
|
+
For a value that changes at runtime without touching component state —
|
|
112
|
+
a live accent color, a user-picked theme:
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
import { setDynamicToken, useDynamicToken } from '@kbach/react-native';
|
|
116
|
+
|
|
117
|
+
setDynamicToken('accent', '#8b5cf6');
|
|
118
|
+
|
|
119
|
+
<View className="bg-[var(--accent)]" />; // updates instantly, everywhere it's used
|
|
120
|
+
const accent = useDynamicToken('accent'); // '#8b5cf6' | undefined, reactive
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Call `setDynamicToken` from a component's own render (guarded to fire
|
|
124
|
+
once), not from module top-level — see
|
|
125
|
+
[AGENTS.md §8](https://github.com/semsakadanupol/kbach/blob/main/packages/react-native/AGENTS.md)
|
|
126
|
+
for why and the exact pattern.
|
|
93
127
|
|
|
94
128
|
## Colors as values
|
|
95
129
|
|
|
@@ -113,13 +147,39 @@ container queries parse without error but do not apply. When two classes
|
|
|
113
147
|
set the same property the more-specific one wins regardless of source
|
|
114
148
|
order (`dark:bg-black bg-white` → black in dark mode).
|
|
115
149
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
150
|
+
`hover:` only fires for pointer-capable input (mouse/trackpad) — it's
|
|
151
|
+
inert on pure touch, so don't expect it to do anything on a phone/tablet
|
|
152
|
+
with no attached pointer.
|
|
153
|
+
|
|
154
|
+
`disabled:`/`aria-[…]:`/`data-[…]:` read that exact element's own props —
|
|
155
|
+
never a parent's, since there's no `group-disabled:`-style cascade to
|
|
156
|
+
inherit through. `<Pressable disabled><Text className="disabled:text-gray-5">`
|
|
157
|
+
does nothing to the `Text`, silently, because `Text` never received a
|
|
158
|
+
`disabled` prop of its own; the prop has to be repeated on whichever
|
|
159
|
+
element the modifier is written on:
|
|
160
|
+
`<Pressable disabled><Text disabled className="disabled:text-gray-5">`.
|
|
161
|
+
|
|
162
|
+
Expo Go, and iOS in ANY build type (no native engine there yet — see the
|
|
163
|
+
callout at the top), cover the same documented subset of utilities (no
|
|
164
|
+
grid, filters, gradients, or DOM-only typography). Expo Web and a real
|
|
165
|
+
**Android** dev-client/CLI build cover the full set.
|
|
166
|
+
|
|
167
|
+
A malformed or misused value fails safely — a deduped, dev-only
|
|
168
|
+
`console.warn` naming the offending class and the fix, never a crash or
|
|
169
|
+
silently-wrong output. Confirmed across CSS-injection attempts, invalid
|
|
170
|
+
`calc()` operands, and double-mounting.
|
|
171
|
+
|
|
172
|
+
`clsx()` — this package's own bundled copy, `import { clsx } from
|
|
173
|
+
'@kbach/react-native'` — composes conditional class strings the same way
|
|
174
|
+
the standalone `clsx` package does. You don't need it for `dark:`/`sm:`/
|
|
175
|
+
etc. (those work as plain classes), but it's there for `isActive &&
|
|
176
|
+
'bg-blue-6'`-style composition.
|
|
177
|
+
|
|
178
|
+
See [this package's own AGENTS.md](https://github.com/semsakadanupol/kbach/blob/main/packages/react-native/AGENTS.md)
|
|
179
|
+
for the complete reference — modifier list, `calc()`/`min()`/`max()`/
|
|
180
|
+
`clamp()` support, dynamic tokens, monorepo setup, and failure modes; see
|
|
181
|
+
the [root AGENTS.md](https://github.com/semsakadanupol/kbach/blob/main/AGENTS.md)
|
|
182
|
+
for `kbach.config.js` and how the underlying engine is built.
|
|
123
183
|
|
|
124
184
|
## License
|
|
125
185
|
|
|
Binary file
|
|
Binary file
|