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