@kbach/react-native 1.0.0-beta.14 → 1.0.0-beta.16
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 +50 -0
- package/dist/chunk-3ED4FIO2.mjs +552 -0
- package/dist/{chunk-6QFPLRSP.mjs → chunk-6ML62O2R.mjs} +1 -1
- package/dist/{chunk-RBJXE32L.mjs → chunk-XGQWM65X.mjs} +1 -1
- package/dist/darkModeStore.d.ts +58 -0
- package/dist/darkModeStore.js +112 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +36 -448
- package/dist/index.web.d.ts +3 -1
- package/dist/index.web.js +34 -447
- package/dist/index.web.mjs +169 -12
- package/dist/jsx-dev-runtime.js +31 -415
- package/dist/jsx-dev-runtime.web.js +7 -396
- package/dist/jsx-dev-runtime.web.mjs +18 -7
- package/dist/jsx-runtime.js +31 -415
- package/dist/jsx-runtime.web.js +4 -354
- package/dist/jsx-runtime.web.mjs +2 -3
- package/dist/theme.d.ts +54 -0
- package/dist/{chunk-HK6PDJJK.mjs → theme.js} +34 -5
- package/dist/{useColors-C6jyCLuG.d.ts → useColors-Br8QhIlE.d.ts} +3 -95
- package/package.json +3 -7
- package/dist/chunk-H57O3BJO.mjs +0 -84
- package/dist/chunk-JMNJCPGK.mjs +0 -1239
- package/dist/chunk-TDWBXJH5.mjs +0 -186
- package/dist/chunk-WT6WH54F.mjs +0 -14
- package/dist/chunk-ZB2UU6EO.mjs +0 -192
- package/dist/index.d.mts +0 -83
- package/dist/index.mjs +0 -38
- package/dist/index.web.d.mts +0 -15
- package/dist/jsx-dev-runtime.d.mts +0 -10
- package/dist/jsx-dev-runtime.mjs +0 -18
- package/dist/jsx-dev-runtime.web.d.mts +0 -10
- package/dist/jsx-runtime.d.mts +0 -7
- package/dist/jsx-runtime.mjs +0 -15
- package/dist/jsx-runtime.web.d.mts +0 -7
- package/dist/useColors-C6jyCLuG.d.mts +0 -239
package/dist/index.web.mjs
CHANGED
|
@@ -1,25 +1,182 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ThemeProvider,
|
|
3
|
-
applyKbachConfig,
|
|
4
|
-
resolveKbachConfig,
|
|
5
|
-
useColors,
|
|
6
|
-
useTheme
|
|
7
|
-
} from "./chunk-TDWBXJH5.mjs";
|
|
8
|
-
import {
|
|
9
|
-
resolveClassName
|
|
10
|
-
} from "./chunk-ZB2UU6EO.mjs";
|
|
11
1
|
import {
|
|
12
2
|
getGlobalDarkMode,
|
|
13
3
|
getGlobalThemeMode,
|
|
4
|
+
seedDefaultMode,
|
|
14
5
|
setGlobalThemeMode,
|
|
15
6
|
subscribeGlobalDarkMode,
|
|
16
7
|
toggleGlobalDarkMode
|
|
17
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XGQWM65X.mjs";
|
|
18
9
|
import {
|
|
19
10
|
defaultTheme,
|
|
20
11
|
getTheme,
|
|
12
|
+
resolveClassName,
|
|
21
13
|
setTheme
|
|
22
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-3ED4FIO2.mjs";
|
|
15
|
+
|
|
16
|
+
// src/config.ts
|
|
17
|
+
function parseHexRgb(hex) {
|
|
18
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
19
|
+
if (!m) return null;
|
|
20
|
+
let h = m[1];
|
|
21
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
22
|
+
const n = parseInt(h, 16);
|
|
23
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
24
|
+
}
|
|
25
|
+
function applyOpacityToHex(hex, opacityText) {
|
|
26
|
+
const rgb = parseHexRgb(hex);
|
|
27
|
+
if (!rgb) return hex;
|
|
28
|
+
const a = Number(opacityText) / 100;
|
|
29
|
+
const clamped = Number.isFinite(a) ? Math.min(1, Math.max(0, a)) : 1;
|
|
30
|
+
return `rgba(${rgb.join(",")},${clamped})`;
|
|
31
|
+
}
|
|
32
|
+
function resolveColorEntry(value, lookup) {
|
|
33
|
+
const slash = value.indexOf("/");
|
|
34
|
+
const name = slash === -1 ? value : value.slice(0, slash);
|
|
35
|
+
const opacity = slash === -1 ? void 0 : value.slice(slash + 1);
|
|
36
|
+
const base = lookup(name);
|
|
37
|
+
if (base === void 0) return value;
|
|
38
|
+
return opacity === void 0 ? base : applyOpacityToHex(base, opacity);
|
|
39
|
+
}
|
|
40
|
+
function resolveColors(extend, existing) {
|
|
41
|
+
const resolved = {};
|
|
42
|
+
const lookup = (name) => {
|
|
43
|
+
const found = resolved[name] ?? existing[name];
|
|
44
|
+
return typeof found === "string" ? found : void 0;
|
|
45
|
+
};
|
|
46
|
+
for (const [name, value] of Object.entries(extend)) {
|
|
47
|
+
resolved[name] = resolveColorEntry(value, lookup);
|
|
48
|
+
}
|
|
49
|
+
return resolved;
|
|
50
|
+
}
|
|
51
|
+
function resolveKbachConfig(config) {
|
|
52
|
+
let theme = { ...defaultTheme, ...config.theme };
|
|
53
|
+
if (config.extend?.colors) {
|
|
54
|
+
theme = { ...theme, colors: { ...theme.colors, ...resolveColors(config.extend.colors, theme.colors) } };
|
|
55
|
+
}
|
|
56
|
+
if (config.extend?.spacing) {
|
|
57
|
+
theme = { ...theme, spacing: { ...theme.spacing, ...config.extend.spacing } };
|
|
58
|
+
}
|
|
59
|
+
if (config.extend?.screens) {
|
|
60
|
+
theme = { ...theme, screens: { ...theme.screens, ...config.extend.screens } };
|
|
61
|
+
}
|
|
62
|
+
if (config.extend?.fontFamily) {
|
|
63
|
+
theme = { ...theme, fontFamily: { ...theme.fontFamily, ...config.extend.fontFamily } };
|
|
64
|
+
}
|
|
65
|
+
if (config.extend?.container) {
|
|
66
|
+
theme = { ...theme, container: { ...theme.container, ...config.extend.container } };
|
|
67
|
+
}
|
|
68
|
+
if (config.darkMode) {
|
|
69
|
+
theme = { ...theme, darkMode: config.darkMode };
|
|
70
|
+
}
|
|
71
|
+
return theme;
|
|
72
|
+
}
|
|
73
|
+
function applyKbachConfig(config) {
|
|
74
|
+
const theme = resolveKbachConfig(config);
|
|
75
|
+
setTheme(theme);
|
|
76
|
+
return theme;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/useTheme.ts
|
|
80
|
+
import { useMemo, useSyncExternalStore } from "react";
|
|
81
|
+
function useTheme() {
|
|
82
|
+
const isDark = useSyncExternalStore(subscribeGlobalDarkMode, getGlobalDarkMode);
|
|
83
|
+
const mode = useSyncExternalStore(subscribeGlobalDarkMode, getGlobalThemeMode);
|
|
84
|
+
return useMemo(
|
|
85
|
+
() => ({ mode, isDark, setMode: setGlobalThemeMode, toggle: toggleGlobalDarkMode }),
|
|
86
|
+
[mode, isDark]
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/ThemeProvider.tsx
|
|
91
|
+
import { useEffect, useRef } from "react";
|
|
92
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
93
|
+
var mountedProviderCount = 0;
|
|
94
|
+
var warnedMultipleProviders = false;
|
|
95
|
+
function ThemeProvider({ children, defaultMode = "system" }) {
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
mountedProviderCount++;
|
|
98
|
+
if (mountedProviderCount > 1 && !warnedMultipleProviders) {
|
|
99
|
+
warnedMultipleProviders = true;
|
|
100
|
+
console.warn(
|
|
101
|
+
"[kbach] Multiple <ThemeProvider> instances are mounted at once. Dark-mode state is one global store useTheme() reads everywhere, not scoped per-provider, so their defaultMode seeds will fight over the same state."
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return () => {
|
|
105
|
+
mountedProviderCount--;
|
|
106
|
+
};
|
|
107
|
+
}, []);
|
|
108
|
+
const seeded = useRef(false);
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (seeded.current) return;
|
|
111
|
+
seeded.current = true;
|
|
112
|
+
seedDefaultMode(defaultMode);
|
|
113
|
+
}, []);
|
|
114
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/useColors.ts
|
|
118
|
+
function parseHexRgb2(hex) {
|
|
119
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
120
|
+
if (!m) return null;
|
|
121
|
+
let h = m[1];
|
|
122
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
123
|
+
const n = parseInt(h, 16);
|
|
124
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
125
|
+
}
|
|
126
|
+
function applyOpacity(color, opacity) {
|
|
127
|
+
const a = Math.max(0, Math.min(1, opacity / 100));
|
|
128
|
+
if (color.startsWith("#")) {
|
|
129
|
+
const rgb = parseHexRgb2(color);
|
|
130
|
+
return rgb ? `rgba(${rgb.join(",")},${a})` : color;
|
|
131
|
+
}
|
|
132
|
+
if (color.startsWith("rgb(")) return color.replace("rgb(", "rgba(").replace(")", `,${a})`);
|
|
133
|
+
if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
|
|
134
|
+
return color;
|
|
135
|
+
}
|
|
136
|
+
function resolveEntry(entry, isDark) {
|
|
137
|
+
return typeof entry === "string" ? entry : isDark ? entry.dark : entry.light;
|
|
138
|
+
}
|
|
139
|
+
function makeColorsProxy(theme, isDark) {
|
|
140
|
+
const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
|
|
141
|
+
const cache = /* @__PURE__ */ new Map();
|
|
142
|
+
function resolveNamed(key) {
|
|
143
|
+
let name = key;
|
|
144
|
+
let opacity;
|
|
145
|
+
if (key.includes("/")) {
|
|
146
|
+
const slash = key.indexOf("/");
|
|
147
|
+
name = key.slice(0, slash);
|
|
148
|
+
opacity = Number(key.slice(slash + 1));
|
|
149
|
+
}
|
|
150
|
+
const entry = theme.colors[name];
|
|
151
|
+
if (entry === void 0) return void 0;
|
|
152
|
+
const value = resolveEntry(entry, isDark);
|
|
153
|
+
return opacity === void 0 ? value : applyOpacity(value, opacity);
|
|
154
|
+
}
|
|
155
|
+
function makeFamilyProxy(family) {
|
|
156
|
+
return new Proxy({}, {
|
|
157
|
+
get(_, prop) {
|
|
158
|
+
const key = String(prop);
|
|
159
|
+
if (key === "then") return void 0;
|
|
160
|
+
return resolveNamed(`${family}-${key}`);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return new Proxy({ alpha }, {
|
|
165
|
+
get(_, prop) {
|
|
166
|
+
const key = String(prop);
|
|
167
|
+
if (key === "then") return void 0;
|
|
168
|
+
if (key === "alpha") return alpha;
|
|
169
|
+
const direct = resolveNamed(key);
|
|
170
|
+
if (direct !== void 0) return direct;
|
|
171
|
+
if (!cache.has(key)) cache.set(key, makeFamilyProxy(key));
|
|
172
|
+
return cache.get(key);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function useColors() {
|
|
177
|
+
const { isDark } = useTheme();
|
|
178
|
+
return makeColorsProxy(getTheme(), isDark);
|
|
179
|
+
}
|
|
23
180
|
export {
|
|
24
181
|
ThemeProvider,
|
|
25
182
|
applyKbachConfig,
|
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -28,408 +28,9 @@ module.exports = __toCommonJS(jsx_dev_runtime_exports);
|
|
|
28
28
|
// src/jsxRuntimeCore.ts
|
|
29
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
30
|
var import_react = require("react");
|
|
31
|
-
var import_react_native2 = require("react-native");
|
|
32
|
-
|
|
33
|
-
// src/darkModeStore.ts
|
|
34
31
|
var import_react_native = require("react-native");
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var PALETTE = {
|
|
38
|
-
"amber-1": "#fffbeb",
|
|
39
|
-
"amber-10": "#78350f",
|
|
40
|
-
"amber-11": "#451a03",
|
|
41
|
-
"amber-12": "#291002",
|
|
42
|
-
"amber-2": "#fef3c7",
|
|
43
|
-
"amber-3": "#fde68a",
|
|
44
|
-
"amber-4": "#fcd34d",
|
|
45
|
-
"amber-5": "#fbbf24",
|
|
46
|
-
"amber-6": "#f59e0b",
|
|
47
|
-
"amber-7": "#d97706",
|
|
48
|
-
"amber-8": "#b45309",
|
|
49
|
-
"amber-9": "#92400e",
|
|
50
|
-
"black": "#000000",
|
|
51
|
-
"blue-1": "#eff6ff",
|
|
52
|
-
"blue-10": "#1e3a8a",
|
|
53
|
-
"blue-11": "#172554",
|
|
54
|
-
"blue-12": "#0d1633",
|
|
55
|
-
"blue-2": "#dbeafe",
|
|
56
|
-
"blue-3": "#bfdbfe",
|
|
57
|
-
"blue-4": "#93c5fd",
|
|
58
|
-
"blue-5": "#60a5fa",
|
|
59
|
-
"blue-6": "#3b82f6",
|
|
60
|
-
"blue-7": "#2563eb",
|
|
61
|
-
"blue-8": "#1d4ed8",
|
|
62
|
-
"blue-9": "#1e40af",
|
|
63
|
-
"bronze": "#cd7f32",
|
|
64
|
-
"coal": "#1c1c1c",
|
|
65
|
-
"copper": "#b87333",
|
|
66
|
-
"current": "currentColor",
|
|
67
|
-
"cyan-1": "#ecfeff",
|
|
68
|
-
"cyan-10": "#164e63",
|
|
69
|
-
"cyan-11": "#083344",
|
|
70
|
-
"cyan-12": "#041e28",
|
|
71
|
-
"cyan-2": "#cffafe",
|
|
72
|
-
"cyan-3": "#a5f3fc",
|
|
73
|
-
"cyan-4": "#67e8f9",
|
|
74
|
-
"cyan-5": "#22d3ee",
|
|
75
|
-
"cyan-6": "#06b6d4",
|
|
76
|
-
"cyan-7": "#0891b2",
|
|
77
|
-
"cyan-8": "#0e7490",
|
|
78
|
-
"cyan-9": "#155e75",
|
|
79
|
-
"emerald-1": "#ecfdf5",
|
|
80
|
-
"emerald-10": "#064e3b",
|
|
81
|
-
"emerald-11": "#022c22",
|
|
82
|
-
"emerald-12": "#011a14",
|
|
83
|
-
"emerald-2": "#d1fae5",
|
|
84
|
-
"emerald-3": "#a7f3d0",
|
|
85
|
-
"emerald-4": "#6ee7b7",
|
|
86
|
-
"emerald-5": "#34d399",
|
|
87
|
-
"emerald-6": "#10b981",
|
|
88
|
-
"emerald-7": "#059669",
|
|
89
|
-
"emerald-8": "#047857",
|
|
90
|
-
"emerald-9": "#065f46",
|
|
91
|
-
"fuchsia-1": "#fdf4ff",
|
|
92
|
-
"fuchsia-10": "#701a75",
|
|
93
|
-
"fuchsia-11": "#4a044e",
|
|
94
|
-
"fuchsia-12": "#2d022f",
|
|
95
|
-
"fuchsia-2": "#fae8ff",
|
|
96
|
-
"fuchsia-3": "#f5d0fe",
|
|
97
|
-
"fuchsia-4": "#f0abfc",
|
|
98
|
-
"fuchsia-5": "#e879f9",
|
|
99
|
-
"fuchsia-6": "#d946ef",
|
|
100
|
-
"fuchsia-7": "#c026d3",
|
|
101
|
-
"fuchsia-8": "#a21caf",
|
|
102
|
-
"fuchsia-9": "#86198f",
|
|
103
|
-
"gold": "#d4af37",
|
|
104
|
-
"gray-1": "#f9fafb",
|
|
105
|
-
"gray-10": "#111827",
|
|
106
|
-
"gray-11": "#030712",
|
|
107
|
-
"gray-12": "#020409",
|
|
108
|
-
"gray-2": "#f3f4f6",
|
|
109
|
-
"gray-3": "#e5e7eb",
|
|
110
|
-
"gray-4": "#d1d5db",
|
|
111
|
-
"gray-5": "#9ca3af",
|
|
112
|
-
"gray-6": "#6b7280",
|
|
113
|
-
"gray-7": "#4b5563",
|
|
114
|
-
"gray-8": "#374151",
|
|
115
|
-
"gray-9": "#1f2937",
|
|
116
|
-
"green-1": "#f0fdf4",
|
|
117
|
-
"green-10": "#14532d",
|
|
118
|
-
"green-11": "#052e16",
|
|
119
|
-
"green-12": "#031b0d",
|
|
120
|
-
"green-2": "#dcfce7",
|
|
121
|
-
"green-3": "#bbf7d0",
|
|
122
|
-
"green-4": "#86efac",
|
|
123
|
-
"green-5": "#4ade80",
|
|
124
|
-
"green-6": "#22c55e",
|
|
125
|
-
"green-7": "#16a34a",
|
|
126
|
-
"green-8": "#15803d",
|
|
127
|
-
"green-9": "#166534",
|
|
128
|
-
"indigo-1": "#eef2ff",
|
|
129
|
-
"indigo-10": "#312e81",
|
|
130
|
-
"indigo-11": "#1e1b4b",
|
|
131
|
-
"indigo-12": "#12102d",
|
|
132
|
-
"indigo-2": "#e0e7ff",
|
|
133
|
-
"indigo-3": "#c7d2fe",
|
|
134
|
-
"indigo-4": "#a5b4fc",
|
|
135
|
-
"indigo-5": "#818cf8",
|
|
136
|
-
"indigo-6": "#6366f1",
|
|
137
|
-
"indigo-7": "#4f46e5",
|
|
138
|
-
"indigo-8": "#4338ca",
|
|
139
|
-
"indigo-9": "#3730a3",
|
|
140
|
-
"lime-1": "#f7fee7",
|
|
141
|
-
"lime-10": "#365314",
|
|
142
|
-
"lime-11": "#1a2e05",
|
|
143
|
-
"lime-12": "#0f1b03",
|
|
144
|
-
"lime-2": "#ecfccb",
|
|
145
|
-
"lime-3": "#d9f99d",
|
|
146
|
-
"lime-4": "#bef264",
|
|
147
|
-
"lime-5": "#a3e635",
|
|
148
|
-
"lime-6": "#84cc16",
|
|
149
|
-
"lime-7": "#65a30d",
|
|
150
|
-
"lime-8": "#4d7c0f",
|
|
151
|
-
"lime-9": "#3f6212",
|
|
152
|
-
"neutral-1": "#fafafa",
|
|
153
|
-
"neutral-10": "#171717",
|
|
154
|
-
"neutral-11": "#0a0a0a",
|
|
155
|
-
"neutral-12": "#050505",
|
|
156
|
-
"neutral-2": "#f5f5f5",
|
|
157
|
-
"neutral-3": "#e5e5e5",
|
|
158
|
-
"neutral-4": "#d4d4d4",
|
|
159
|
-
"neutral-5": "#a3a3a3",
|
|
160
|
-
"neutral-6": "#737373",
|
|
161
|
-
"neutral-7": "#525252",
|
|
162
|
-
"neutral-8": "#404040",
|
|
163
|
-
"neutral-9": "#262626",
|
|
164
|
-
"orange-1": "#fff7ed",
|
|
165
|
-
"orange-10": "#7c2d12",
|
|
166
|
-
"orange-11": "#431407",
|
|
167
|
-
"orange-12": "#270c04",
|
|
168
|
-
"orange-2": "#ffedd5",
|
|
169
|
-
"orange-3": "#fed7aa",
|
|
170
|
-
"orange-4": "#fdba74",
|
|
171
|
-
"orange-5": "#fb923c",
|
|
172
|
-
"orange-6": "#f97316",
|
|
173
|
-
"orange-7": "#ea580c",
|
|
174
|
-
"orange-8": "#c2410c",
|
|
175
|
-
"orange-9": "#9a3412",
|
|
176
|
-
"pink-1": "#fdf2f8",
|
|
177
|
-
"pink-10": "#831843",
|
|
178
|
-
"pink-11": "#500724",
|
|
179
|
-
"pink-12": "#300415",
|
|
180
|
-
"pink-2": "#fce7f3",
|
|
181
|
-
"pink-3": "#fbcfe8",
|
|
182
|
-
"pink-4": "#f9a8d4",
|
|
183
|
-
"pink-5": "#f472b6",
|
|
184
|
-
"pink-6": "#ec4899",
|
|
185
|
-
"pink-7": "#db2777",
|
|
186
|
-
"pink-8": "#be185d",
|
|
187
|
-
"pink-9": "#9d174d",
|
|
188
|
-
"purple-1": "#faf5ff",
|
|
189
|
-
"purple-10": "#581c87",
|
|
190
|
-
"purple-11": "#3b0764",
|
|
191
|
-
"purple-12": "#23043c",
|
|
192
|
-
"purple-2": "#f3e8ff",
|
|
193
|
-
"purple-3": "#e9d5ff",
|
|
194
|
-
"purple-4": "#d8b4fe",
|
|
195
|
-
"purple-5": "#c084fc",
|
|
196
|
-
"purple-6": "#a855f7",
|
|
197
|
-
"purple-7": "#9333ea",
|
|
198
|
-
"purple-8": "#7e22ce",
|
|
199
|
-
"purple-9": "#6b21a8",
|
|
200
|
-
"red-1": "#fef2f2",
|
|
201
|
-
"red-10": "#7f1d1d",
|
|
202
|
-
"red-11": "#450a0a",
|
|
203
|
-
"red-12": "#280606",
|
|
204
|
-
"red-2": "#fee2e2",
|
|
205
|
-
"red-3": "#fecaca",
|
|
206
|
-
"red-4": "#fca5a5",
|
|
207
|
-
"red-5": "#f87171",
|
|
208
|
-
"red-6": "#ef4444",
|
|
209
|
-
"red-7": "#dc2626",
|
|
210
|
-
"red-8": "#b91c1c",
|
|
211
|
-
"red-9": "#991b1b",
|
|
212
|
-
"rose-1": "#fff1f2",
|
|
213
|
-
"rose-10": "#881337",
|
|
214
|
-
"rose-11": "#4c0519",
|
|
215
|
-
"rose-12": "#2d030e",
|
|
216
|
-
"rose-2": "#ffe4e6",
|
|
217
|
-
"rose-3": "#fecdd3",
|
|
218
|
-
"rose-4": "#fda4af",
|
|
219
|
-
"rose-5": "#fb7185",
|
|
220
|
-
"rose-6": "#f43f5e",
|
|
221
|
-
"rose-7": "#e11d48",
|
|
222
|
-
"rose-8": "#be123c",
|
|
223
|
-
"rose-9": "#9f1239",
|
|
224
|
-
"silver": "#c0c0c0",
|
|
225
|
-
"sky-1": "#f0f9ff",
|
|
226
|
-
"sky-10": "#0c4a6e",
|
|
227
|
-
"sky-11": "#082f49",
|
|
228
|
-
"sky-12": "#041b2b",
|
|
229
|
-
"sky-2": "#e0f2fe",
|
|
230
|
-
"sky-3": "#bae6fd",
|
|
231
|
-
"sky-4": "#7dd3fc",
|
|
232
|
-
"sky-5": "#38bdf8",
|
|
233
|
-
"sky-6": "#0ea5e9",
|
|
234
|
-
"sky-7": "#0284c7",
|
|
235
|
-
"sky-8": "#0369a1",
|
|
236
|
-
"sky-9": "#075985",
|
|
237
|
-
"slate-1": "#f8fafc",
|
|
238
|
-
"slate-10": "#0f172a",
|
|
239
|
-
"slate-11": "#020617",
|
|
240
|
-
"slate-12": "#01020a",
|
|
241
|
-
"slate-2": "#f1f5f9",
|
|
242
|
-
"slate-3": "#e2e8f0",
|
|
243
|
-
"slate-4": "#cbd5e1",
|
|
244
|
-
"slate-5": "#94a3b8",
|
|
245
|
-
"slate-6": "#64748b",
|
|
246
|
-
"slate-7": "#475569",
|
|
247
|
-
"slate-8": "#334155",
|
|
248
|
-
"slate-9": "#1e293b",
|
|
249
|
-
"stone-1": "#fafaf9",
|
|
250
|
-
"stone-10": "#1c1917",
|
|
251
|
-
"stone-11": "#0c0a09",
|
|
252
|
-
"stone-12": "#070605",
|
|
253
|
-
"stone-2": "#f5f5f4",
|
|
254
|
-
"stone-3": "#e7e5e4",
|
|
255
|
-
"stone-4": "#d6d3d1",
|
|
256
|
-
"stone-5": "#a8a29e",
|
|
257
|
-
"stone-6": "#78716c",
|
|
258
|
-
"stone-7": "#57534e",
|
|
259
|
-
"stone-8": "#44403c",
|
|
260
|
-
"stone-9": "#292524",
|
|
261
|
-
"teal-1": "#f0fdfa",
|
|
262
|
-
"teal-10": "#134e4a",
|
|
263
|
-
"teal-11": "#042f2e",
|
|
264
|
-
"teal-12": "#021c1b",
|
|
265
|
-
"teal-2": "#ccfbf1",
|
|
266
|
-
"teal-3": "#99f6e4",
|
|
267
|
-
"teal-4": "#5eead4",
|
|
268
|
-
"teal-5": "#2dd4bf",
|
|
269
|
-
"teal-6": "#14b8a6",
|
|
270
|
-
"teal-7": "#0d9488",
|
|
271
|
-
"teal-8": "#0f766e",
|
|
272
|
-
"teal-9": "#115e59",
|
|
273
|
-
"transparent": "transparent",
|
|
274
|
-
"violet-1": "#f5f3ff",
|
|
275
|
-
"violet-10": "#4c1d95",
|
|
276
|
-
"violet-11": "#2e1065",
|
|
277
|
-
"violet-12": "#1c0a3d",
|
|
278
|
-
"violet-2": "#ede9fe",
|
|
279
|
-
"violet-3": "#ddd6fe",
|
|
280
|
-
"violet-4": "#c4b5fd",
|
|
281
|
-
"violet-5": "#a78bfa",
|
|
282
|
-
"violet-6": "#8b5cf6",
|
|
283
|
-
"violet-7": "#7c3aed",
|
|
284
|
-
"violet-8": "#6d28d9",
|
|
285
|
-
"violet-9": "#5b21b6",
|
|
286
|
-
"white": "#ffffff",
|
|
287
|
-
"yellow-1": "#fefce8",
|
|
288
|
-
"yellow-10": "#713f12",
|
|
289
|
-
"yellow-11": "#422006",
|
|
290
|
-
"yellow-12": "#271304",
|
|
291
|
-
"yellow-2": "#fef9c3",
|
|
292
|
-
"yellow-3": "#fef08a",
|
|
293
|
-
"yellow-4": "#fde047",
|
|
294
|
-
"yellow-5": "#facc15",
|
|
295
|
-
"yellow-6": "#eab308",
|
|
296
|
-
"yellow-7": "#ca8a04",
|
|
297
|
-
"yellow-8": "#a16207",
|
|
298
|
-
"yellow-9": "#854d0e",
|
|
299
|
-
"zinc-1": "#fafafa",
|
|
300
|
-
"zinc-10": "#18181b",
|
|
301
|
-
"zinc-11": "#09090b",
|
|
302
|
-
"zinc-12": "#050506",
|
|
303
|
-
"zinc-2": "#f4f4f5",
|
|
304
|
-
"zinc-3": "#e4e4e7",
|
|
305
|
-
"zinc-4": "#d4d4d8",
|
|
306
|
-
"zinc-5": "#a1a1aa",
|
|
307
|
-
"zinc-6": "#71717a",
|
|
308
|
-
"zinc-7": "#52525b",
|
|
309
|
-
"zinc-8": "#3f3f46",
|
|
310
|
-
"zinc-9": "#27272a"
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
// src/theme.ts
|
|
314
|
-
var defaultTheme = {
|
|
315
|
-
colors: PALETTE,
|
|
316
|
-
// Real Tailwind's default spacing scale in full — every step is exactly
|
|
317
|
-
// `n * 4px`, including the fractional `.5` steps (`1.5` -> 6px, `2.5` ->
|
|
318
|
-
// 10px, `3.5` -> 14px) and the "px" literal (a bare 1px). Only the
|
|
319
|
-
// "usual stops", though — `jsEngine/shared.ts`'s `spacingPx` (and the
|
|
320
|
-
// native Rust dispatcher's own `spacing_px`) falls back to Tailwind v4's
|
|
321
|
-
// live `n * 4px` formula for any bare numeric step not listed here
|
|
322
|
-
// (`p-0.25`, `w-13`, ...), so this table names the common values and
|
|
323
|
-
// gives a theme override something to target, not the full resolvable
|
|
324
|
-
// set. Mirrors @kbach/react's theme.ts exactly.
|
|
325
|
-
spacing: {
|
|
326
|
-
"0": 0,
|
|
327
|
-
"px": 1,
|
|
328
|
-
"0.5": 2,
|
|
329
|
-
"1": 4,
|
|
330
|
-
"1.5": 6,
|
|
331
|
-
"2": 8,
|
|
332
|
-
"2.5": 10,
|
|
333
|
-
"3": 12,
|
|
334
|
-
"3.5": 14,
|
|
335
|
-
"4": 16,
|
|
336
|
-
"5": 20,
|
|
337
|
-
"6": 24,
|
|
338
|
-
"7": 28,
|
|
339
|
-
"8": 32,
|
|
340
|
-
"9": 36,
|
|
341
|
-
"10": 40,
|
|
342
|
-
"11": 44,
|
|
343
|
-
"12": 48,
|
|
344
|
-
"14": 56,
|
|
345
|
-
"16": 64,
|
|
346
|
-
"20": 80,
|
|
347
|
-
"24": 96,
|
|
348
|
-
"28": 112,
|
|
349
|
-
"32": 128,
|
|
350
|
-
"36": 144,
|
|
351
|
-
"40": 160,
|
|
352
|
-
"44": 176,
|
|
353
|
-
"48": 192,
|
|
354
|
-
"52": 208,
|
|
355
|
-
"56": 224,
|
|
356
|
-
"60": 240,
|
|
357
|
-
"64": 256,
|
|
358
|
-
"72": 288,
|
|
359
|
-
"80": 320,
|
|
360
|
-
"96": 384
|
|
361
|
-
},
|
|
362
|
-
screens: {
|
|
363
|
-
sm: 640,
|
|
364
|
-
md: 768,
|
|
365
|
-
lg: 1024,
|
|
366
|
-
xl: 1280,
|
|
367
|
-
"2xl": 1536
|
|
368
|
-
},
|
|
369
|
-
// Byte-for-byte the same three stacks
|
|
370
|
-
// packages/core-engine/src/resolvers/typography.rs's `font_family_value`
|
|
371
|
-
// falls back to. On native these three still effectively no-op (see
|
|
372
|
-
// `first_font_name`'s own doc comment for why a generic CSS keyword
|
|
373
|
-
// isn't a real loadable font) — only a caller-configured custom name
|
|
374
|
-
// changes native rendering; Expo Web uses the full stack as-is.
|
|
375
|
-
fontFamily: {
|
|
376
|
-
sans: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
377
|
-
serif: 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
|
|
378
|
-
mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
|
|
379
|
-
},
|
|
380
|
-
darkMode: "attribute",
|
|
381
|
-
// Empty by default, matching real Tailwind's own defaults.
|
|
382
|
-
container: {}
|
|
383
|
-
};
|
|
384
|
-
var activeTheme = defaultTheme;
|
|
385
|
-
var activeThemeJson = JSON.stringify(defaultTheme);
|
|
386
|
-
function getTheme() {
|
|
387
|
-
return activeTheme;
|
|
388
|
-
}
|
|
389
|
-
function getThemeJson() {
|
|
390
|
-
return activeThemeJson;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// src/darkModeStore.ts
|
|
394
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
395
|
-
function systemPrefersDark() {
|
|
396
|
-
return import_react_native.Appearance.getColorScheme() === "dark";
|
|
397
|
-
}
|
|
398
|
-
function resolveIsDark(m) {
|
|
399
|
-
return m === "system" ? systemPrefersDark() : m === "dark";
|
|
400
|
-
}
|
|
401
|
-
function applyToDom(dark) {
|
|
402
|
-
if (typeof document === "undefined") return;
|
|
403
|
-
const root = document.documentElement;
|
|
404
|
-
const strategy = getTheme().darkMode;
|
|
405
|
-
if (strategy === "class") {
|
|
406
|
-
root.classList.toggle("dark", dark);
|
|
407
|
-
root.classList.toggle("light", !dark);
|
|
408
|
-
} else if (strategy === "attribute") {
|
|
409
|
-
root.setAttribute("data-theme", dark ? "dark" : "light");
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
var mode = "system";
|
|
413
|
-
var isDark = resolveIsDark(mode);
|
|
414
|
-
applyToDom(isDark);
|
|
415
|
-
var subscription = import_react_native.Appearance.addChangeListener(({ colorScheme }) => {
|
|
416
|
-
if (mode !== "system") return;
|
|
417
|
-
isDark = colorScheme === "dark";
|
|
418
|
-
applyToDom(isDark);
|
|
419
|
-
notify();
|
|
420
|
-
});
|
|
421
|
-
function notify() {
|
|
422
|
-
for (const listener of listeners) listener();
|
|
423
|
-
}
|
|
424
|
-
function getGlobalDarkMode() {
|
|
425
|
-
return isDark;
|
|
426
|
-
}
|
|
427
|
-
function subscribeGlobalDarkMode(listener) {
|
|
428
|
-
listeners.add(listener);
|
|
429
|
-
return () => listeners.delete(listener);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// src/jsxRuntimeCore.ts
|
|
32
|
+
var import_darkModeStore = require("./darkModeStore");
|
|
33
|
+
var import_theme = require("./theme");
|
|
433
34
|
function makeElement(isStaticChildren, type, props, key) {
|
|
434
35
|
return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
|
|
435
36
|
}
|
|
@@ -444,10 +45,22 @@ function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed) {
|
|
|
444
45
|
return [resolved, userStyle];
|
|
445
46
|
}
|
|
446
47
|
var DARK_MODIFIER_RE = /(^|\s)dark:/;
|
|
48
|
+
var BREAKPOINT_MODIFIER_RE = /(^|\s)(sm|md|lg|xl|2xl):/;
|
|
49
|
+
var BREAKPOINT_MODIFIER_MATCH_RE = /(?:^|\s)(sm|md|lg|xl|2xl):/g;
|
|
447
50
|
function darkModeKeySuffix(classStrRaw) {
|
|
448
|
-
return DARK_MODIFIER_RE.test(classStrRaw) ? `:kb-dark-${getGlobalDarkMode()}` : "";
|
|
51
|
+
return DARK_MODIFIER_RE.test(classStrRaw) ? `:kb-dark-${(0, import_darkModeStore.getGlobalDarkMode)()}` : "";
|
|
449
52
|
}
|
|
450
|
-
function
|
|
53
|
+
function breakpointKeySuffix(classStrRaw, width) {
|
|
54
|
+
const matches = classStrRaw.match(BREAKPOINT_MODIFIER_MATCH_RE);
|
|
55
|
+
if (!matches) {
|
|
56
|
+
return "";
|
|
57
|
+
}
|
|
58
|
+
const screens = (0, import_theme.getTheme)().screens;
|
|
59
|
+
const present = Array.from(new Set(matches.map((m) => m.trim().slice(0, -1))));
|
|
60
|
+
const state = present.map((name) => screens[name] !== void 0 && width >= screens[name] ? "1" : "0").join("");
|
|
61
|
+
return `:kb-bp-${state}`;
|
|
62
|
+
}
|
|
63
|
+
function ReactiveElement({
|
|
451
64
|
hostType,
|
|
452
65
|
hostRest,
|
|
453
66
|
classStrRaw,
|
|
@@ -456,9 +69,10 @@ function DarkAwareElement({
|
|
|
456
69
|
elementKey,
|
|
457
70
|
isStaticChildren
|
|
458
71
|
}) {
|
|
459
|
-
(0, import_react.useSyncExternalStore)(subscribeGlobalDarkMode, getGlobalDarkMode);
|
|
460
|
-
const
|
|
461
|
-
const
|
|
72
|
+
(0, import_react.useSyncExternalStore)(import_darkModeStore.subscribeGlobalDarkMode, import_darkModeStore.getGlobalDarkMode);
|
|
73
|
+
const { width } = (0, import_react_native.useWindowDimensions)();
|
|
74
|
+
const finalStyle = hostType === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
|
|
75
|
+
const suffix = darkModeKeySuffix(classStrRaw) + breakpointKeySuffix(classStrRaw, width);
|
|
462
76
|
const finalKey = suffix ? `${elementKey ?? ""}${suffix}` : elementKey;
|
|
463
77
|
return makeElement(isStaticChildren, hostType, { ...hostRest, style: finalStyle }, finalKey);
|
|
464
78
|
}
|
|
@@ -470,14 +84,14 @@ function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
|
|
|
470
84
|
if (typeof classStrRaw !== "string") {
|
|
471
85
|
return makeElement(isStaticChildren, type, rawProps, key);
|
|
472
86
|
}
|
|
473
|
-
if (DARK_MODIFIER_RE.test(classStrRaw)) {
|
|
87
|
+
if (DARK_MODIFIER_RE.test(classStrRaw) || BREAKPOINT_MODIFIER_RE.test(classStrRaw)) {
|
|
474
88
|
return (0, import_jsx_runtime.jsx)(
|
|
475
|
-
|
|
89
|
+
ReactiveElement,
|
|
476
90
|
{ hostType: type, hostRest: rest, classStrRaw, userStyle, resolveStyle: resolveStyle2, elementKey: key, isStaticChildren },
|
|
477
91
|
key
|
|
478
92
|
);
|
|
479
93
|
}
|
|
480
|
-
const finalStyle = type ===
|
|
94
|
+
const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
|
|
481
95
|
return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
|
|
482
96
|
}
|
|
483
97
|
function createJsxFunctions(resolveStyle2) {
|
|
@@ -501,7 +115,9 @@ function createJsxDEV(jsx2, jsxs2) {
|
|
|
501
115
|
}
|
|
502
116
|
|
|
503
117
|
// src/nativeBridge.ts
|
|
504
|
-
var
|
|
118
|
+
var import_react_native2 = require("react-native");
|
|
119
|
+
var import_theme2 = require("./theme");
|
|
120
|
+
var import_darkModeStore2 = require("./darkModeStore");
|
|
505
121
|
|
|
506
122
|
// src/jsEngine/parser.ts
|
|
507
123
|
var VALUE_PREFIXES = [
|
|
@@ -1718,13 +1334,13 @@ function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
|
|
|
1718
1334
|
|
|
1719
1335
|
// src/nativeBridge.ts
|
|
1720
1336
|
function resolveStyle(classString, pressed = false) {
|
|
1721
|
-
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
1722
|
-
const width =
|
|
1723
|
-
const KbachModule =
|
|
1337
|
+
const colorScheme = (0, import_darkModeStore2.getGlobalDarkMode)() ? "dark" : "light";
|
|
1338
|
+
const width = import_react_native2.Dimensions.get("window").width;
|
|
1339
|
+
const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
|
|
1724
1340
|
if (!KbachModule) {
|
|
1725
|
-
return resolveStyleJs(classString, getTheme(), colorScheme, pressed, width);
|
|
1341
|
+
return resolveStyleJs(classString, (0, import_theme2.getTheme)(), colorScheme, pressed, width);
|
|
1726
1342
|
}
|
|
1727
|
-
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
1343
|
+
const json = KbachModule.resolveStyle(classString, (0, import_theme2.getThemeJson)(), colorScheme, pressed, width);
|
|
1728
1344
|
return JSON.parse(json);
|
|
1729
1345
|
}
|
|
1730
1346
|
|