@kbach/react-native 1.0.0-beta.7 → 1.0.0-beta.9

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.
@@ -0,0 +1,1211 @@
1
+ import {
2
+ getGlobalDarkMode
3
+ } from "./chunk-Z664AKW7.mjs";
4
+ import {
5
+ getTheme,
6
+ getThemeJson
7
+ } from "./chunk-HK6PDJJK.mjs";
8
+
9
+ // src/nativeBridge.ts
10
+ import { Dimensions, TurboModuleRegistry } from "react-native";
11
+
12
+ // src/jsEngine/parser.ts
13
+ var VALUE_PREFIXES = [
14
+ "bg-opacity-",
15
+ "text-opacity-",
16
+ "bg-blend-",
17
+ "text-shadow-",
18
+ "bg-",
19
+ "text-",
20
+ "border-x-",
21
+ "border-y-",
22
+ "border-t-",
23
+ "border-r-",
24
+ "border-b-",
25
+ "border-l-",
26
+ "border-",
27
+ "caret-",
28
+ "accent-",
29
+ "fill-",
30
+ "stroke-width-",
31
+ "stroke-",
32
+ "resize-",
33
+ "touch-",
34
+ "will-change-",
35
+ "scroll-mx-",
36
+ "scroll-my-",
37
+ "scroll-mt-",
38
+ "scroll-mr-",
39
+ "scroll-mb-",
40
+ "scroll-ml-",
41
+ "scroll-m-",
42
+ "scroll-px-",
43
+ "scroll-py-",
44
+ "scroll-pt-",
45
+ "scroll-pr-",
46
+ "scroll-pb-",
47
+ "scroll-pl-",
48
+ "scroll-p-",
49
+ "px-",
50
+ "py-",
51
+ "pt-",
52
+ "pr-",
53
+ "pb-",
54
+ "pl-",
55
+ "p-",
56
+ "mx-",
57
+ "my-",
58
+ "mt-",
59
+ "mr-",
60
+ "mb-",
61
+ "ml-",
62
+ "m-",
63
+ "gap-x-",
64
+ "gap-y-",
65
+ "gap-",
66
+ "min-w-",
67
+ "max-w-",
68
+ "w-",
69
+ "min-h-",
70
+ "max-h-",
71
+ "h-",
72
+ "size-",
73
+ "basis-",
74
+ "rounded-tl-",
75
+ "rounded-tr-",
76
+ "rounded-br-",
77
+ "rounded-bl-",
78
+ "rounded-t-",
79
+ "rounded-r-",
80
+ "rounded-b-",
81
+ "rounded-l-",
82
+ "rounded-",
83
+ "ring-offset-",
84
+ "ring-",
85
+ "outline-offset-",
86
+ "outline-",
87
+ "shadow-",
88
+ "opacity-",
89
+ "duration-",
90
+ "delay-",
91
+ "ease-",
92
+ "cursor-",
93
+ "mix-blend-",
94
+ "animate-",
95
+ "leading-",
96
+ "tracking-",
97
+ "font-",
98
+ "z-",
99
+ "inset-",
100
+ "top-",
101
+ "right-",
102
+ "bottom-",
103
+ "left-",
104
+ "divide-color-",
105
+ "space-x-",
106
+ "space-y-",
107
+ "flex-",
108
+ "grow-",
109
+ "shrink-",
110
+ "order-",
111
+ "grid-cols-",
112
+ "grid-rows-",
113
+ "grid-flow-",
114
+ "auto-cols-",
115
+ "auto-rows-",
116
+ "col-span-",
117
+ "col-start-",
118
+ "col-end-",
119
+ "col-",
120
+ "row-span-",
121
+ "row-start-",
122
+ "row-end-",
123
+ "row-",
124
+ "place-items-",
125
+ "place-content-",
126
+ "place-self-",
127
+ "justify-items-",
128
+ "justify-self-",
129
+ "scale-x-",
130
+ "scale-y-",
131
+ "scale-",
132
+ "rotate-",
133
+ "translate-x-",
134
+ "translate-y-",
135
+ "skew-x-",
136
+ "skew-y-",
137
+ "origin-",
138
+ "blur-",
139
+ "brightness-",
140
+ "contrast-",
141
+ "grayscale-",
142
+ "hue-rotate-",
143
+ "invert-",
144
+ "saturate-",
145
+ "sepia-",
146
+ "drop-shadow-",
147
+ "filter-",
148
+ "backdrop-blur-",
149
+ "backdrop-brightness-",
150
+ "backdrop-contrast-",
151
+ "backdrop-grayscale-",
152
+ "backdrop-hue-rotate-",
153
+ "backdrop-invert-",
154
+ "backdrop-opacity-",
155
+ "backdrop-saturate-",
156
+ "backdrop-sepia-",
157
+ "backdrop-filter-",
158
+ "decoration-",
159
+ "underline-offset-",
160
+ "indent-",
161
+ "from-",
162
+ "via-",
163
+ "to-"
164
+ ];
165
+ var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
166
+ function isSafeArbitraryValue(value) {
167
+ return !value.includes("{") && !value.includes("}") && !value.includes(";");
168
+ }
169
+ function splitRespectingBrackets(token) {
170
+ const parts = [];
171
+ let depth = 0;
172
+ let start = 0;
173
+ for (let i = 0; i < token.length; i++) {
174
+ const ch = token[i];
175
+ if (ch === "[") depth += 1;
176
+ else if (ch === "]") depth -= 1;
177
+ else if (ch === ":" && depth <= 0) {
178
+ parts.push(token.slice(start, i));
179
+ start = i + 1;
180
+ }
181
+ }
182
+ parts.push(token.slice(start));
183
+ return parts;
184
+ }
185
+ function parseClass(token) {
186
+ const parts = splitRespectingBrackets(token);
187
+ let base = parts.pop() ?? token;
188
+ const modifiers = parts;
189
+ const important = base.startsWith("!");
190
+ if (important) {
191
+ base = base.slice(1);
192
+ }
193
+ const negative = base.startsWith("-");
194
+ if (negative) {
195
+ base = base.slice(1);
196
+ }
197
+ if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
198
+ const raw = base.slice(1, -1);
199
+ const colonIdx = raw.indexOf(":");
200
+ if (colonIdx !== -1) {
201
+ const property = raw.slice(0, colonIdx);
202
+ const rawValue = raw.slice(colonIdx + 1);
203
+ if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
204
+ const value = rawValue.replace(/_/g, " ");
205
+ return {
206
+ modifiers,
207
+ utility: ARBITRARY_PROPERTY_SENTINEL,
208
+ value: `${property}:${value}`,
209
+ isArbitrary: true,
210
+ important,
211
+ negative,
212
+ original: token
213
+ };
214
+ }
215
+ }
216
+ }
217
+ for (const prefix of VALUE_PREFIXES) {
218
+ if (!base.startsWith(prefix)) continue;
219
+ const value = base.slice(prefix.length);
220
+ if (value === "") continue;
221
+ if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
222
+ const raw = value.slice(1, -1);
223
+ if (!isSafeArbitraryValue(raw)) {
224
+ continue;
225
+ }
226
+ const spaced = raw.replace(/_/g, " ");
227
+ return {
228
+ modifiers,
229
+ utility: prefix.slice(0, -1),
230
+ value: spaced,
231
+ isArbitrary: true,
232
+ important,
233
+ negative,
234
+ original: token
235
+ };
236
+ }
237
+ return {
238
+ modifiers,
239
+ utility: prefix.slice(0, -1),
240
+ value,
241
+ isArbitrary: false,
242
+ important,
243
+ negative,
244
+ original: token
245
+ };
246
+ }
247
+ return {
248
+ modifiers,
249
+ utility: base,
250
+ value: null,
251
+ isArbitrary: false,
252
+ important,
253
+ negative,
254
+ original: token
255
+ };
256
+ }
257
+
258
+ // src/jsEngine/shared.ts
259
+ function decl(property, value) {
260
+ return { property, value };
261
+ }
262
+ function spacingPx(theme, value) {
263
+ const fromTable = theme.spacing[value];
264
+ if (fromTable !== void 0) return fromTable;
265
+ const n = Number(value);
266
+ return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
267
+ }
268
+ function resolveLength(theme, parsed) {
269
+ if (parsed.negative) return null;
270
+ const value = parsed.value;
271
+ if (value === null) return null;
272
+ if (parsed.isArbitrary) return value;
273
+ if (value === "full") return "100%";
274
+ if (value === "auto") return "auto";
275
+ const px = spacingPx(theme, value);
276
+ return px === void 0 ? null : `${px}px`;
277
+ }
278
+ function resolveNegatableLength(theme, parsed) {
279
+ if (!parsed.negative) return resolveLength(theme, parsed);
280
+ if (parsed.isArbitrary) return null;
281
+ const value = parsed.value;
282
+ if (value === null) return null;
283
+ const px = spacingPx(theme, value);
284
+ if (px === void 0) return null;
285
+ if (px === 0) return "0px";
286
+ return `-${px}px`;
287
+ }
288
+
289
+ // src/jsEngine/resolvers/layout.ts
290
+ function negateRaw(value, negative) {
291
+ return negative ? `-${value}` : value;
292
+ }
293
+ function resolve(parsed, theme) {
294
+ switch (parsed.utility) {
295
+ case "flex":
296
+ return parsed.value === null ? [decl("display", "flex")] : null;
297
+ case "grid":
298
+ return [decl("display", "grid")];
299
+ case "block":
300
+ return [decl("display", "block")];
301
+ case "inline-block":
302
+ return [decl("display", "inline-block")];
303
+ case "inline":
304
+ return [decl("display", "inline")];
305
+ case "inline-flex":
306
+ return [decl("display", "inline-flex")];
307
+ case "inline-grid":
308
+ return [decl("display", "inline-grid")];
309
+ case "contents":
310
+ return [decl("display", "contents")];
311
+ case "flow-root":
312
+ return [decl("display", "flow-root")];
313
+ case "hidden":
314
+ return [decl("display", "none")];
315
+ case "@container":
316
+ return [decl("container-type", "inline-size")];
317
+ case "items-center":
318
+ return [decl("align-items", "center")];
319
+ case "items-start":
320
+ return [decl("align-items", "flex-start")];
321
+ case "items-end":
322
+ return [decl("align-items", "flex-end")];
323
+ case "items-baseline":
324
+ return [decl("align-items", "baseline")];
325
+ case "items-stretch":
326
+ return [decl("align-items", "stretch")];
327
+ case "justify-center":
328
+ return [decl("justify-content", "center")];
329
+ case "justify-start":
330
+ return [decl("justify-content", "flex-start")];
331
+ case "justify-end":
332
+ return [decl("justify-content", "flex-end")];
333
+ case "justify-between":
334
+ return [decl("justify-content", "space-between")];
335
+ case "justify-around":
336
+ return [decl("justify-content", "space-around")];
337
+ case "justify-evenly":
338
+ return [decl("justify-content", "space-evenly")];
339
+ case "content-start":
340
+ return [decl("align-content", "flex-start")];
341
+ case "content-end":
342
+ return [decl("align-content", "flex-end")];
343
+ case "content-center":
344
+ return [decl("align-content", "center")];
345
+ case "content-between":
346
+ return [decl("align-content", "space-between")];
347
+ case "content-around":
348
+ return [decl("align-content", "space-around")];
349
+ case "content-evenly":
350
+ return [decl("align-content", "space-evenly")];
351
+ case "content-stretch":
352
+ return [decl("align-content", "stretch")];
353
+ case "self-auto":
354
+ return [decl("align-self", "auto")];
355
+ case "self-center":
356
+ return [decl("align-self", "center")];
357
+ case "self-start":
358
+ return [decl("align-self", "flex-start")];
359
+ case "self-end":
360
+ return [decl("align-self", "flex-end")];
361
+ case "self-stretch":
362
+ return [decl("align-self", "stretch")];
363
+ case "self-baseline":
364
+ return [decl("align-self", "baseline")];
365
+ case "overflow-hidden":
366
+ return [decl("overflow", "hidden")];
367
+ case "overflow-auto":
368
+ return [decl("overflow", "auto")];
369
+ case "overflow-scroll":
370
+ return [decl("overflow", "scroll")];
371
+ case "overflow-visible":
372
+ return [decl("overflow", "visible")];
373
+ case "static":
374
+ return [decl("position", "static")];
375
+ case "relative":
376
+ return [decl("position", "relative")];
377
+ case "absolute":
378
+ return [decl("position", "absolute")];
379
+ case "fixed":
380
+ return [decl("position", "fixed")];
381
+ case "sticky":
382
+ return [decl("position", "sticky")];
383
+ case "z":
384
+ return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
385
+ case "order":
386
+ return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
387
+ case "grow":
388
+ return [decl("flex-grow", parsed.value ?? "1")];
389
+ case "shrink":
390
+ return [decl("flex-shrink", parsed.value ?? "1")];
391
+ // top/right/bottom/left/inset support real Tailwind's negative-value
392
+ // convention ("-top-4") — see resolveNegatableLength's own doc comment.
393
+ case "top": {
394
+ const v = resolveNegatableLength(theme, parsed);
395
+ return v === null ? null : [decl("top", v)];
396
+ }
397
+ case "right": {
398
+ const v = resolveNegatableLength(theme, parsed);
399
+ return v === null ? null : [decl("right", v)];
400
+ }
401
+ case "bottom": {
402
+ const v = resolveNegatableLength(theme, parsed);
403
+ return v === null ? null : [decl("bottom", v)];
404
+ }
405
+ case "left": {
406
+ const v = resolveNegatableLength(theme, parsed);
407
+ return v === null ? null : [decl("left", v)];
408
+ }
409
+ case "inset": {
410
+ const v = resolveNegatableLength(theme, parsed);
411
+ return v === null ? null : [decl("inset", v)];
412
+ }
413
+ case "aspect-square":
414
+ return [decl("aspect-ratio", "1 / 1")];
415
+ case "aspect-video":
416
+ return [decl("aspect-ratio", "16 / 9")];
417
+ default:
418
+ return null;
419
+ }
420
+ }
421
+ function resolveFlex(parsed, web) {
422
+ if (parsed.utility !== "flex") return null;
423
+ const value = parsed.value;
424
+ if (value === null) return null;
425
+ if (parsed.isArbitrary) return [decl("flex", value)];
426
+ switch (value) {
427
+ case "row":
428
+ return [decl("flex-direction", "row")];
429
+ case "col":
430
+ return [decl("flex-direction", "column")];
431
+ case "row-reverse":
432
+ return [decl("flex-direction", "row-reverse")];
433
+ case "col-reverse":
434
+ return [decl("flex-direction", "column-reverse")];
435
+ case "wrap":
436
+ return [decl("flex-wrap", "wrap")];
437
+ case "wrap-reverse":
438
+ return [decl("flex-wrap", "wrap-reverse")];
439
+ case "nowrap":
440
+ return [decl("flex-wrap", "nowrap")];
441
+ case "1":
442
+ return [decl("flex", "1")];
443
+ case "auto":
444
+ return [decl("flex", web ? "auto" : "1")];
445
+ case "initial":
446
+ return [decl("flex", web ? "initial" : "1")];
447
+ case "none":
448
+ return [decl("flex", web ? "none" : "0")];
449
+ case "grow":
450
+ return [decl("flex-grow", "1")];
451
+ case "grow-0":
452
+ return [decl("flex-grow", "0")];
453
+ case "shrink":
454
+ return [decl("flex-shrink", "1")];
455
+ case "shrink-0":
456
+ return [decl("flex-shrink", "0")];
457
+ default:
458
+ return null;
459
+ }
460
+ }
461
+
462
+ // src/jsEngine/resolvers/spacing.ts
463
+ function namedSize(key) {
464
+ switch (key) {
465
+ case "sm":
466
+ return "24rem";
467
+ case "md":
468
+ return "28rem";
469
+ case "lg":
470
+ return "32rem";
471
+ case "xl":
472
+ return "36rem";
473
+ case "2xl":
474
+ return "42rem";
475
+ case "3xl":
476
+ return "48rem";
477
+ case "4xl":
478
+ return "56rem";
479
+ case "5xl":
480
+ return "64rem";
481
+ case "6xl":
482
+ return "72rem";
483
+ case "7xl":
484
+ return "80rem";
485
+ case "8xl":
486
+ return "88rem";
487
+ case "9xl":
488
+ return "96rem";
489
+ default:
490
+ return null;
491
+ }
492
+ }
493
+ function fractionPercent(value) {
494
+ const slashIdx = value.indexOf("/");
495
+ if (slashIdx === -1) return null;
496
+ const numStr = value.slice(0, slashIdx);
497
+ const denStr = value.slice(slashIdx + 1);
498
+ const num = Number(numStr);
499
+ const den = Number(denStr);
500
+ if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
501
+ if (den === 0) return null;
502
+ const pct = num / den * 100;
503
+ const formatted = pct.toFixed(6);
504
+ const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
505
+ return `${trimmed}%`;
506
+ }
507
+ function cssSizeKeyword(key) {
508
+ switch (key) {
509
+ case "min":
510
+ return "min-content";
511
+ case "max":
512
+ return "max-content";
513
+ case "fit":
514
+ return "fit-content";
515
+ default:
516
+ return null;
517
+ }
518
+ }
519
+ function resolveSize(theme, parsed) {
520
+ if (!parsed.isArbitrary && parsed.value !== null) {
521
+ const named = namedSize(parsed.value);
522
+ if (named !== null) return named;
523
+ const kw = cssSizeKeyword(parsed.value);
524
+ if (kw !== null) return kw;
525
+ const fraction = fractionPercent(parsed.value);
526
+ if (fraction !== null) return fraction;
527
+ }
528
+ return resolveLength(theme, parsed);
529
+ }
530
+ function resolve2(parsed, theme) {
531
+ const length = () => resolveLength(theme, parsed);
532
+ const size = () => resolveSize(theme, parsed);
533
+ const negatableLength = () => resolveNegatableLength(theme, parsed);
534
+ switch (parsed.utility) {
535
+ case "p": {
536
+ const v = length();
537
+ return v === null ? null : [decl("padding", v)];
538
+ }
539
+ case "px": {
540
+ const v = length();
541
+ return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
542
+ }
543
+ case "py": {
544
+ const v = length();
545
+ return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
546
+ }
547
+ case "pt": {
548
+ const v = length();
549
+ return v === null ? null : [decl("padding-top", v)];
550
+ }
551
+ case "pr": {
552
+ const v = length();
553
+ return v === null ? null : [decl("padding-right", v)];
554
+ }
555
+ case "pb": {
556
+ const v = length();
557
+ return v === null ? null : [decl("padding-bottom", v)];
558
+ }
559
+ case "pl": {
560
+ const v = length();
561
+ return v === null ? null : [decl("padding-left", v)];
562
+ }
563
+ case "m": {
564
+ const v = negatableLength();
565
+ return v === null ? null : [decl("margin", v)];
566
+ }
567
+ case "mx": {
568
+ const v = negatableLength();
569
+ return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
570
+ }
571
+ case "my": {
572
+ const v = negatableLength();
573
+ return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
574
+ }
575
+ case "mt": {
576
+ const v = negatableLength();
577
+ return v === null ? null : [decl("margin-top", v)];
578
+ }
579
+ case "mr": {
580
+ const v = negatableLength();
581
+ return v === null ? null : [decl("margin-right", v)];
582
+ }
583
+ case "mb": {
584
+ const v = negatableLength();
585
+ return v === null ? null : [decl("margin-bottom", v)];
586
+ }
587
+ case "ml": {
588
+ const v = negatableLength();
589
+ return v === null ? null : [decl("margin-left", v)];
590
+ }
591
+ case "gap": {
592
+ const v = length();
593
+ return v === null ? null : [decl("gap", v)];
594
+ }
595
+ case "gap-x": {
596
+ const v = length();
597
+ return v === null ? null : [decl("column-gap", v)];
598
+ }
599
+ case "gap-y": {
600
+ const v = length();
601
+ return v === null ? null : [decl("row-gap", v)];
602
+ }
603
+ case "w": {
604
+ const v = size();
605
+ return v === null ? null : [decl("width", v)];
606
+ }
607
+ case "h": {
608
+ const v = size();
609
+ return v === null ? null : [decl("height", v)];
610
+ }
611
+ case "min-w": {
612
+ const v = size();
613
+ return v === null ? null : [decl("min-width", v)];
614
+ }
615
+ case "max-w": {
616
+ const v = size();
617
+ return v === null ? null : [decl("max-width", v)];
618
+ }
619
+ case "min-h": {
620
+ const v = size();
621
+ return v === null ? null : [decl("min-height", v)];
622
+ }
623
+ case "max-h": {
624
+ const v = size();
625
+ return v === null ? null : [decl("max-height", v)];
626
+ }
627
+ case "size": {
628
+ const v = size();
629
+ return v === null ? null : [decl("width", v), decl("height", v)];
630
+ }
631
+ case "basis": {
632
+ const v = size();
633
+ return v === null ? null : [decl("flex-basis", v)];
634
+ }
635
+ default:
636
+ return null;
637
+ }
638
+ }
639
+
640
+ // src/jsEngine/resolvers/color.ts
641
+ function lookupHex(theme, key) {
642
+ const entry = theme.colors[key];
643
+ return typeof entry === "string" ? entry : null;
644
+ }
645
+
646
+ // src/jsEngine/resolvers/border.ts
647
+ function radiusSize(key) {
648
+ switch (key) {
649
+ case "none":
650
+ return "0px";
651
+ case "sm":
652
+ return "0.125rem";
653
+ case "md":
654
+ return "0.375rem";
655
+ case "lg":
656
+ return "0.5rem";
657
+ case "xl":
658
+ return "0.75rem";
659
+ case "2xl":
660
+ return "1rem";
661
+ case "3xl":
662
+ return "1.5rem";
663
+ case "full":
664
+ return "9999px";
665
+ default:
666
+ return null;
667
+ }
668
+ }
669
+ function borderSideProperty(side) {
670
+ switch (side) {
671
+ case "t":
672
+ return "border-top";
673
+ case "r":
674
+ return "border-right";
675
+ case "b":
676
+ return "border-bottom";
677
+ case "l":
678
+ return "border-left";
679
+ default:
680
+ return null;
681
+ }
682
+ }
683
+ function borderValue(theme, parsed) {
684
+ const value = parsed.value;
685
+ if (value === null) return null;
686
+ if (!parsed.isArbitrary) {
687
+ const side = borderSideProperty(value);
688
+ if (side !== null) {
689
+ return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
690
+ }
691
+ if (value === "collapse") return [decl("border-collapse", "collapse")];
692
+ if (value === "separate") return [decl("border-collapse", "separate")];
693
+ }
694
+ if (parsed.isArbitrary) {
695
+ return [decl("border-width", value)];
696
+ }
697
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
698
+ const v = resolveLength(theme, parsed);
699
+ return v === null ? null : [decl("border-width", v)];
700
+ }
701
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
702
+ return [decl("border-style", value)];
703
+ }
704
+ const hex = lookupHex(theme, value);
705
+ return hex === null ? null : [decl("border-color", hex)];
706
+ }
707
+ function borderSideValue(theme, parsed, sideProperty) {
708
+ const value = parsed.value;
709
+ if (value === null) return null;
710
+ if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
711
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
712
+ const v = resolveLength(theme, parsed);
713
+ return v === null ? null : [decl(`${sideProperty}-width`, v)];
714
+ }
715
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
716
+ return [decl(`${sideProperty}-style`, value)];
717
+ }
718
+ const hex = lookupHex(theme, value);
719
+ return hex === null ? null : [decl(`${sideProperty}-color`, hex)];
720
+ }
721
+ function borderAxisValue(theme, parsed, sideA, sideB) {
722
+ const value = parsed.value;
723
+ if (value === null) return null;
724
+ if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
725
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
726
+ const v = resolveLength(theme, parsed);
727
+ return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
728
+ }
729
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
730
+ return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
731
+ }
732
+ const hex = lookupHex(theme, value);
733
+ return hex === null ? null : [decl(`${sideA}-color`, hex), decl(`${sideB}-color`, hex)];
734
+ }
735
+ function radiusProperties(side) {
736
+ switch (side) {
737
+ case "t":
738
+ return ["border-top-left-radius", "border-top-right-radius"];
739
+ case "r":
740
+ return ["border-top-right-radius", "border-bottom-right-radius"];
741
+ case "b":
742
+ return ["border-bottom-right-radius", "border-bottom-left-radius"];
743
+ case "l":
744
+ return ["border-top-left-radius", "border-bottom-left-radius"];
745
+ case "tl":
746
+ return ["border-top-left-radius"];
747
+ case "tr":
748
+ return ["border-top-right-radius"];
749
+ case "br":
750
+ return ["border-bottom-right-radius"];
751
+ case "bl":
752
+ return ["border-bottom-left-radius"];
753
+ default:
754
+ return null;
755
+ }
756
+ }
757
+ function resolveRadiusValue(theme, parsed) {
758
+ if (!parsed.isArbitrary && parsed.value !== null) {
759
+ const size = radiusSize(parsed.value);
760
+ if (size !== null) return size;
761
+ }
762
+ return resolveLength(theme, parsed);
763
+ }
764
+ function resolveRadiusSide(theme, parsed, side) {
765
+ const properties = radiusProperties(side);
766
+ if (properties === null) return null;
767
+ const value = resolveRadiusValue(theme, parsed);
768
+ if (value === null) return null;
769
+ return properties.map((p) => decl(p, value));
770
+ }
771
+ var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
772
+ function outlineWidthValue(key) {
773
+ switch (key) {
774
+ case "0":
775
+ return "0px";
776
+ case "1":
777
+ return "1px";
778
+ case "2":
779
+ return "2px";
780
+ case "4":
781
+ return "4px";
782
+ case "8":
783
+ return "8px";
784
+ default:
785
+ return null;
786
+ }
787
+ }
788
+ function outlineValue(theme, parsed) {
789
+ const value = parsed.value;
790
+ if (value === null) return null;
791
+ if (parsed.isArbitrary) return [decl("outline-width", value)];
792
+ const w = outlineWidthValue(value);
793
+ if (w !== null) return [decl("outline-width", w)];
794
+ if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
795
+ const hex = lookupHex(theme, value);
796
+ return hex === null ? null : [decl("outline-color", hex)];
797
+ }
798
+ function outlineOffsetValue(parsed) {
799
+ const value = parsed.value;
800
+ if (value === null) return null;
801
+ if (parsed.isArbitrary) return [decl("outline-offset", value)];
802
+ const w = outlineWidthValue(value);
803
+ return w === null ? null : [decl("outline-offset", w)];
804
+ }
805
+ var RING_BOX_SHADOW = "var(--kb-ring-inset,) 0 0 0 var(--kb-ring-offset-width, 0px) var(--kb-ring-offset-color, #fff), var(--kb-ring-inset,) 0 0 0 calc(var(--kb-ring-width, 0px) + var(--kb-ring-offset-width, 0px)) var(--kb-ring-color, rgba(59,130,246,0.5))";
806
+ function ringWidth(key) {
807
+ switch (key) {
808
+ case "0":
809
+ return "0px";
810
+ case "1":
811
+ return "1px";
812
+ case "2":
813
+ return "2px";
814
+ case "4":
815
+ return "4px";
816
+ case "8":
817
+ return "8px";
818
+ default:
819
+ return null;
820
+ }
821
+ }
822
+ function ringValue(theme, parsed) {
823
+ const value = parsed.value;
824
+ if (value === null) return null;
825
+ if (value === "inset") {
826
+ return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
827
+ }
828
+ if (!parsed.isArbitrary) {
829
+ const w = ringWidth(value);
830
+ if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
831
+ }
832
+ const color = parsed.isArbitrary ? value : lookupHex(theme, value);
833
+ if (color === null) return null;
834
+ return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
835
+ }
836
+ function ringOffsetValue(theme, parsed) {
837
+ const value = parsed.value;
838
+ if (value === null) return null;
839
+ if (!parsed.isArbitrary) {
840
+ const w = ringWidth(value);
841
+ if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
842
+ }
843
+ const color = parsed.isArbitrary ? value : lookupHex(theme, value);
844
+ if (color === null) return null;
845
+ return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
846
+ }
847
+ var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
848
+ function resolve3(parsed, theme) {
849
+ switch (parsed.utility) {
850
+ case "border":
851
+ if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
852
+ return borderValue(theme, parsed);
853
+ case "border-t":
854
+ return borderSideValue(theme, parsed, "border-top");
855
+ case "border-r":
856
+ return borderSideValue(theme, parsed, "border-right");
857
+ case "border-b":
858
+ return borderSideValue(theme, parsed, "border-bottom");
859
+ case "border-l":
860
+ return borderSideValue(theme, parsed, "border-left");
861
+ case "border-x":
862
+ return borderAxisValue(theme, parsed, "border-left", "border-right");
863
+ case "border-y":
864
+ return borderAxisValue(theme, parsed, "border-top", "border-bottom");
865
+ case "rounded": {
866
+ if (parsed.value === null) return [decl("border-radius", "0.25rem")];
867
+ const value = parsed.value;
868
+ if (!parsed.isArbitrary) {
869
+ const size = radiusSize(value);
870
+ if (size !== null) return [decl("border-radius", size)];
871
+ }
872
+ const v = resolveLength(theme, parsed);
873
+ return v === null ? null : [decl("border-radius", v)];
874
+ }
875
+ case "ring":
876
+ if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
877
+ return ringValue(theme, parsed);
878
+ case "ring-offset":
879
+ return ringOffsetValue(theme, parsed);
880
+ case "outline":
881
+ if (parsed.value === null) return [decl("outline-style", "solid")];
882
+ if (parsed.value === "none") return [decl("outline", "none")];
883
+ return outlineValue(theme, parsed);
884
+ case "outline-offset":
885
+ return outlineOffsetValue(parsed);
886
+ default:
887
+ if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
888
+ return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
889
+ }
890
+ return null;
891
+ }
892
+ }
893
+
894
+ // src/jsEngine/resolvers/typography.ts
895
+ function textSize(key) {
896
+ switch (key) {
897
+ case "xs":
898
+ return "0.75rem";
899
+ case "sm":
900
+ return "0.875rem";
901
+ case "base":
902
+ return "1rem";
903
+ case "lg":
904
+ return "1.125rem";
905
+ case "xl":
906
+ return "1.25rem";
907
+ case "2xl":
908
+ return "1.5rem";
909
+ case "3xl":
910
+ return "1.875rem";
911
+ case "4xl":
912
+ return "2.25rem";
913
+ default:
914
+ return null;
915
+ }
916
+ }
917
+ function lineHeightSize(key) {
918
+ switch (key) {
919
+ case "3":
920
+ return "0.75rem";
921
+ case "4":
922
+ return "1rem";
923
+ case "5":
924
+ return "1.25rem";
925
+ case "6":
926
+ return "1.5rem";
927
+ case "7":
928
+ return "1.75rem";
929
+ case "8":
930
+ return "2rem";
931
+ case "9":
932
+ return "2.25rem";
933
+ case "10":
934
+ return "2.5rem";
935
+ default:
936
+ return null;
937
+ }
938
+ }
939
+ function textAlign(key) {
940
+ switch (key) {
941
+ case "left":
942
+ return "left";
943
+ case "center":
944
+ return "center";
945
+ case "right":
946
+ return "right";
947
+ case "justify":
948
+ return "justify";
949
+ default:
950
+ return null;
951
+ }
952
+ }
953
+ function fontWeight(key) {
954
+ switch (key) {
955
+ case "thin":
956
+ return "100";
957
+ case "normal":
958
+ return "400";
959
+ case "medium":
960
+ return "500";
961
+ case "semibold":
962
+ return "600";
963
+ case "bold":
964
+ return "700";
965
+ case "extrabold":
966
+ return "800";
967
+ default:
968
+ return null;
969
+ }
970
+ }
971
+
972
+ // src/jsEngine/resolvers/effects.ts
973
+ function nativeShadowValue(key) {
974
+ switch (key) {
975
+ case "sm":
976
+ return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
977
+ case "DEFAULT":
978
+ return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
979
+ case "md":
980
+ return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
981
+ case "lg":
982
+ return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
983
+ case "xl":
984
+ return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
985
+ case "2xl":
986
+ return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
987
+ case "none":
988
+ return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
989
+ default:
990
+ return null;
991
+ }
992
+ }
993
+ function nativeShadowDeclarations(parsed) {
994
+ if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
995
+ const key = parsed.value ?? "DEFAULT";
996
+ const s = nativeShadowValue(key);
997
+ if (s === null) return null;
998
+ return [
999
+ decl("shadow-color", "#000000"),
1000
+ decl("shadow-offset-x", "0"),
1001
+ decl("shadow-offset-y", String(s.offsetY)),
1002
+ decl("shadow-opacity", String(s.opacity)),
1003
+ decl("shadow-radius", String(s.radius)),
1004
+ decl("elevation", String(s.elevation))
1005
+ ];
1006
+ }
1007
+
1008
+ // src/jsEngine/resolveUtilityNative.ts
1009
+ function resolveTypographyNative(parsed) {
1010
+ switch (parsed.utility) {
1011
+ case "font": {
1012
+ if (parsed.value === null) return null;
1013
+ const w = fontWeight(parsed.value);
1014
+ return w === null ? null : [decl("font-weight", w)];
1015
+ }
1016
+ case "uppercase":
1017
+ return [decl("text-transform", "uppercase")];
1018
+ case "lowercase":
1019
+ return [decl("text-transform", "lowercase")];
1020
+ case "capitalize":
1021
+ return [decl("text-transform", "capitalize")];
1022
+ case "underline":
1023
+ return [decl("text-decoration-line", "underline")];
1024
+ case "line-through":
1025
+ return [decl("text-decoration-line", "line-through")];
1026
+ case "no-underline":
1027
+ return [decl("text-decoration-line", "none")];
1028
+ case "italic":
1029
+ return [decl("font-style", "italic")];
1030
+ case "not-italic":
1031
+ return [decl("font-style", "normal")];
1032
+ default:
1033
+ return null;
1034
+ }
1035
+ }
1036
+ function resolveLeadingTrackingNative(parsed) {
1037
+ const value = parsed.value;
1038
+ if (value === null) return null;
1039
+ if (parsed.utility === "leading") {
1040
+ if (parsed.isArbitrary) return [decl("line-height", value)];
1041
+ const v = lineHeightSize(value);
1042
+ return v === null ? null : [decl("line-height", v)];
1043
+ }
1044
+ if (parsed.utility === "tracking" && parsed.isArbitrary) {
1045
+ return [decl("letter-spacing", value)];
1046
+ }
1047
+ return null;
1048
+ }
1049
+ function nativeHexColor(parsed, theme) {
1050
+ const value = parsed.value;
1051
+ if (value === null) return null;
1052
+ return parsed.isArbitrary ? value : lookupHex(theme, value);
1053
+ }
1054
+ function resolveTextNative(parsed, theme) {
1055
+ if (!parsed.isArbitrary && parsed.value !== null) {
1056
+ const size = textSize(parsed.value);
1057
+ if (size !== null) return [decl("font-size", size)];
1058
+ const align = textAlign(parsed.value);
1059
+ if (align !== null) return [decl("text-align", align)];
1060
+ }
1061
+ const hex = nativeHexColor(parsed, theme);
1062
+ return hex === null ? null : [decl("color", hex)];
1063
+ }
1064
+ function resolveColorNative(parsed, theme) {
1065
+ switch (parsed.utility) {
1066
+ case "bg": {
1067
+ const hex = nativeHexColor(parsed, theme);
1068
+ return hex === null ? null : [decl("background-color", hex)];
1069
+ }
1070
+ case "text":
1071
+ return resolveTextNative(parsed, theme);
1072
+ default:
1073
+ return null;
1074
+ }
1075
+ }
1076
+ function resolveUtilityNative(parsed, theme) {
1077
+ return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
1078
+ }
1079
+
1080
+ // src/jsEngine/resolveStyle.ts
1081
+ var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
1082
+ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
1083
+ if (modifier === "dark") return colorScheme === "dark";
1084
+ if (modifier === "active") return pressed;
1085
+ if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
1086
+ const minWidth = theme.screens[modifier];
1087
+ if (minWidth === void 0) return null;
1088
+ return width >= minWidth;
1089
+ }
1090
+ return null;
1091
+ }
1092
+ function kebabToCamel(s) {
1093
+ return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
1094
+ }
1095
+ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
1096
+ "padding",
1097
+ "padding-top",
1098
+ "padding-right",
1099
+ "padding-bottom",
1100
+ "padding-left",
1101
+ "margin",
1102
+ "margin-top",
1103
+ "margin-right",
1104
+ "margin-bottom",
1105
+ "margin-left",
1106
+ "gap",
1107
+ "column-gap",
1108
+ "row-gap",
1109
+ "width",
1110
+ "height",
1111
+ "min-width",
1112
+ "max-width",
1113
+ "min-height",
1114
+ "max-height",
1115
+ "top",
1116
+ "right",
1117
+ "bottom",
1118
+ "left",
1119
+ "inset",
1120
+ "border-radius",
1121
+ "border-width",
1122
+ "font-size",
1123
+ "z-index",
1124
+ "line-height",
1125
+ "letter-spacing",
1126
+ "flex",
1127
+ "flex-grow",
1128
+ "flex-shrink",
1129
+ "order",
1130
+ "flex-basis",
1131
+ "shadow-opacity",
1132
+ "shadow-radius",
1133
+ "elevation",
1134
+ // Per-side border width + per-corner radius — see resolvers/border.ts's
1135
+ // new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
1136
+ // style system wants plain numbers for these exactly like the generic
1137
+ // "border-width"/"border-radius" forms above.
1138
+ "border-top-width",
1139
+ "border-right-width",
1140
+ "border-bottom-width",
1141
+ "border-left-width",
1142
+ "border-top-left-radius",
1143
+ "border-top-right-radius",
1144
+ "border-bottom-right-radius",
1145
+ "border-bottom-left-radius",
1146
+ "outline-width",
1147
+ "outline-offset"
1148
+ ]);
1149
+ function rnStyleValue(property, value) {
1150
+ if (NUMERIC_LENGTH_PROPS.has(property)) {
1151
+ let px = null;
1152
+ if (value.endsWith("px")) {
1153
+ const n = Number(value.slice(0, -2));
1154
+ px = Number.isFinite(n) ? n : null;
1155
+ } else if (value.endsWith("rem")) {
1156
+ const n = Number(value.slice(0, -3));
1157
+ px = Number.isFinite(n) ? n * 16 : null;
1158
+ } else {
1159
+ const n = Number(value);
1160
+ px = value.trim() !== "" && Number.isFinite(n) ? n : null;
1161
+ }
1162
+ if (px !== null) return px;
1163
+ }
1164
+ return value;
1165
+ }
1166
+ function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
1167
+ const style = {};
1168
+ let shadowOffset = null;
1169
+ for (const token of classString.split(/\s+/).filter(Boolean)) {
1170
+ const parsed = parseClass(token);
1171
+ const allModifiersHold = parsed.modifiers.every(
1172
+ (m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
1173
+ );
1174
+ if (!allModifiersHold) continue;
1175
+ const decls = resolveUtilityNative(parsed, theme);
1176
+ if (decls === null) continue;
1177
+ for (const d of decls) {
1178
+ if (d.property.startsWith("__")) {
1179
+ continue;
1180
+ }
1181
+ if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
1182
+ const n = Number(d.value);
1183
+ if (!Number.isFinite(n)) continue;
1184
+ if (shadowOffset === null) shadowOffset = {};
1185
+ shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
1186
+ continue;
1187
+ }
1188
+ style[kebabToCamel(d.property)] = rnStyleValue(d.property, d.value);
1189
+ }
1190
+ }
1191
+ if (shadowOffset !== null) {
1192
+ style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
1193
+ }
1194
+ return style;
1195
+ }
1196
+
1197
+ // src/nativeBridge.ts
1198
+ function resolveStyle(classString, pressed = false) {
1199
+ const colorScheme = getGlobalDarkMode() ? "dark" : "light";
1200
+ const width = Dimensions.get("window").width;
1201
+ const KbachModule = TurboModuleRegistry.get("KbachModule");
1202
+ if (!KbachModule) {
1203
+ return resolveStyleJs(classString, getTheme(), colorScheme, pressed, width);
1204
+ }
1205
+ const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
1206
+ return JSON.parse(json);
1207
+ }
1208
+
1209
+ export {
1210
+ resolveStyle
1211
+ };