@kbach/react-native 1.0.0-beta.0 → 1.0.0-beta.10
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 +103 -54
- package/android/build.gradle +36 -0
- package/android/src/main/AndroidManifest.xml +14 -0
- package/android/src/main/java/com/kbachnative/KbachModule.kt +83 -0
- package/android/src/main/java/com/kbachnative/KbachPackage.kt +54 -0
- 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-4N7UEVQL.mjs +14 -0
- package/dist/{chunk-SVMYVXY6.mjs → chunk-DLIXI5OW.mjs} +23 -14
- package/dist/chunk-H5Z24XX5.mjs +192 -0
- package/dist/{chunk-YHF3QLRL.mjs → chunk-HK6PDJJK.mjs} +61 -68
- package/dist/chunk-RBJXE32L.mjs +73 -0
- package/dist/chunk-TDWBXJH5.mjs +186 -0
- package/dist/chunk-XHL653X2.mjs +1211 -0
- package/dist/chunk-YOC3SHF5.mjs +40 -0
- package/dist/index.d.mts +37 -102
- package/dist/index.d.ts +37 -102
- package/dist/index.js +1411 -38
- package/dist/index.mjs +19 -61
- package/dist/index.web.d.mts +15 -0
- package/dist/index.web.d.ts +15 -0
- package/dist/index.web.js +829 -0
- package/dist/index.web.mjs +38 -0
- package/dist/jsx-dev-runtime.d.mts +3 -12
- package/dist/jsx-dev-runtime.d.ts +3 -12
- package/dist/jsx-dev-runtime.js +1314 -47
- package/dist/jsx-dev-runtime.mjs +9 -11
- package/dist/jsx-dev-runtime.web.d.mts +10 -0
- package/dist/jsx-dev-runtime.web.d.ts +10 -0
- package/dist/jsx-dev-runtime.web.js +618 -0
- package/dist/jsx-dev-runtime.web.mjs +17 -0
- package/dist/jsx-runtime.d.mts +3 -23
- package/dist/jsx-runtime.d.ts +3 -23
- package/dist/jsx-runtime.js +1305 -39
- package/dist/jsx-runtime.mjs +7 -3
- package/dist/jsx-runtime.web.d.mts +7 -0
- package/dist/jsx-runtime.web.d.ts +7 -0
- package/dist/jsx-runtime.web.js +602 -0
- package/dist/jsx-runtime.web.mjs +12 -0
- package/dist/useColors-C6jyCLuG.d.mts +239 -0
- package/dist/useColors-C6jyCLuG.d.ts +239 -0
- package/package.json +57 -5
- package/react-native.config.js +29 -0
- package/specs/NativeKbachModule.ts +31 -0
- package/src/babel-plugin.js +74 -2
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -25,13 +25,56 @@ __export(jsx_dev_runtime_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(jsx_dev_runtime_exports);
|
|
27
27
|
|
|
28
|
-
// src/
|
|
28
|
+
// src/jsxRuntimeCore.ts
|
|
29
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
30
|
var import_react = require("react");
|
|
31
|
-
var
|
|
31
|
+
var import_react_native = require("react-native");
|
|
32
|
+
function makeElement(isStaticChildren, type, props, key) {
|
|
33
|
+
return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
|
|
34
|
+
}
|
|
35
|
+
function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed) {
|
|
36
|
+
const resolved = resolveStyle2(classStrRaw, pressed);
|
|
37
|
+
if (userStyle === void 0) {
|
|
38
|
+
return resolved;
|
|
39
|
+
}
|
|
40
|
+
if (typeof userStyle === "function") {
|
|
41
|
+
return [resolved, userStyle({ pressed })];
|
|
42
|
+
}
|
|
43
|
+
return [resolved, userStyle];
|
|
44
|
+
}
|
|
45
|
+
function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
|
|
46
|
+
if (type === null || typeof type === "symbol" || !rawProps) {
|
|
47
|
+
return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
48
|
+
}
|
|
49
|
+
const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
|
|
50
|
+
if (typeof classStrRaw !== "string") {
|
|
51
|
+
return makeElement(isStaticChildren, type, rawProps, key);
|
|
52
|
+
}
|
|
53
|
+
const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
|
|
54
|
+
return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
|
|
55
|
+
}
|
|
56
|
+
function createJsxFunctions(resolveStyle2) {
|
|
57
|
+
function jsx2(type, props, key) {
|
|
58
|
+
return processElement(resolveStyle2, type, props, key, false);
|
|
59
|
+
}
|
|
60
|
+
function jsxs2(type, props, key) {
|
|
61
|
+
return processElement(resolveStyle2, type, props, key, true);
|
|
62
|
+
}
|
|
63
|
+
return { jsx: jsx2, jsxs: jsxs2 };
|
|
64
|
+
}
|
|
65
|
+
function createJsxDEV(jsx2, jsxs2) {
|
|
66
|
+
return function jsxDEV2(type, props, key, isStaticChildren, source, self) {
|
|
67
|
+
const element = (isStaticChildren ? jsxs2 : jsx2)(type, props, key);
|
|
68
|
+
if (source && element && typeof element === "object" && Object.isExtensible(element)) {
|
|
69
|
+
element._source = source;
|
|
70
|
+
element._self = self;
|
|
71
|
+
}
|
|
72
|
+
return element;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
32
75
|
|
|
33
76
|
// src/nativeBridge.ts
|
|
34
|
-
var
|
|
77
|
+
var import_react_native3 = require("react-native");
|
|
35
78
|
|
|
36
79
|
// src/generatedPalette.ts
|
|
37
80
|
var PALETTE = {
|
|
@@ -313,39 +356,110 @@ var PALETTE = {
|
|
|
313
356
|
// src/theme.ts
|
|
314
357
|
var defaultTheme = {
|
|
315
358
|
colors: PALETTE,
|
|
359
|
+
// Real Tailwind's default spacing scale in full — every step is exactly
|
|
360
|
+
// `n * 4px`, including the fractional `.5` steps (`1.5` -> 6px, `2.5` ->
|
|
361
|
+
// 10px, `3.5` -> 14px) and the "px" literal (a bare 1px). Only the
|
|
362
|
+
// "usual stops", though — `jsEngine/shared.ts`'s `spacingPx` (and the
|
|
363
|
+
// native Rust dispatcher's own `spacing_px`) falls back to Tailwind v4's
|
|
364
|
+
// live `n * 4px` formula for any bare numeric step not listed here
|
|
365
|
+
// (`p-0.25`, `w-13`, ...), so this table names the common values and
|
|
366
|
+
// gives a theme override something to target, not the full resolvable
|
|
367
|
+
// set. Mirrors @kbach/react's theme.ts exactly.
|
|
316
368
|
spacing: {
|
|
317
|
-
// "0" is always a hardcoded zero in real Tailwind's own scale too,
|
|
318
|
-
// regardless of the base spacing unit — needed for `p-0`/`m-0`/etc.
|
|
319
|
-
// Mirrors the identical fix in @kbach/react's theme.ts.
|
|
320
369
|
"0": 0,
|
|
370
|
+
"px": 1,
|
|
371
|
+
"0.5": 2,
|
|
321
372
|
"1": 4,
|
|
373
|
+
"1.5": 6,
|
|
322
374
|
"2": 8,
|
|
375
|
+
"2.5": 10,
|
|
376
|
+
"3": 12,
|
|
377
|
+
"3.5": 14,
|
|
323
378
|
"4": 16,
|
|
379
|
+
"5": 20,
|
|
324
380
|
"6": 24,
|
|
325
|
-
"
|
|
381
|
+
"7": 28,
|
|
382
|
+
"8": 32,
|
|
383
|
+
"9": 36,
|
|
384
|
+
"10": 40,
|
|
385
|
+
"11": 44,
|
|
386
|
+
"12": 48,
|
|
387
|
+
"14": 56,
|
|
388
|
+
"16": 64,
|
|
389
|
+
"20": 80,
|
|
390
|
+
"24": 96,
|
|
391
|
+
"28": 112,
|
|
392
|
+
"32": 128,
|
|
393
|
+
"36": 144,
|
|
394
|
+
"40": 160,
|
|
395
|
+
"44": 176,
|
|
396
|
+
"48": 192,
|
|
397
|
+
"52": 208,
|
|
398
|
+
"56": 224,
|
|
399
|
+
"60": 240,
|
|
400
|
+
"64": 256,
|
|
401
|
+
"72": 288,
|
|
402
|
+
"80": 320,
|
|
403
|
+
"96": 384
|
|
326
404
|
},
|
|
327
|
-
screens: {
|
|
328
|
-
|
|
405
|
+
screens: {
|
|
406
|
+
sm: 640,
|
|
407
|
+
md: 768,
|
|
408
|
+
lg: 1024,
|
|
409
|
+
xl: 1280,
|
|
410
|
+
"2xl": 1536
|
|
411
|
+
},
|
|
412
|
+
// Byte-for-byte the same three stacks
|
|
413
|
+
// packages/core-engine/src/resolvers/typography.rs's `font_family_value`
|
|
414
|
+
// falls back to. On native these three still effectively no-op (see
|
|
415
|
+
// `first_font_name`'s own doc comment for why a generic CSS keyword
|
|
416
|
+
// isn't a real loadable font) — only a caller-configured custom name
|
|
417
|
+
// changes native rendering; Expo Web uses the full stack as-is.
|
|
418
|
+
fontFamily: {
|
|
419
|
+
sans: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
420
|
+
serif: 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
|
|
421
|
+
mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
|
|
422
|
+
},
|
|
423
|
+
darkMode: "attribute",
|
|
424
|
+
// Empty by default, matching real Tailwind's own defaults.
|
|
425
|
+
container: {}
|
|
329
426
|
};
|
|
427
|
+
var activeTheme = defaultTheme;
|
|
330
428
|
var activeThemeJson = JSON.stringify(defaultTheme);
|
|
429
|
+
function getTheme() {
|
|
430
|
+
return activeTheme;
|
|
431
|
+
}
|
|
331
432
|
function getThemeJson() {
|
|
332
433
|
return activeThemeJson;
|
|
333
434
|
}
|
|
334
435
|
|
|
335
436
|
// src/darkModeStore.ts
|
|
336
|
-
var
|
|
437
|
+
var import_react_native2 = require("react-native");
|
|
337
438
|
var listeners = /* @__PURE__ */ new Set();
|
|
338
439
|
function systemPrefersDark() {
|
|
339
|
-
return
|
|
440
|
+
return import_react_native2.Appearance.getColorScheme() === "dark";
|
|
340
441
|
}
|
|
341
442
|
function resolveIsDark(m) {
|
|
342
443
|
return m === "system" ? systemPrefersDark() : m === "dark";
|
|
343
444
|
}
|
|
445
|
+
function applyToDom(dark) {
|
|
446
|
+
if (typeof document === "undefined") return;
|
|
447
|
+
const root = document.documentElement;
|
|
448
|
+
const strategy = getTheme().darkMode;
|
|
449
|
+
if (strategy === "class") {
|
|
450
|
+
root.classList.toggle("dark", dark);
|
|
451
|
+
root.classList.toggle("light", !dark);
|
|
452
|
+
} else if (strategy === "attribute") {
|
|
453
|
+
root.setAttribute("data-theme", dark ? "dark" : "light");
|
|
454
|
+
}
|
|
455
|
+
}
|
|
344
456
|
var mode = "system";
|
|
345
457
|
var isDark = resolveIsDark(mode);
|
|
346
|
-
|
|
458
|
+
applyToDom(isDark);
|
|
459
|
+
var subscription = import_react_native2.Appearance.addChangeListener(({ colorScheme }) => {
|
|
347
460
|
if (mode !== "system") return;
|
|
348
461
|
isDark = colorScheme === "dark";
|
|
462
|
+
applyToDom(isDark);
|
|
349
463
|
notify();
|
|
350
464
|
});
|
|
351
465
|
function notify() {
|
|
@@ -355,55 +469,1208 @@ function getGlobalDarkMode() {
|
|
|
355
469
|
return isDark;
|
|
356
470
|
}
|
|
357
471
|
|
|
358
|
-
// src/
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
472
|
+
// src/jsEngine/parser.ts
|
|
473
|
+
var VALUE_PREFIXES = [
|
|
474
|
+
"bg-opacity-",
|
|
475
|
+
"text-opacity-",
|
|
476
|
+
"bg-blend-",
|
|
477
|
+
"text-shadow-",
|
|
478
|
+
"bg-",
|
|
479
|
+
"text-",
|
|
480
|
+
"border-x-",
|
|
481
|
+
"border-y-",
|
|
482
|
+
"border-t-",
|
|
483
|
+
"border-r-",
|
|
484
|
+
"border-b-",
|
|
485
|
+
"border-l-",
|
|
486
|
+
"border-",
|
|
487
|
+
"caret-",
|
|
488
|
+
"accent-",
|
|
489
|
+
"fill-",
|
|
490
|
+
"stroke-width-",
|
|
491
|
+
"stroke-",
|
|
492
|
+
"resize-",
|
|
493
|
+
"touch-",
|
|
494
|
+
"will-change-",
|
|
495
|
+
"scroll-mx-",
|
|
496
|
+
"scroll-my-",
|
|
497
|
+
"scroll-mt-",
|
|
498
|
+
"scroll-mr-",
|
|
499
|
+
"scroll-mb-",
|
|
500
|
+
"scroll-ml-",
|
|
501
|
+
"scroll-m-",
|
|
502
|
+
"scroll-px-",
|
|
503
|
+
"scroll-py-",
|
|
504
|
+
"scroll-pt-",
|
|
505
|
+
"scroll-pr-",
|
|
506
|
+
"scroll-pb-",
|
|
507
|
+
"scroll-pl-",
|
|
508
|
+
"scroll-p-",
|
|
509
|
+
"px-",
|
|
510
|
+
"py-",
|
|
511
|
+
"pt-",
|
|
512
|
+
"pr-",
|
|
513
|
+
"pb-",
|
|
514
|
+
"pl-",
|
|
515
|
+
"p-",
|
|
516
|
+
"mx-",
|
|
517
|
+
"my-",
|
|
518
|
+
"mt-",
|
|
519
|
+
"mr-",
|
|
520
|
+
"mb-",
|
|
521
|
+
"ml-",
|
|
522
|
+
"m-",
|
|
523
|
+
"gap-x-",
|
|
524
|
+
"gap-y-",
|
|
525
|
+
"gap-",
|
|
526
|
+
"min-w-",
|
|
527
|
+
"max-w-",
|
|
528
|
+
"w-",
|
|
529
|
+
"min-h-",
|
|
530
|
+
"max-h-",
|
|
531
|
+
"h-",
|
|
532
|
+
"size-",
|
|
533
|
+
"basis-",
|
|
534
|
+
"rounded-tl-",
|
|
535
|
+
"rounded-tr-",
|
|
536
|
+
"rounded-br-",
|
|
537
|
+
"rounded-bl-",
|
|
538
|
+
"rounded-t-",
|
|
539
|
+
"rounded-r-",
|
|
540
|
+
"rounded-b-",
|
|
541
|
+
"rounded-l-",
|
|
542
|
+
"rounded-",
|
|
543
|
+
"ring-offset-",
|
|
544
|
+
"ring-",
|
|
545
|
+
"outline-offset-",
|
|
546
|
+
"outline-",
|
|
547
|
+
"shadow-",
|
|
548
|
+
"opacity-",
|
|
549
|
+
"duration-",
|
|
550
|
+
"delay-",
|
|
551
|
+
"ease-",
|
|
552
|
+
"cursor-",
|
|
553
|
+
"mix-blend-",
|
|
554
|
+
"animate-",
|
|
555
|
+
"leading-",
|
|
556
|
+
"tracking-",
|
|
557
|
+
"font-",
|
|
558
|
+
"z-",
|
|
559
|
+
"inset-",
|
|
560
|
+
"top-",
|
|
561
|
+
"right-",
|
|
562
|
+
"bottom-",
|
|
563
|
+
"left-",
|
|
564
|
+
"divide-color-",
|
|
565
|
+
"space-x-",
|
|
566
|
+
"space-y-",
|
|
567
|
+
"flex-",
|
|
568
|
+
"grow-",
|
|
569
|
+
"shrink-",
|
|
570
|
+
"order-",
|
|
571
|
+
"grid-cols-",
|
|
572
|
+
"grid-rows-",
|
|
573
|
+
"grid-flow-",
|
|
574
|
+
"auto-cols-",
|
|
575
|
+
"auto-rows-",
|
|
576
|
+
"col-span-",
|
|
577
|
+
"col-start-",
|
|
578
|
+
"col-end-",
|
|
579
|
+
"col-",
|
|
580
|
+
"row-span-",
|
|
581
|
+
"row-start-",
|
|
582
|
+
"row-end-",
|
|
583
|
+
"row-",
|
|
584
|
+
"place-items-",
|
|
585
|
+
"place-content-",
|
|
586
|
+
"place-self-",
|
|
587
|
+
"justify-items-",
|
|
588
|
+
"justify-self-",
|
|
589
|
+
"scale-x-",
|
|
590
|
+
"scale-y-",
|
|
591
|
+
"scale-",
|
|
592
|
+
"rotate-",
|
|
593
|
+
"translate-x-",
|
|
594
|
+
"translate-y-",
|
|
595
|
+
"skew-x-",
|
|
596
|
+
"skew-y-",
|
|
597
|
+
"origin-",
|
|
598
|
+
"blur-",
|
|
599
|
+
"brightness-",
|
|
600
|
+
"contrast-",
|
|
601
|
+
"grayscale-",
|
|
602
|
+
"hue-rotate-",
|
|
603
|
+
"invert-",
|
|
604
|
+
"saturate-",
|
|
605
|
+
"sepia-",
|
|
606
|
+
"drop-shadow-",
|
|
607
|
+
"filter-",
|
|
608
|
+
"backdrop-blur-",
|
|
609
|
+
"backdrop-brightness-",
|
|
610
|
+
"backdrop-contrast-",
|
|
611
|
+
"backdrop-grayscale-",
|
|
612
|
+
"backdrop-hue-rotate-",
|
|
613
|
+
"backdrop-invert-",
|
|
614
|
+
"backdrop-opacity-",
|
|
615
|
+
"backdrop-saturate-",
|
|
616
|
+
"backdrop-sepia-",
|
|
617
|
+
"backdrop-filter-",
|
|
618
|
+
"decoration-",
|
|
619
|
+
"underline-offset-",
|
|
620
|
+
"indent-",
|
|
621
|
+
"from-",
|
|
622
|
+
"via-",
|
|
623
|
+
"to-"
|
|
624
|
+
];
|
|
625
|
+
var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
626
|
+
function isSafeArbitraryValue(value) {
|
|
627
|
+
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
628
|
+
}
|
|
629
|
+
function splitRespectingBrackets(token) {
|
|
630
|
+
const parts = [];
|
|
631
|
+
let depth = 0;
|
|
632
|
+
let start = 0;
|
|
633
|
+
for (let i = 0; i < token.length; i++) {
|
|
634
|
+
const ch = token[i];
|
|
635
|
+
if (ch === "[") depth += 1;
|
|
636
|
+
else if (ch === "]") depth -= 1;
|
|
637
|
+
else if (ch === ":" && depth <= 0) {
|
|
638
|
+
parts.push(token.slice(start, i));
|
|
639
|
+
start = i + 1;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
parts.push(token.slice(start));
|
|
643
|
+
return parts;
|
|
644
|
+
}
|
|
645
|
+
function parseClass(token) {
|
|
646
|
+
const parts = splitRespectingBrackets(token);
|
|
647
|
+
let base = parts.pop() ?? token;
|
|
648
|
+
const modifiers = parts;
|
|
649
|
+
const important = base.startsWith("!");
|
|
650
|
+
if (important) {
|
|
651
|
+
base = base.slice(1);
|
|
652
|
+
}
|
|
653
|
+
const negative = base.startsWith("-");
|
|
654
|
+
if (negative) {
|
|
655
|
+
base = base.slice(1);
|
|
656
|
+
}
|
|
657
|
+
if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
|
|
658
|
+
const raw = base.slice(1, -1);
|
|
659
|
+
const colonIdx = raw.indexOf(":");
|
|
660
|
+
if (colonIdx !== -1) {
|
|
661
|
+
const property = raw.slice(0, colonIdx);
|
|
662
|
+
const rawValue = raw.slice(colonIdx + 1);
|
|
663
|
+
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
664
|
+
const value = rawValue.replace(/_/g, " ");
|
|
665
|
+
return {
|
|
666
|
+
modifiers,
|
|
667
|
+
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
668
|
+
value: `${property}:${value}`,
|
|
669
|
+
isArbitrary: true,
|
|
670
|
+
important,
|
|
671
|
+
negative,
|
|
672
|
+
original: token
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
for (const prefix of VALUE_PREFIXES) {
|
|
678
|
+
if (!base.startsWith(prefix)) continue;
|
|
679
|
+
const value = base.slice(prefix.length);
|
|
680
|
+
if (value === "") continue;
|
|
681
|
+
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
682
|
+
const raw = value.slice(1, -1);
|
|
683
|
+
if (!isSafeArbitraryValue(raw)) {
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
const spaced = raw.replace(/_/g, " ");
|
|
687
|
+
return {
|
|
688
|
+
modifiers,
|
|
689
|
+
utility: prefix.slice(0, -1),
|
|
690
|
+
value: spaced,
|
|
691
|
+
isArbitrary: true,
|
|
692
|
+
important,
|
|
693
|
+
negative,
|
|
694
|
+
original: token
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
return {
|
|
698
|
+
modifiers,
|
|
699
|
+
utility: prefix.slice(0, -1),
|
|
700
|
+
value,
|
|
701
|
+
isArbitrary: false,
|
|
702
|
+
important,
|
|
703
|
+
negative,
|
|
704
|
+
original: token
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
return {
|
|
708
|
+
modifiers,
|
|
709
|
+
utility: base,
|
|
710
|
+
value: null,
|
|
711
|
+
isArbitrary: false,
|
|
712
|
+
important,
|
|
713
|
+
negative,
|
|
714
|
+
original: token
|
|
715
|
+
};
|
|
364
716
|
}
|
|
365
717
|
|
|
366
|
-
// src/
|
|
367
|
-
function
|
|
368
|
-
return
|
|
718
|
+
// src/jsEngine/shared.ts
|
|
719
|
+
function decl(property, value) {
|
|
720
|
+
return { property, value };
|
|
369
721
|
}
|
|
370
|
-
function
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
373
|
-
|
|
722
|
+
function spacingPx(theme, value) {
|
|
723
|
+
const fromTable = theme.spacing[value];
|
|
724
|
+
if (fromTable !== void 0) return fromTable;
|
|
725
|
+
const n = Number(value);
|
|
726
|
+
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
727
|
+
}
|
|
728
|
+
function resolveLength(theme, parsed) {
|
|
729
|
+
if (parsed.negative) return null;
|
|
730
|
+
const value = parsed.value;
|
|
731
|
+
if (value === null) return null;
|
|
732
|
+
if (parsed.isArbitrary) return value;
|
|
733
|
+
if (value === "full") return "100%";
|
|
734
|
+
if (value === "auto") return "auto";
|
|
735
|
+
const px = spacingPx(theme, value);
|
|
736
|
+
return px === void 0 ? null : `${px}px`;
|
|
737
|
+
}
|
|
738
|
+
function resolveNegatableLength(theme, parsed) {
|
|
739
|
+
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
740
|
+
if (parsed.isArbitrary) return null;
|
|
741
|
+
const value = parsed.value;
|
|
742
|
+
if (value === null) return null;
|
|
743
|
+
const px = spacingPx(theme, value);
|
|
744
|
+
if (px === void 0) return null;
|
|
745
|
+
if (px === 0) return "0px";
|
|
746
|
+
return `-${px}px`;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// src/jsEngine/resolvers/layout.ts
|
|
750
|
+
function negateRaw(value, negative) {
|
|
751
|
+
return negative ? `-${value}` : value;
|
|
752
|
+
}
|
|
753
|
+
function resolve(parsed, theme) {
|
|
754
|
+
switch (parsed.utility) {
|
|
755
|
+
case "flex":
|
|
756
|
+
return parsed.value === null ? [decl("display", "flex")] : null;
|
|
757
|
+
case "grid":
|
|
758
|
+
return [decl("display", "grid")];
|
|
759
|
+
case "block":
|
|
760
|
+
return [decl("display", "block")];
|
|
761
|
+
case "inline-block":
|
|
762
|
+
return [decl("display", "inline-block")];
|
|
763
|
+
case "inline":
|
|
764
|
+
return [decl("display", "inline")];
|
|
765
|
+
case "inline-flex":
|
|
766
|
+
return [decl("display", "inline-flex")];
|
|
767
|
+
case "inline-grid":
|
|
768
|
+
return [decl("display", "inline-grid")];
|
|
769
|
+
case "contents":
|
|
770
|
+
return [decl("display", "contents")];
|
|
771
|
+
case "flow-root":
|
|
772
|
+
return [decl("display", "flow-root")];
|
|
773
|
+
case "hidden":
|
|
774
|
+
return [decl("display", "none")];
|
|
775
|
+
case "@container":
|
|
776
|
+
return [decl("container-type", "inline-size")];
|
|
777
|
+
case "items-center":
|
|
778
|
+
return [decl("align-items", "center")];
|
|
779
|
+
case "items-start":
|
|
780
|
+
return [decl("align-items", "flex-start")];
|
|
781
|
+
case "items-end":
|
|
782
|
+
return [decl("align-items", "flex-end")];
|
|
783
|
+
case "items-baseline":
|
|
784
|
+
return [decl("align-items", "baseline")];
|
|
785
|
+
case "items-stretch":
|
|
786
|
+
return [decl("align-items", "stretch")];
|
|
787
|
+
case "justify-center":
|
|
788
|
+
return [decl("justify-content", "center")];
|
|
789
|
+
case "justify-start":
|
|
790
|
+
return [decl("justify-content", "flex-start")];
|
|
791
|
+
case "justify-end":
|
|
792
|
+
return [decl("justify-content", "flex-end")];
|
|
793
|
+
case "justify-between":
|
|
794
|
+
return [decl("justify-content", "space-between")];
|
|
795
|
+
case "justify-around":
|
|
796
|
+
return [decl("justify-content", "space-around")];
|
|
797
|
+
case "justify-evenly":
|
|
798
|
+
return [decl("justify-content", "space-evenly")];
|
|
799
|
+
case "content-start":
|
|
800
|
+
return [decl("align-content", "flex-start")];
|
|
801
|
+
case "content-end":
|
|
802
|
+
return [decl("align-content", "flex-end")];
|
|
803
|
+
case "content-center":
|
|
804
|
+
return [decl("align-content", "center")];
|
|
805
|
+
case "content-between":
|
|
806
|
+
return [decl("align-content", "space-between")];
|
|
807
|
+
case "content-around":
|
|
808
|
+
return [decl("align-content", "space-around")];
|
|
809
|
+
case "content-evenly":
|
|
810
|
+
return [decl("align-content", "space-evenly")];
|
|
811
|
+
case "content-stretch":
|
|
812
|
+
return [decl("align-content", "stretch")];
|
|
813
|
+
case "self-auto":
|
|
814
|
+
return [decl("align-self", "auto")];
|
|
815
|
+
case "self-center":
|
|
816
|
+
return [decl("align-self", "center")];
|
|
817
|
+
case "self-start":
|
|
818
|
+
return [decl("align-self", "flex-start")];
|
|
819
|
+
case "self-end":
|
|
820
|
+
return [decl("align-self", "flex-end")];
|
|
821
|
+
case "self-stretch":
|
|
822
|
+
return [decl("align-self", "stretch")];
|
|
823
|
+
case "self-baseline":
|
|
824
|
+
return [decl("align-self", "baseline")];
|
|
825
|
+
case "overflow-hidden":
|
|
826
|
+
return [decl("overflow", "hidden")];
|
|
827
|
+
case "overflow-auto":
|
|
828
|
+
return [decl("overflow", "auto")];
|
|
829
|
+
case "overflow-scroll":
|
|
830
|
+
return [decl("overflow", "scroll")];
|
|
831
|
+
case "overflow-visible":
|
|
832
|
+
return [decl("overflow", "visible")];
|
|
833
|
+
case "static":
|
|
834
|
+
return [decl("position", "static")];
|
|
835
|
+
case "relative":
|
|
836
|
+
return [decl("position", "relative")];
|
|
837
|
+
case "absolute":
|
|
838
|
+
return [decl("position", "absolute")];
|
|
839
|
+
case "fixed":
|
|
840
|
+
return [decl("position", "fixed")];
|
|
841
|
+
case "sticky":
|
|
842
|
+
return [decl("position", "sticky")];
|
|
843
|
+
case "z":
|
|
844
|
+
return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
|
|
845
|
+
case "order":
|
|
846
|
+
return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
|
|
847
|
+
case "grow":
|
|
848
|
+
return [decl("flex-grow", parsed.value ?? "1")];
|
|
849
|
+
case "shrink":
|
|
850
|
+
return [decl("flex-shrink", parsed.value ?? "1")];
|
|
851
|
+
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
852
|
+
// convention ("-top-4") — see resolveNegatableLength's own doc comment.
|
|
853
|
+
case "top": {
|
|
854
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
855
|
+
return v === null ? null : [decl("top", v)];
|
|
856
|
+
}
|
|
857
|
+
case "right": {
|
|
858
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
859
|
+
return v === null ? null : [decl("right", v)];
|
|
860
|
+
}
|
|
861
|
+
case "bottom": {
|
|
862
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
863
|
+
return v === null ? null : [decl("bottom", v)];
|
|
864
|
+
}
|
|
865
|
+
case "left": {
|
|
866
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
867
|
+
return v === null ? null : [decl("left", v)];
|
|
868
|
+
}
|
|
869
|
+
case "inset": {
|
|
870
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
871
|
+
return v === null ? null : [decl("inset", v)];
|
|
872
|
+
}
|
|
873
|
+
case "aspect-square":
|
|
874
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
875
|
+
case "aspect-video":
|
|
876
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
877
|
+
default:
|
|
878
|
+
return null;
|
|
374
879
|
}
|
|
375
|
-
|
|
376
|
-
|
|
880
|
+
}
|
|
881
|
+
function resolveFlex(parsed, web) {
|
|
882
|
+
if (parsed.utility !== "flex") return null;
|
|
883
|
+
const value = parsed.value;
|
|
884
|
+
if (value === null) return null;
|
|
885
|
+
if (parsed.isArbitrary) return [decl("flex", value)];
|
|
886
|
+
switch (value) {
|
|
887
|
+
case "row":
|
|
888
|
+
return [decl("flex-direction", "row")];
|
|
889
|
+
case "col":
|
|
890
|
+
return [decl("flex-direction", "column")];
|
|
891
|
+
case "row-reverse":
|
|
892
|
+
return [decl("flex-direction", "row-reverse")];
|
|
893
|
+
case "col-reverse":
|
|
894
|
+
return [decl("flex-direction", "column-reverse")];
|
|
895
|
+
case "wrap":
|
|
896
|
+
return [decl("flex-wrap", "wrap")];
|
|
897
|
+
case "wrap-reverse":
|
|
898
|
+
return [decl("flex-wrap", "wrap-reverse")];
|
|
899
|
+
case "nowrap":
|
|
900
|
+
return [decl("flex-wrap", "nowrap")];
|
|
901
|
+
case "1":
|
|
902
|
+
return [decl("flex", "1")];
|
|
903
|
+
case "auto":
|
|
904
|
+
return [decl("flex", web ? "auto" : "1")];
|
|
905
|
+
case "initial":
|
|
906
|
+
return [decl("flex", web ? "initial" : "1")];
|
|
907
|
+
case "none":
|
|
908
|
+
return [decl("flex", web ? "none" : "0")];
|
|
909
|
+
case "grow":
|
|
910
|
+
return [decl("flex-grow", "1")];
|
|
911
|
+
case "grow-0":
|
|
912
|
+
return [decl("flex-grow", "0")];
|
|
913
|
+
case "shrink":
|
|
914
|
+
return [decl("flex-shrink", "1")];
|
|
915
|
+
case "shrink-0":
|
|
916
|
+
return [decl("flex-shrink", "0")];
|
|
917
|
+
default:
|
|
918
|
+
return null;
|
|
377
919
|
}
|
|
378
|
-
return [resolved, userStyle];
|
|
379
920
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
921
|
+
|
|
922
|
+
// src/jsEngine/resolvers/spacing.ts
|
|
923
|
+
function namedSize(key) {
|
|
924
|
+
switch (key) {
|
|
925
|
+
case "sm":
|
|
926
|
+
return "24rem";
|
|
927
|
+
case "md":
|
|
928
|
+
return "28rem";
|
|
929
|
+
case "lg":
|
|
930
|
+
return "32rem";
|
|
931
|
+
case "xl":
|
|
932
|
+
return "36rem";
|
|
933
|
+
case "2xl":
|
|
934
|
+
return "42rem";
|
|
935
|
+
case "3xl":
|
|
936
|
+
return "48rem";
|
|
937
|
+
case "4xl":
|
|
938
|
+
return "56rem";
|
|
939
|
+
case "5xl":
|
|
940
|
+
return "64rem";
|
|
941
|
+
case "6xl":
|
|
942
|
+
return "72rem";
|
|
943
|
+
case "7xl":
|
|
944
|
+
return "80rem";
|
|
945
|
+
case "8xl":
|
|
946
|
+
return "88rem";
|
|
947
|
+
case "9xl":
|
|
948
|
+
return "96rem";
|
|
949
|
+
default:
|
|
950
|
+
return null;
|
|
383
951
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
952
|
+
}
|
|
953
|
+
function fractionPercent(value) {
|
|
954
|
+
const slashIdx = value.indexOf("/");
|
|
955
|
+
if (slashIdx === -1) return null;
|
|
956
|
+
const numStr = value.slice(0, slashIdx);
|
|
957
|
+
const denStr = value.slice(slashIdx + 1);
|
|
958
|
+
const num = Number(numStr);
|
|
959
|
+
const den = Number(denStr);
|
|
960
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
961
|
+
if (den === 0) return null;
|
|
962
|
+
const pct = num / den * 100;
|
|
963
|
+
const formatted = pct.toFixed(6);
|
|
964
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
965
|
+
return `${trimmed}%`;
|
|
966
|
+
}
|
|
967
|
+
function cssSizeKeyword(key) {
|
|
968
|
+
switch (key) {
|
|
969
|
+
case "min":
|
|
970
|
+
return "min-content";
|
|
971
|
+
case "max":
|
|
972
|
+
return "max-content";
|
|
973
|
+
case "fit":
|
|
974
|
+
return "fit-content";
|
|
975
|
+
default:
|
|
976
|
+
return null;
|
|
387
977
|
}
|
|
388
|
-
const finalStyle = type === import_react_native3.Pressable ? (state) => resolvedStyleFor(classStrRaw, userStyle, state.pressed) : resolvedStyleFor(classStrRaw, userStyle, false);
|
|
389
|
-
return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
|
|
390
978
|
}
|
|
391
|
-
function
|
|
392
|
-
|
|
979
|
+
function resolveSize(theme, parsed) {
|
|
980
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
981
|
+
const named = namedSize(parsed.value);
|
|
982
|
+
if (named !== null) return named;
|
|
983
|
+
const kw = cssSizeKeyword(parsed.value);
|
|
984
|
+
if (kw !== null) return kw;
|
|
985
|
+
const fraction = fractionPercent(parsed.value);
|
|
986
|
+
if (fraction !== null) return fraction;
|
|
987
|
+
}
|
|
988
|
+
return resolveLength(theme, parsed);
|
|
393
989
|
}
|
|
394
|
-
function
|
|
395
|
-
|
|
990
|
+
function resolve2(parsed, theme) {
|
|
991
|
+
const length = () => resolveLength(theme, parsed);
|
|
992
|
+
const size = () => resolveSize(theme, parsed);
|
|
993
|
+
const negatableLength = () => resolveNegatableLength(theme, parsed);
|
|
994
|
+
switch (parsed.utility) {
|
|
995
|
+
case "p": {
|
|
996
|
+
const v = length();
|
|
997
|
+
return v === null ? null : [decl("padding", v)];
|
|
998
|
+
}
|
|
999
|
+
case "px": {
|
|
1000
|
+
const v = length();
|
|
1001
|
+
return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
|
|
1002
|
+
}
|
|
1003
|
+
case "py": {
|
|
1004
|
+
const v = length();
|
|
1005
|
+
return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
|
|
1006
|
+
}
|
|
1007
|
+
case "pt": {
|
|
1008
|
+
const v = length();
|
|
1009
|
+
return v === null ? null : [decl("padding-top", v)];
|
|
1010
|
+
}
|
|
1011
|
+
case "pr": {
|
|
1012
|
+
const v = length();
|
|
1013
|
+
return v === null ? null : [decl("padding-right", v)];
|
|
1014
|
+
}
|
|
1015
|
+
case "pb": {
|
|
1016
|
+
const v = length();
|
|
1017
|
+
return v === null ? null : [decl("padding-bottom", v)];
|
|
1018
|
+
}
|
|
1019
|
+
case "pl": {
|
|
1020
|
+
const v = length();
|
|
1021
|
+
return v === null ? null : [decl("padding-left", v)];
|
|
1022
|
+
}
|
|
1023
|
+
case "m": {
|
|
1024
|
+
const v = negatableLength();
|
|
1025
|
+
return v === null ? null : [decl("margin", v)];
|
|
1026
|
+
}
|
|
1027
|
+
case "mx": {
|
|
1028
|
+
const v = negatableLength();
|
|
1029
|
+
return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
|
|
1030
|
+
}
|
|
1031
|
+
case "my": {
|
|
1032
|
+
const v = negatableLength();
|
|
1033
|
+
return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
|
|
1034
|
+
}
|
|
1035
|
+
case "mt": {
|
|
1036
|
+
const v = negatableLength();
|
|
1037
|
+
return v === null ? null : [decl("margin-top", v)];
|
|
1038
|
+
}
|
|
1039
|
+
case "mr": {
|
|
1040
|
+
const v = negatableLength();
|
|
1041
|
+
return v === null ? null : [decl("margin-right", v)];
|
|
1042
|
+
}
|
|
1043
|
+
case "mb": {
|
|
1044
|
+
const v = negatableLength();
|
|
1045
|
+
return v === null ? null : [decl("margin-bottom", v)];
|
|
1046
|
+
}
|
|
1047
|
+
case "ml": {
|
|
1048
|
+
const v = negatableLength();
|
|
1049
|
+
return v === null ? null : [decl("margin-left", v)];
|
|
1050
|
+
}
|
|
1051
|
+
case "gap": {
|
|
1052
|
+
const v = length();
|
|
1053
|
+
return v === null ? null : [decl("gap", v)];
|
|
1054
|
+
}
|
|
1055
|
+
case "gap-x": {
|
|
1056
|
+
const v = length();
|
|
1057
|
+
return v === null ? null : [decl("column-gap", v)];
|
|
1058
|
+
}
|
|
1059
|
+
case "gap-y": {
|
|
1060
|
+
const v = length();
|
|
1061
|
+
return v === null ? null : [decl("row-gap", v)];
|
|
1062
|
+
}
|
|
1063
|
+
case "w": {
|
|
1064
|
+
const v = size();
|
|
1065
|
+
return v === null ? null : [decl("width", v)];
|
|
1066
|
+
}
|
|
1067
|
+
case "h": {
|
|
1068
|
+
const v = size();
|
|
1069
|
+
return v === null ? null : [decl("height", v)];
|
|
1070
|
+
}
|
|
1071
|
+
case "min-w": {
|
|
1072
|
+
const v = size();
|
|
1073
|
+
return v === null ? null : [decl("min-width", v)];
|
|
1074
|
+
}
|
|
1075
|
+
case "max-w": {
|
|
1076
|
+
const v = size();
|
|
1077
|
+
return v === null ? null : [decl("max-width", v)];
|
|
1078
|
+
}
|
|
1079
|
+
case "min-h": {
|
|
1080
|
+
const v = size();
|
|
1081
|
+
return v === null ? null : [decl("min-height", v)];
|
|
1082
|
+
}
|
|
1083
|
+
case "max-h": {
|
|
1084
|
+
const v = size();
|
|
1085
|
+
return v === null ? null : [decl("max-height", v)];
|
|
1086
|
+
}
|
|
1087
|
+
case "size": {
|
|
1088
|
+
const v = size();
|
|
1089
|
+
return v === null ? null : [decl("width", v), decl("height", v)];
|
|
1090
|
+
}
|
|
1091
|
+
case "basis": {
|
|
1092
|
+
const v = size();
|
|
1093
|
+
return v === null ? null : [decl("flex-basis", v)];
|
|
1094
|
+
}
|
|
1095
|
+
default:
|
|
1096
|
+
return null;
|
|
1097
|
+
}
|
|
396
1098
|
}
|
|
397
1099
|
|
|
398
|
-
// src/
|
|
399
|
-
function
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
1100
|
+
// src/jsEngine/resolvers/color.ts
|
|
1101
|
+
function lookupHex(theme, key) {
|
|
1102
|
+
const entry = theme.colors[key];
|
|
1103
|
+
return typeof entry === "string" ? entry : null;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
// src/jsEngine/resolvers/border.ts
|
|
1107
|
+
function radiusSize(key) {
|
|
1108
|
+
switch (key) {
|
|
1109
|
+
case "none":
|
|
1110
|
+
return "0px";
|
|
1111
|
+
case "sm":
|
|
1112
|
+
return "0.125rem";
|
|
1113
|
+
case "md":
|
|
1114
|
+
return "0.375rem";
|
|
1115
|
+
case "lg":
|
|
1116
|
+
return "0.5rem";
|
|
1117
|
+
case "xl":
|
|
1118
|
+
return "0.75rem";
|
|
1119
|
+
case "2xl":
|
|
1120
|
+
return "1rem";
|
|
1121
|
+
case "3xl":
|
|
1122
|
+
return "1.5rem";
|
|
1123
|
+
case "full":
|
|
1124
|
+
return "9999px";
|
|
1125
|
+
default:
|
|
1126
|
+
return null;
|
|
404
1127
|
}
|
|
405
|
-
return element;
|
|
406
1128
|
}
|
|
1129
|
+
function borderSideProperty(side) {
|
|
1130
|
+
switch (side) {
|
|
1131
|
+
case "t":
|
|
1132
|
+
return "border-top";
|
|
1133
|
+
case "r":
|
|
1134
|
+
return "border-right";
|
|
1135
|
+
case "b":
|
|
1136
|
+
return "border-bottom";
|
|
1137
|
+
case "l":
|
|
1138
|
+
return "border-left";
|
|
1139
|
+
default:
|
|
1140
|
+
return null;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
function borderValue(theme, parsed) {
|
|
1144
|
+
const value = parsed.value;
|
|
1145
|
+
if (value === null) return null;
|
|
1146
|
+
if (!parsed.isArbitrary) {
|
|
1147
|
+
const side = borderSideProperty(value);
|
|
1148
|
+
if (side !== null) {
|
|
1149
|
+
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
1150
|
+
}
|
|
1151
|
+
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
1152
|
+
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
1153
|
+
}
|
|
1154
|
+
if (parsed.isArbitrary) {
|
|
1155
|
+
return [decl("border-width", value)];
|
|
1156
|
+
}
|
|
1157
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1158
|
+
const v = resolveLength(theme, parsed);
|
|
1159
|
+
return v === null ? null : [decl("border-width", v)];
|
|
1160
|
+
}
|
|
1161
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1162
|
+
return [decl("border-style", value)];
|
|
1163
|
+
}
|
|
1164
|
+
const hex = lookupHex(theme, value);
|
|
1165
|
+
return hex === null ? null : [decl("border-color", hex)];
|
|
1166
|
+
}
|
|
1167
|
+
function borderSideValue(theme, parsed, sideProperty) {
|
|
1168
|
+
const value = parsed.value;
|
|
1169
|
+
if (value === null) return null;
|
|
1170
|
+
if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
|
|
1171
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1172
|
+
const v = resolveLength(theme, parsed);
|
|
1173
|
+
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
1174
|
+
}
|
|
1175
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1176
|
+
return [decl(`${sideProperty}-style`, value)];
|
|
1177
|
+
}
|
|
1178
|
+
const hex = lookupHex(theme, value);
|
|
1179
|
+
return hex === null ? null : [decl(`${sideProperty}-color`, hex)];
|
|
1180
|
+
}
|
|
1181
|
+
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
1182
|
+
const value = parsed.value;
|
|
1183
|
+
if (value === null) return null;
|
|
1184
|
+
if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
1185
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1186
|
+
const v = resolveLength(theme, parsed);
|
|
1187
|
+
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
1188
|
+
}
|
|
1189
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1190
|
+
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
1191
|
+
}
|
|
1192
|
+
const hex = lookupHex(theme, value);
|
|
1193
|
+
return hex === null ? null : [decl(`${sideA}-color`, hex), decl(`${sideB}-color`, hex)];
|
|
1194
|
+
}
|
|
1195
|
+
function radiusProperties(side) {
|
|
1196
|
+
switch (side) {
|
|
1197
|
+
case "t":
|
|
1198
|
+
return ["border-top-left-radius", "border-top-right-radius"];
|
|
1199
|
+
case "r":
|
|
1200
|
+
return ["border-top-right-radius", "border-bottom-right-radius"];
|
|
1201
|
+
case "b":
|
|
1202
|
+
return ["border-bottom-right-radius", "border-bottom-left-radius"];
|
|
1203
|
+
case "l":
|
|
1204
|
+
return ["border-top-left-radius", "border-bottom-left-radius"];
|
|
1205
|
+
case "tl":
|
|
1206
|
+
return ["border-top-left-radius"];
|
|
1207
|
+
case "tr":
|
|
1208
|
+
return ["border-top-right-radius"];
|
|
1209
|
+
case "br":
|
|
1210
|
+
return ["border-bottom-right-radius"];
|
|
1211
|
+
case "bl":
|
|
1212
|
+
return ["border-bottom-left-radius"];
|
|
1213
|
+
default:
|
|
1214
|
+
return null;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
function resolveRadiusValue(theme, parsed) {
|
|
1218
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1219
|
+
const size = radiusSize(parsed.value);
|
|
1220
|
+
if (size !== null) return size;
|
|
1221
|
+
}
|
|
1222
|
+
return resolveLength(theme, parsed);
|
|
1223
|
+
}
|
|
1224
|
+
function resolveRadiusSide(theme, parsed, side) {
|
|
1225
|
+
const properties = radiusProperties(side);
|
|
1226
|
+
if (properties === null) return null;
|
|
1227
|
+
const value = resolveRadiusValue(theme, parsed);
|
|
1228
|
+
if (value === null) return null;
|
|
1229
|
+
return properties.map((p) => decl(p, value));
|
|
1230
|
+
}
|
|
1231
|
+
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1232
|
+
function outlineWidthValue(key) {
|
|
1233
|
+
switch (key) {
|
|
1234
|
+
case "0":
|
|
1235
|
+
return "0px";
|
|
1236
|
+
case "1":
|
|
1237
|
+
return "1px";
|
|
1238
|
+
case "2":
|
|
1239
|
+
return "2px";
|
|
1240
|
+
case "4":
|
|
1241
|
+
return "4px";
|
|
1242
|
+
case "8":
|
|
1243
|
+
return "8px";
|
|
1244
|
+
default:
|
|
1245
|
+
return null;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
function outlineValue(theme, parsed) {
|
|
1249
|
+
const value = parsed.value;
|
|
1250
|
+
if (value === null) return null;
|
|
1251
|
+
if (parsed.isArbitrary) return [decl("outline-width", value)];
|
|
1252
|
+
const w = outlineWidthValue(value);
|
|
1253
|
+
if (w !== null) return [decl("outline-width", w)];
|
|
1254
|
+
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1255
|
+
const hex = lookupHex(theme, value);
|
|
1256
|
+
return hex === null ? null : [decl("outline-color", hex)];
|
|
1257
|
+
}
|
|
1258
|
+
function outlineOffsetValue(parsed) {
|
|
1259
|
+
const value = parsed.value;
|
|
1260
|
+
if (value === null) return null;
|
|
1261
|
+
if (parsed.isArbitrary) return [decl("outline-offset", value)];
|
|
1262
|
+
const w = outlineWidthValue(value);
|
|
1263
|
+
return w === null ? null : [decl("outline-offset", w)];
|
|
1264
|
+
}
|
|
1265
|
+
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))";
|
|
1266
|
+
function ringWidth(key) {
|
|
1267
|
+
switch (key) {
|
|
1268
|
+
case "0":
|
|
1269
|
+
return "0px";
|
|
1270
|
+
case "1":
|
|
1271
|
+
return "1px";
|
|
1272
|
+
case "2":
|
|
1273
|
+
return "2px";
|
|
1274
|
+
case "4":
|
|
1275
|
+
return "4px";
|
|
1276
|
+
case "8":
|
|
1277
|
+
return "8px";
|
|
1278
|
+
default:
|
|
1279
|
+
return null;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
function ringValue(theme, parsed) {
|
|
1283
|
+
const value = parsed.value;
|
|
1284
|
+
if (value === null) return null;
|
|
1285
|
+
if (value === "inset") {
|
|
1286
|
+
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1287
|
+
}
|
|
1288
|
+
if (!parsed.isArbitrary) {
|
|
1289
|
+
const w = ringWidth(value);
|
|
1290
|
+
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1291
|
+
}
|
|
1292
|
+
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1293
|
+
if (color === null) return null;
|
|
1294
|
+
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1295
|
+
}
|
|
1296
|
+
function ringOffsetValue(theme, parsed) {
|
|
1297
|
+
const value = parsed.value;
|
|
1298
|
+
if (value === null) return null;
|
|
1299
|
+
if (!parsed.isArbitrary) {
|
|
1300
|
+
const w = ringWidth(value);
|
|
1301
|
+
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1302
|
+
}
|
|
1303
|
+
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1304
|
+
if (color === null) return null;
|
|
1305
|
+
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1306
|
+
}
|
|
1307
|
+
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1308
|
+
function resolve3(parsed, theme) {
|
|
1309
|
+
switch (parsed.utility) {
|
|
1310
|
+
case "border":
|
|
1311
|
+
if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
|
|
1312
|
+
return borderValue(theme, parsed);
|
|
1313
|
+
case "border-t":
|
|
1314
|
+
return borderSideValue(theme, parsed, "border-top");
|
|
1315
|
+
case "border-r":
|
|
1316
|
+
return borderSideValue(theme, parsed, "border-right");
|
|
1317
|
+
case "border-b":
|
|
1318
|
+
return borderSideValue(theme, parsed, "border-bottom");
|
|
1319
|
+
case "border-l":
|
|
1320
|
+
return borderSideValue(theme, parsed, "border-left");
|
|
1321
|
+
case "border-x":
|
|
1322
|
+
return borderAxisValue(theme, parsed, "border-left", "border-right");
|
|
1323
|
+
case "border-y":
|
|
1324
|
+
return borderAxisValue(theme, parsed, "border-top", "border-bottom");
|
|
1325
|
+
case "rounded": {
|
|
1326
|
+
if (parsed.value === null) return [decl("border-radius", "0.25rem")];
|
|
1327
|
+
const value = parsed.value;
|
|
1328
|
+
if (!parsed.isArbitrary) {
|
|
1329
|
+
const size = radiusSize(value);
|
|
1330
|
+
if (size !== null) return [decl("border-radius", size)];
|
|
1331
|
+
}
|
|
1332
|
+
const v = resolveLength(theme, parsed);
|
|
1333
|
+
return v === null ? null : [decl("border-radius", v)];
|
|
1334
|
+
}
|
|
1335
|
+
case "ring":
|
|
1336
|
+
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1337
|
+
return ringValue(theme, parsed);
|
|
1338
|
+
case "ring-offset":
|
|
1339
|
+
return ringOffsetValue(theme, parsed);
|
|
1340
|
+
case "outline":
|
|
1341
|
+
if (parsed.value === null) return [decl("outline-style", "solid")];
|
|
1342
|
+
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1343
|
+
return outlineValue(theme, parsed);
|
|
1344
|
+
case "outline-offset":
|
|
1345
|
+
return outlineOffsetValue(parsed);
|
|
1346
|
+
default:
|
|
1347
|
+
if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
|
|
1348
|
+
return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
|
|
1349
|
+
}
|
|
1350
|
+
return null;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
// src/jsEngine/resolvers/typography.ts
|
|
1355
|
+
function textSize(key) {
|
|
1356
|
+
switch (key) {
|
|
1357
|
+
case "xs":
|
|
1358
|
+
return "0.75rem";
|
|
1359
|
+
case "sm":
|
|
1360
|
+
return "0.875rem";
|
|
1361
|
+
case "base":
|
|
1362
|
+
return "1rem";
|
|
1363
|
+
case "lg":
|
|
1364
|
+
return "1.125rem";
|
|
1365
|
+
case "xl":
|
|
1366
|
+
return "1.25rem";
|
|
1367
|
+
case "2xl":
|
|
1368
|
+
return "1.5rem";
|
|
1369
|
+
case "3xl":
|
|
1370
|
+
return "1.875rem";
|
|
1371
|
+
case "4xl":
|
|
1372
|
+
return "2.25rem";
|
|
1373
|
+
default:
|
|
1374
|
+
return null;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
function lineHeightSize(key) {
|
|
1378
|
+
switch (key) {
|
|
1379
|
+
case "3":
|
|
1380
|
+
return "0.75rem";
|
|
1381
|
+
case "4":
|
|
1382
|
+
return "1rem";
|
|
1383
|
+
case "5":
|
|
1384
|
+
return "1.25rem";
|
|
1385
|
+
case "6":
|
|
1386
|
+
return "1.5rem";
|
|
1387
|
+
case "7":
|
|
1388
|
+
return "1.75rem";
|
|
1389
|
+
case "8":
|
|
1390
|
+
return "2rem";
|
|
1391
|
+
case "9":
|
|
1392
|
+
return "2.25rem";
|
|
1393
|
+
case "10":
|
|
1394
|
+
return "2.5rem";
|
|
1395
|
+
default:
|
|
1396
|
+
return null;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
function textAlign(key) {
|
|
1400
|
+
switch (key) {
|
|
1401
|
+
case "left":
|
|
1402
|
+
return "left";
|
|
1403
|
+
case "center":
|
|
1404
|
+
return "center";
|
|
1405
|
+
case "right":
|
|
1406
|
+
return "right";
|
|
1407
|
+
case "justify":
|
|
1408
|
+
return "justify";
|
|
1409
|
+
default:
|
|
1410
|
+
return null;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
function fontWeight(key) {
|
|
1414
|
+
switch (key) {
|
|
1415
|
+
case "thin":
|
|
1416
|
+
return "100";
|
|
1417
|
+
case "normal":
|
|
1418
|
+
return "400";
|
|
1419
|
+
case "medium":
|
|
1420
|
+
return "500";
|
|
1421
|
+
case "semibold":
|
|
1422
|
+
return "600";
|
|
1423
|
+
case "bold":
|
|
1424
|
+
return "700";
|
|
1425
|
+
case "extrabold":
|
|
1426
|
+
return "800";
|
|
1427
|
+
default:
|
|
1428
|
+
return null;
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
// src/jsEngine/resolvers/effects.ts
|
|
1433
|
+
function nativeShadowValue(key) {
|
|
1434
|
+
switch (key) {
|
|
1435
|
+
case "sm":
|
|
1436
|
+
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
1437
|
+
case "DEFAULT":
|
|
1438
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1439
|
+
case "md":
|
|
1440
|
+
return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
|
|
1441
|
+
case "lg":
|
|
1442
|
+
return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
|
|
1443
|
+
case "xl":
|
|
1444
|
+
return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
|
|
1445
|
+
case "2xl":
|
|
1446
|
+
return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
|
|
1447
|
+
case "none":
|
|
1448
|
+
return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
|
|
1449
|
+
default:
|
|
1450
|
+
return null;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
function nativeShadowDeclarations(parsed) {
|
|
1454
|
+
if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
|
|
1455
|
+
const key = parsed.value ?? "DEFAULT";
|
|
1456
|
+
const s = nativeShadowValue(key);
|
|
1457
|
+
if (s === null) return null;
|
|
1458
|
+
return [
|
|
1459
|
+
decl("shadow-color", "#000000"),
|
|
1460
|
+
decl("shadow-offset-x", "0"),
|
|
1461
|
+
decl("shadow-offset-y", String(s.offsetY)),
|
|
1462
|
+
decl("shadow-opacity", String(s.opacity)),
|
|
1463
|
+
decl("shadow-radius", String(s.radius)),
|
|
1464
|
+
decl("elevation", String(s.elevation))
|
|
1465
|
+
];
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
// src/jsEngine/resolveUtilityNative.ts
|
|
1469
|
+
function resolveTypographyNative(parsed) {
|
|
1470
|
+
switch (parsed.utility) {
|
|
1471
|
+
case "font": {
|
|
1472
|
+
if (parsed.value === null) return null;
|
|
1473
|
+
const w = fontWeight(parsed.value);
|
|
1474
|
+
return w === null ? null : [decl("font-weight", w)];
|
|
1475
|
+
}
|
|
1476
|
+
case "uppercase":
|
|
1477
|
+
return [decl("text-transform", "uppercase")];
|
|
1478
|
+
case "lowercase":
|
|
1479
|
+
return [decl("text-transform", "lowercase")];
|
|
1480
|
+
case "capitalize":
|
|
1481
|
+
return [decl("text-transform", "capitalize")];
|
|
1482
|
+
case "underline":
|
|
1483
|
+
return [decl("text-decoration-line", "underline")];
|
|
1484
|
+
case "line-through":
|
|
1485
|
+
return [decl("text-decoration-line", "line-through")];
|
|
1486
|
+
case "no-underline":
|
|
1487
|
+
return [decl("text-decoration-line", "none")];
|
|
1488
|
+
case "italic":
|
|
1489
|
+
return [decl("font-style", "italic")];
|
|
1490
|
+
case "not-italic":
|
|
1491
|
+
return [decl("font-style", "normal")];
|
|
1492
|
+
default:
|
|
1493
|
+
return null;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
function resolveLeadingTrackingNative(parsed) {
|
|
1497
|
+
const value = parsed.value;
|
|
1498
|
+
if (value === null) return null;
|
|
1499
|
+
if (parsed.utility === "leading") {
|
|
1500
|
+
if (parsed.isArbitrary) return [decl("line-height", value)];
|
|
1501
|
+
const v = lineHeightSize(value);
|
|
1502
|
+
return v === null ? null : [decl("line-height", v)];
|
|
1503
|
+
}
|
|
1504
|
+
if (parsed.utility === "tracking" && parsed.isArbitrary) {
|
|
1505
|
+
return [decl("letter-spacing", value)];
|
|
1506
|
+
}
|
|
1507
|
+
return null;
|
|
1508
|
+
}
|
|
1509
|
+
function nativeHexColor(parsed, theme) {
|
|
1510
|
+
const value = parsed.value;
|
|
1511
|
+
if (value === null) return null;
|
|
1512
|
+
return parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1513
|
+
}
|
|
1514
|
+
function resolveTextNative(parsed, theme) {
|
|
1515
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1516
|
+
const size = textSize(parsed.value);
|
|
1517
|
+
if (size !== null) return [decl("font-size", size)];
|
|
1518
|
+
const align = textAlign(parsed.value);
|
|
1519
|
+
if (align !== null) return [decl("text-align", align)];
|
|
1520
|
+
}
|
|
1521
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1522
|
+
return hex === null ? null : [decl("color", hex)];
|
|
1523
|
+
}
|
|
1524
|
+
function resolveColorNative(parsed, theme) {
|
|
1525
|
+
switch (parsed.utility) {
|
|
1526
|
+
case "bg": {
|
|
1527
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1528
|
+
return hex === null ? null : [decl("background-color", hex)];
|
|
1529
|
+
}
|
|
1530
|
+
case "text":
|
|
1531
|
+
return resolveTextNative(parsed, theme);
|
|
1532
|
+
default:
|
|
1533
|
+
return null;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
function resolveUtilityNative(parsed, theme) {
|
|
1537
|
+
return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
// src/jsEngine/resolveStyle.ts
|
|
1541
|
+
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
1542
|
+
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
1543
|
+
if (modifier === "dark") return colorScheme === "dark";
|
|
1544
|
+
if (modifier === "active") return pressed;
|
|
1545
|
+
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
1546
|
+
const minWidth = theme.screens[modifier];
|
|
1547
|
+
if (minWidth === void 0) return null;
|
|
1548
|
+
return width >= minWidth;
|
|
1549
|
+
}
|
|
1550
|
+
return null;
|
|
1551
|
+
}
|
|
1552
|
+
function kebabToCamel(s) {
|
|
1553
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1554
|
+
}
|
|
1555
|
+
var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
1556
|
+
"padding",
|
|
1557
|
+
"padding-top",
|
|
1558
|
+
"padding-right",
|
|
1559
|
+
"padding-bottom",
|
|
1560
|
+
"padding-left",
|
|
1561
|
+
"margin",
|
|
1562
|
+
"margin-top",
|
|
1563
|
+
"margin-right",
|
|
1564
|
+
"margin-bottom",
|
|
1565
|
+
"margin-left",
|
|
1566
|
+
"gap",
|
|
1567
|
+
"column-gap",
|
|
1568
|
+
"row-gap",
|
|
1569
|
+
"width",
|
|
1570
|
+
"height",
|
|
1571
|
+
"min-width",
|
|
1572
|
+
"max-width",
|
|
1573
|
+
"min-height",
|
|
1574
|
+
"max-height",
|
|
1575
|
+
"top",
|
|
1576
|
+
"right",
|
|
1577
|
+
"bottom",
|
|
1578
|
+
"left",
|
|
1579
|
+
"inset",
|
|
1580
|
+
"border-radius",
|
|
1581
|
+
"border-width",
|
|
1582
|
+
"font-size",
|
|
1583
|
+
"z-index",
|
|
1584
|
+
"line-height",
|
|
1585
|
+
"letter-spacing",
|
|
1586
|
+
"flex",
|
|
1587
|
+
"flex-grow",
|
|
1588
|
+
"flex-shrink",
|
|
1589
|
+
"order",
|
|
1590
|
+
"flex-basis",
|
|
1591
|
+
"shadow-opacity",
|
|
1592
|
+
"shadow-radius",
|
|
1593
|
+
"elevation",
|
|
1594
|
+
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1595
|
+
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1596
|
+
// style system wants plain numbers for these exactly like the generic
|
|
1597
|
+
// "border-width"/"border-radius" forms above.
|
|
1598
|
+
"border-top-width",
|
|
1599
|
+
"border-right-width",
|
|
1600
|
+
"border-bottom-width",
|
|
1601
|
+
"border-left-width",
|
|
1602
|
+
"border-top-left-radius",
|
|
1603
|
+
"border-top-right-radius",
|
|
1604
|
+
"border-bottom-right-radius",
|
|
1605
|
+
"border-bottom-left-radius",
|
|
1606
|
+
"outline-width",
|
|
1607
|
+
"outline-offset"
|
|
1608
|
+
]);
|
|
1609
|
+
function rnStyleValue(property, value) {
|
|
1610
|
+
if (NUMERIC_LENGTH_PROPS.has(property)) {
|
|
1611
|
+
let px = null;
|
|
1612
|
+
if (value.endsWith("px")) {
|
|
1613
|
+
const n = Number(value.slice(0, -2));
|
|
1614
|
+
px = Number.isFinite(n) ? n : null;
|
|
1615
|
+
} else if (value.endsWith("rem")) {
|
|
1616
|
+
const n = Number(value.slice(0, -3));
|
|
1617
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
1618
|
+
} else {
|
|
1619
|
+
const n = Number(value);
|
|
1620
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
1621
|
+
}
|
|
1622
|
+
if (px !== null) return px;
|
|
1623
|
+
}
|
|
1624
|
+
return value;
|
|
1625
|
+
}
|
|
1626
|
+
function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
|
|
1627
|
+
const style = {};
|
|
1628
|
+
let shadowOffset = null;
|
|
1629
|
+
for (const token of classString.split(/\s+/).filter(Boolean)) {
|
|
1630
|
+
const parsed = parseClass(token);
|
|
1631
|
+
const allModifiersHold = parsed.modifiers.every(
|
|
1632
|
+
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
1633
|
+
);
|
|
1634
|
+
if (!allModifiersHold) continue;
|
|
1635
|
+
const decls = resolveUtilityNative(parsed, theme);
|
|
1636
|
+
if (decls === null) continue;
|
|
1637
|
+
for (const d of decls) {
|
|
1638
|
+
if (d.property.startsWith("__")) {
|
|
1639
|
+
continue;
|
|
1640
|
+
}
|
|
1641
|
+
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
1642
|
+
const n = Number(d.value);
|
|
1643
|
+
if (!Number.isFinite(n)) continue;
|
|
1644
|
+
if (shadowOffset === null) shadowOffset = {};
|
|
1645
|
+
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
1646
|
+
continue;
|
|
1647
|
+
}
|
|
1648
|
+
style[kebabToCamel(d.property)] = rnStyleValue(d.property, d.value);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
if (shadowOffset !== null) {
|
|
1652
|
+
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1653
|
+
}
|
|
1654
|
+
return style;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
// src/nativeBridge.ts
|
|
1658
|
+
function resolveStyle(classString, pressed = false) {
|
|
1659
|
+
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
1660
|
+
const width = import_react_native3.Dimensions.get("window").width;
|
|
1661
|
+
const KbachModule = import_react_native3.TurboModuleRegistry.get("KbachModule");
|
|
1662
|
+
if (!KbachModule) {
|
|
1663
|
+
return resolveStyleJs(classString, getTheme(), colorScheme, pressed, width);
|
|
1664
|
+
}
|
|
1665
|
+
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
1666
|
+
return JSON.parse(json);
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
// src/jsx-runtime.tsx
|
|
1670
|
+
var { jsx, jsxs } = createJsxFunctions(resolveStyle);
|
|
1671
|
+
|
|
1672
|
+
// src/jsx-dev-runtime.tsx
|
|
1673
|
+
var jsxDEV = createJsxDEV(jsx, jsxs);
|
|
407
1674
|
// Annotate the CommonJS export names for ESM import in node:
|
|
408
1675
|
0 && (module.exports = {
|
|
409
1676
|
Fragment,
|