@kbach/react-native 1.0.0-beta.14 → 1.0.0-beta.15

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