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