tailwind-styled-v4 5.1.12 → 5.1.13
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/dist/index.browser.mjs +228 -203
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +229 -204
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +229 -204
- package/dist/index.mjs.map +1 -1
- package/dist/svelte.js +143 -136
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +143 -136
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.js +144 -137
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +144 -137
- package/dist/vue.mjs.map +1 -1
- package/native/tailwind-styled-native.linux-x64-gnu.node +0 -0
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -290,22 +290,27 @@ if (typeof window !== "undefined") {
|
|
|
290
290
|
window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
|
|
291
291
|
}
|
|
292
292
|
var _hashContainerCache = /* @__PURE__ */ new Map();
|
|
293
|
+
function _fnvHash6(s) {
|
|
294
|
+
let h = 2166136261;
|
|
295
|
+
for (let i = 0; i < s.length; i++) {
|
|
296
|
+
h ^= s.charCodeAt(i);
|
|
297
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
298
|
+
}
|
|
299
|
+
return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
|
|
300
|
+
}
|
|
293
301
|
function hashContainer(tag, container, name) {
|
|
294
302
|
const sortedKey = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
|
|
295
303
|
const cached = _hashContainerCache.get(sortedKey);
|
|
296
304
|
if (cached) return cached;
|
|
297
305
|
const native = getNativeBinding();
|
|
298
|
-
|
|
299
|
-
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
300
|
-
}
|
|
301
|
-
const id = `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
|
|
306
|
+
const id = native?.hashContent ? `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-cq-${_fnvHash6(sortedKey)}`;
|
|
302
307
|
_hashContainerCache.set(sortedKey, id);
|
|
303
308
|
return id;
|
|
304
309
|
}
|
|
305
310
|
function layoutClassesToCss(classes) {
|
|
306
311
|
const native = getNativeBinding();
|
|
307
312
|
if (!native?.layoutClassesToCss) {
|
|
308
|
-
|
|
313
|
+
return "";
|
|
309
314
|
}
|
|
310
315
|
return native.layoutClassesToCss(classes);
|
|
311
316
|
}
|
|
@@ -466,96 +471,97 @@ var FONT_WEIGHT_NAMES = /* @__PURE__ */ new Set([
|
|
|
466
471
|
var TEXT_ALIGN_VALUES = /* @__PURE__ */ new Set(["left", "center", "right", "justify", "start", "end"]);
|
|
467
472
|
var BORDER_SIDE_PREFIXES = ["t-", "r-", "b-", "l-", "x-", "y-", "s-", "e-"];
|
|
468
473
|
var BORDER_STYLE_VALUES = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none"]);
|
|
469
|
-
function conflictGroup(base) {
|
|
470
|
-
const
|
|
474
|
+
function conflictGroup(base, prefix = "") {
|
|
475
|
+
const b = prefix && base.startsWith(prefix) ? base.slice(prefix.length) : base;
|
|
476
|
+
const bracket = b.indexOf("[");
|
|
471
477
|
if (bracket !== -1) {
|
|
472
|
-
const
|
|
473
|
-
return
|
|
474
|
-
}
|
|
475
|
-
if (DISPLAY_VALUES.has(
|
|
476
|
-
if (POSITION_VALUES.has(
|
|
477
|
-
if (
|
|
478
|
-
if (
|
|
479
|
-
if (
|
|
480
|
-
if (
|
|
481
|
-
if (
|
|
482
|
-
if (
|
|
483
|
-
if (
|
|
484
|
-
if (
|
|
485
|
-
if (
|
|
486
|
-
if (
|
|
487
|
-
if (
|
|
488
|
-
if (
|
|
489
|
-
if (
|
|
490
|
-
if (
|
|
491
|
-
if (
|
|
492
|
-
if (
|
|
493
|
-
if (
|
|
494
|
-
if (
|
|
495
|
-
if (
|
|
496
|
-
if (
|
|
497
|
-
if (
|
|
498
|
-
if (
|
|
499
|
-
if (
|
|
500
|
-
if (
|
|
501
|
-
if (
|
|
502
|
-
if (
|
|
503
|
-
if (
|
|
504
|
-
if (
|
|
505
|
-
if (
|
|
506
|
-
if (
|
|
507
|
-
if (
|
|
508
|
-
if (
|
|
509
|
-
if (
|
|
510
|
-
if (
|
|
511
|
-
if (
|
|
512
|
-
if (
|
|
513
|
-
if (
|
|
514
|
-
if (
|
|
515
|
-
if (
|
|
516
|
-
if (
|
|
517
|
-
if (
|
|
518
|
-
if (
|
|
519
|
-
if (
|
|
520
|
-
if (
|
|
521
|
-
if (
|
|
522
|
-
if (
|
|
523
|
-
if (
|
|
524
|
-
if (
|
|
525
|
-
if (
|
|
526
|
-
if (
|
|
527
|
-
if (
|
|
528
|
-
if (
|
|
529
|
-
if (
|
|
530
|
-
if (
|
|
531
|
-
if (
|
|
532
|
-
if (
|
|
533
|
-
if (
|
|
534
|
-
if (
|
|
535
|
-
if (
|
|
536
|
-
if (
|
|
537
|
-
if (
|
|
478
|
+
const grp = b.slice(0, bracket).replace(/-+$/, "");
|
|
479
|
+
return grp.length > 0 ? grp : "arbitrary";
|
|
480
|
+
}
|
|
481
|
+
if (DISPLAY_VALUES.has(b)) return "display";
|
|
482
|
+
if (POSITION_VALUES.has(b)) return "position";
|
|
483
|
+
if (b.startsWith("overflow-x-")) return "overflow-x";
|
|
484
|
+
if (b.startsWith("overflow-y-")) return "overflow-y";
|
|
485
|
+
if (b.startsWith("overflow-")) return "overflow";
|
|
486
|
+
if (b.startsWith("flex-")) return "flex";
|
|
487
|
+
if (b.startsWith("grid-cols-")) return "grid-cols";
|
|
488
|
+
if (b.startsWith("grid-rows-")) return "grid-rows";
|
|
489
|
+
if (b.startsWith("grid-flow-")) return "grid-flow";
|
|
490
|
+
if (b.startsWith("col-")) return "col";
|
|
491
|
+
if (b.startsWith("row-")) return "row";
|
|
492
|
+
if (b === "grow" || b.startsWith("grow-")) return "grow";
|
|
493
|
+
if (b === "shrink" || b.startsWith("shrink-")) return "shrink";
|
|
494
|
+
if (b.startsWith("gap-x-")) return "gap-x";
|
|
495
|
+
if (b.startsWith("gap-y-")) return "gap-y";
|
|
496
|
+
if (b.startsWith("gap-")) return "gap";
|
|
497
|
+
if (b.startsWith("justify-items-")) return "justify-items";
|
|
498
|
+
if (b.startsWith("justify-self-")) return "justify-self";
|
|
499
|
+
if (b.startsWith("justify-")) return "justify";
|
|
500
|
+
if (b.startsWith("items-")) return "items";
|
|
501
|
+
if (b.startsWith("self-")) return "self";
|
|
502
|
+
if (b.startsWith("place-content-")) return "place-content";
|
|
503
|
+
if (b.startsWith("place-items-")) return "place-items";
|
|
504
|
+
if (b.startsWith("place-self-")) return "place-self";
|
|
505
|
+
if (b.startsWith("content-")) return "content";
|
|
506
|
+
if (b.startsWith("px-")) return "px";
|
|
507
|
+
if (b.startsWith("py-")) return "py";
|
|
508
|
+
if (b.startsWith("pt-")) return "pt";
|
|
509
|
+
if (b.startsWith("pr-")) return "pr";
|
|
510
|
+
if (b.startsWith("pb-")) return "pb";
|
|
511
|
+
if (b.startsWith("pl-")) return "pl";
|
|
512
|
+
if (b.startsWith("ps-")) return "ps";
|
|
513
|
+
if (b.startsWith("pe-")) return "pe";
|
|
514
|
+
if (b.startsWith("p-")) return "p";
|
|
515
|
+
if (b.startsWith("mx-")) return "mx";
|
|
516
|
+
if (b.startsWith("my-")) return "my";
|
|
517
|
+
if (b.startsWith("mt-")) return "mt";
|
|
518
|
+
if (b.startsWith("mr-")) return "mr";
|
|
519
|
+
if (b.startsWith("mb-")) return "mb";
|
|
520
|
+
if (b.startsWith("ml-")) return "ml";
|
|
521
|
+
if (b.startsWith("ms-")) return "ms";
|
|
522
|
+
if (b.startsWith("me-")) return "me";
|
|
523
|
+
if (b === "-m" || b.startsWith("m-") || b.startsWith("-m-")) return "m";
|
|
524
|
+
if (b.startsWith("space-x-")) return "space-x";
|
|
525
|
+
if (b.startsWith("space-y-")) return "space-y";
|
|
526
|
+
if (b.startsWith("size-")) return "size";
|
|
527
|
+
if (b.startsWith("min-w-")) return "min-w";
|
|
528
|
+
if (b.startsWith("max-w-")) return "max-w";
|
|
529
|
+
if (b.startsWith("w-")) return "w";
|
|
530
|
+
if (b.startsWith("min-h-")) return "min-h";
|
|
531
|
+
if (b.startsWith("max-h-")) return "max-h";
|
|
532
|
+
if (b.startsWith("h-")) return "h";
|
|
533
|
+
if (b.startsWith("inset-x-")) return "inset-x";
|
|
534
|
+
if (b.startsWith("inset-y-")) return "inset-y";
|
|
535
|
+
if (b.startsWith("inset-")) return "inset";
|
|
536
|
+
if (b.startsWith("top-")) return "top";
|
|
537
|
+
if (b.startsWith("right-") || b.startsWith("end-")) return "right";
|
|
538
|
+
if (b.startsWith("bottom-")) return "bottom";
|
|
539
|
+
if (b.startsWith("left-") || b.startsWith("start-")) return "left";
|
|
540
|
+
if (b.startsWith("z-")) return "z";
|
|
541
|
+
if (b.startsWith("opacity-")) return "opacity";
|
|
542
|
+
if (b.startsWith("bg-")) {
|
|
543
|
+
if (b.startsWith("bg-opacity-")) return "bg-opacity";
|
|
538
544
|
return "bg";
|
|
539
545
|
}
|
|
540
|
-
if (
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
543
|
-
if (
|
|
544
|
-
const suffix =
|
|
546
|
+
if (b.startsWith("from-")) return "from";
|
|
547
|
+
if (b.startsWith("via-")) return "via";
|
|
548
|
+
if (b.startsWith("to-")) return "to";
|
|
549
|
+
if (b.startsWith("text-")) {
|
|
550
|
+
const suffix = b.slice("text-".length);
|
|
545
551
|
if (isTextSize(suffix)) return "text-size";
|
|
546
552
|
if (suffix.startsWith("opacity-")) return "text-opacity";
|
|
547
553
|
if (TEXT_ALIGN_VALUES.has(suffix)) return "text-align";
|
|
548
554
|
return "text-color";
|
|
549
555
|
}
|
|
550
|
-
if (
|
|
551
|
-
const suffix =
|
|
556
|
+
if (b.startsWith("font-")) {
|
|
557
|
+
const suffix = b.slice("font-".length);
|
|
552
558
|
if (FONT_WEIGHT_NAMES.has(suffix) || isAsciiDigits(suffix)) return "font-weight";
|
|
553
559
|
return "font-family";
|
|
554
560
|
}
|
|
555
|
-
if (
|
|
556
|
-
if (
|
|
557
|
-
if (
|
|
558
|
-
const suffix =
|
|
561
|
+
if (b.startsWith("leading-")) return "leading";
|
|
562
|
+
if (b.startsWith("tracking-")) return "tracking";
|
|
563
|
+
if (b.startsWith("border-")) {
|
|
564
|
+
const suffix = b.slice("border-".length);
|
|
559
565
|
const sidePrefix = BORDER_SIDE_PREFIXES.find((p) => suffix.startsWith(p));
|
|
560
566
|
if (sidePrefix) {
|
|
561
567
|
const side = suffix.slice(0, 1);
|
|
@@ -569,67 +575,67 @@ function conflictGroup(base) {
|
|
|
569
575
|
if (BORDER_STYLE_VALUES.has(suffix)) return "border-style";
|
|
570
576
|
return "border-color";
|
|
571
577
|
}
|
|
572
|
-
if (
|
|
573
|
-
if (
|
|
574
|
-
if (
|
|
575
|
-
if (
|
|
576
|
-
const firstChar =
|
|
578
|
+
if (b === "border") return "border-width";
|
|
579
|
+
if (b.startsWith("outline-")) return "outline";
|
|
580
|
+
if (b === "outline") return "outline";
|
|
581
|
+
if (b.startsWith("rounded-t") || b.startsWith("rounded-r") || b.startsWith("rounded-b") || b.startsWith("rounded-l") || b.startsWith("rounded-s") || b.startsWith("rounded-e")) {
|
|
582
|
+
const firstChar = b.slice("rounded-".length).charAt(0) || "x";
|
|
577
583
|
return `rounded-${firstChar}`;
|
|
578
584
|
}
|
|
579
|
-
if (
|
|
580
|
-
if (
|
|
581
|
-
if (
|
|
582
|
-
if (
|
|
583
|
-
if (
|
|
584
|
-
const rest =
|
|
585
|
+
if (b === "rounded" || b.startsWith("rounded-")) return "rounded";
|
|
586
|
+
if (b === "shadow" || b.startsWith("shadow-")) return "shadow";
|
|
587
|
+
if (b.startsWith("ring-offset-")) return "ring-offset";
|
|
588
|
+
if (b === "ring") return "ring-width";
|
|
589
|
+
if (b.startsWith("ring-")) {
|
|
590
|
+
const rest = b.slice("ring-".length);
|
|
585
591
|
const isWidth = rest === "0" || rest === "1" || rest === "2" || rest === "4" || rest === "8" || /^-?\d+(\.\d+)?$/.test(rest) || rest.startsWith("[") && rest.endsWith("]");
|
|
586
592
|
if (isWidth) return "ring-width";
|
|
587
593
|
if (rest === "inset") return "ring-inset";
|
|
588
594
|
return "ring-color";
|
|
589
595
|
}
|
|
590
|
-
if (
|
|
591
|
-
if (
|
|
592
|
-
if (
|
|
593
|
-
if (
|
|
594
|
-
if (
|
|
595
|
-
if (
|
|
596
|
-
if (
|
|
597
|
-
if (
|
|
598
|
-
if (
|
|
599
|
-
if (
|
|
600
|
-
if (
|
|
601
|
-
if (
|
|
602
|
-
if (
|
|
603
|
-
if (
|
|
604
|
-
if (
|
|
605
|
-
if (
|
|
606
|
-
if (
|
|
607
|
-
if (
|
|
608
|
-
if (
|
|
609
|
-
if (
|
|
610
|
-
if (
|
|
611
|
-
if (
|
|
612
|
-
if (
|
|
613
|
-
if (
|
|
614
|
-
if (
|
|
615
|
-
const rest =
|
|
596
|
+
if (b.startsWith("rotate-")) return "rotate";
|
|
597
|
+
if (b.startsWith("scale-x-")) return "scale-x";
|
|
598
|
+
if (b.startsWith("scale-y-")) return "scale-y";
|
|
599
|
+
if (b.startsWith("scale-")) return "scale";
|
|
600
|
+
if (b.startsWith("translate-x-")) return "translate-x";
|
|
601
|
+
if (b.startsWith("translate-y-")) return "translate-y";
|
|
602
|
+
if (b.startsWith("skew-x-")) return "skew-x";
|
|
603
|
+
if (b.startsWith("skew-y-")) return "skew-y";
|
|
604
|
+
if (b === "transition" || b.startsWith("transition-")) return "transition";
|
|
605
|
+
if (b.startsWith("duration-")) return "duration";
|
|
606
|
+
if (b.startsWith("ease-")) return "ease";
|
|
607
|
+
if (b.startsWith("delay-")) return "delay";
|
|
608
|
+
if (b === "animate" || b.startsWith("animate-")) return "animate";
|
|
609
|
+
if (b.startsWith("cursor-")) return "cursor";
|
|
610
|
+
if (b.startsWith("pointer-events-")) return "pointer-events";
|
|
611
|
+
if (b.startsWith("select-")) return "select";
|
|
612
|
+
if (b === "visible" || b === "invisible" || b === "collapse") return "visibility";
|
|
613
|
+
if (b.startsWith("object-")) return "object";
|
|
614
|
+
if (b.startsWith("aspect-")) return "aspect";
|
|
615
|
+
if (b.startsWith("order-")) return "order";
|
|
616
|
+
if (b.startsWith("whitespace-")) return "whitespace";
|
|
617
|
+
if (b.startsWith("list-")) return "list";
|
|
618
|
+
if (b.startsWith("fill-")) return "fill";
|
|
619
|
+
if (b.startsWith("stroke-")) return "stroke";
|
|
620
|
+
if (b.startsWith("backdrop-")) {
|
|
621
|
+
const rest = b.slice("backdrop-".length);
|
|
616
622
|
const seg = rest.split("-")[0] || "x";
|
|
617
623
|
return `backdrop-${seg}`;
|
|
618
624
|
}
|
|
619
|
-
if (
|
|
620
|
-
if (
|
|
621
|
-
if (
|
|
622
|
-
if (
|
|
623
|
-
if (
|
|
624
|
-
if (
|
|
625
|
-
if (
|
|
626
|
-
if (
|
|
627
|
-
if (
|
|
628
|
-
if (
|
|
629
|
-
if (
|
|
630
|
-
if (
|
|
631
|
-
if (
|
|
632
|
-
if (
|
|
625
|
+
if (b.startsWith("scroll-")) return "scroll";
|
|
626
|
+
if (b.startsWith("snap-")) return "snap";
|
|
627
|
+
if (b.startsWith("touch-")) return "touch";
|
|
628
|
+
if (b.startsWith("decoration-")) return "text-decoration";
|
|
629
|
+
if (b.startsWith("caret-")) return "caret";
|
|
630
|
+
if (b.startsWith("accent-")) return "accent";
|
|
631
|
+
if (b.startsWith("appearance-")) return "appearance";
|
|
632
|
+
if (b === "isolate" || b === "isolation-auto") return "isolation";
|
|
633
|
+
if (b.startsWith("mix-blend-")) return "mix-blend";
|
|
634
|
+
if (b.startsWith("bg-blend-")) return "bg-blend";
|
|
635
|
+
if (b.startsWith("float-")) return "float";
|
|
636
|
+
if (b.startsWith("clear-")) return "clear";
|
|
637
|
+
if (b.startsWith("break-")) return "break";
|
|
638
|
+
if (b.startsWith("columns-")) return "columns";
|
|
633
639
|
return null;
|
|
634
640
|
}
|
|
635
641
|
function splitVariants(klass) {
|
|
@@ -644,7 +650,7 @@ function splitVariants(klass) {
|
|
|
644
650
|
if (lastColon === 0) return ["", klass];
|
|
645
651
|
return [klass.slice(0, lastColon), klass.slice(lastColon)];
|
|
646
652
|
}
|
|
647
|
-
function mergeClassStringJs(input) {
|
|
653
|
+
function mergeClassStringJs(input, prefix = "") {
|
|
648
654
|
const tokens = input.split(/\s+/).filter(Boolean);
|
|
649
655
|
if (tokens.length === 0) return "";
|
|
650
656
|
if (tokens.length === 1) return tokens[0];
|
|
@@ -652,7 +658,7 @@ function mergeClassStringJs(input) {
|
|
|
652
658
|
const slots = [];
|
|
653
659
|
for (const token of tokens) {
|
|
654
660
|
const [variants, base] = splitVariants(token);
|
|
655
|
-
const group = conflictGroup(base);
|
|
661
|
+
const group = conflictGroup(base, prefix);
|
|
656
662
|
if (group !== null) {
|
|
657
663
|
const key = `${variants}::${group}`;
|
|
658
664
|
const prevIdx = groupOwner.get(key);
|
|
@@ -665,10 +671,10 @@ function mergeClassStringJs(input) {
|
|
|
665
671
|
}
|
|
666
672
|
return slots.filter((s) => s !== null).join(" ");
|
|
667
673
|
}
|
|
668
|
-
function twMergeRawJs(classLists) {
|
|
674
|
+
function twMergeRawJs(classLists, prefix = "") {
|
|
669
675
|
const joined = classLists.map((s) => s.trim()).filter((s) => s.length > 0).join(" ");
|
|
670
676
|
if (joined.length === 0) return "";
|
|
671
|
-
return mergeClassStringJs(joined);
|
|
677
|
+
return mergeClassStringJs(joined, prefix);
|
|
672
678
|
}
|
|
673
679
|
|
|
674
680
|
// packages/domain/core/src/merge.ts
|
|
@@ -683,6 +689,7 @@ function warnFallbackOnce() {
|
|
|
683
689
|
}
|
|
684
690
|
}
|
|
685
691
|
function createTwMerge(options = {}) {
|
|
692
|
+
const prefix = options.prefix ?? "";
|
|
686
693
|
return function twMerge2(...classLists) {
|
|
687
694
|
const inputs = [];
|
|
688
695
|
for (let i = 0; i < classLists.length; i++) {
|
|
@@ -691,11 +698,16 @@ function createTwMerge(options = {}) {
|
|
|
691
698
|
}
|
|
692
699
|
if (inputs.length === 0) return "";
|
|
693
700
|
const native = getNativeBinding();
|
|
694
|
-
if (native
|
|
695
|
-
|
|
701
|
+
if (native) {
|
|
702
|
+
if (prefix && native.twMergeRawWithOptions) {
|
|
703
|
+
return native.twMergeRawWithOptions(inputs, { prefix });
|
|
704
|
+
}
|
|
705
|
+
if (native.twMergeRaw) {
|
|
706
|
+
return native.twMergeRaw(inputs);
|
|
707
|
+
}
|
|
696
708
|
}
|
|
697
709
|
warnFallbackOnce();
|
|
698
|
-
return twMergeRawJs(inputs);
|
|
710
|
+
return twMergeRawJs(inputs, prefix);
|
|
699
711
|
};
|
|
700
712
|
}
|
|
701
713
|
var twMerge = createTwMerge();
|
|
@@ -708,6 +720,37 @@ function mergeWithRules(rules, ...classLists) {
|
|
|
708
720
|
return classes.join(" ");
|
|
709
721
|
}
|
|
710
722
|
|
|
723
|
+
// packages/domain/core/src/parseTemplateFallback.ts
|
|
724
|
+
init_cjs_shims();
|
|
725
|
+
var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
|
|
726
|
+
var COMMENT_RE = /\/\/[^\n]*/g;
|
|
727
|
+
function collapseSpaces(s) {
|
|
728
|
+
return s.replace(/\s+/g, " ").trim();
|
|
729
|
+
}
|
|
730
|
+
function cleanBlock(raw) {
|
|
731
|
+
const noComments = raw.replace(COMMENT_RE, "");
|
|
732
|
+
const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
733
|
+
return collapseSpaces(lines.join(" "));
|
|
734
|
+
}
|
|
735
|
+
function parseTemplateJs(raw) {
|
|
736
|
+
const subs = {};
|
|
737
|
+
let base = raw;
|
|
738
|
+
for (const match of raw.matchAll(SUB_RE)) {
|
|
739
|
+
const fullMatch = match[0];
|
|
740
|
+
const name = match[1] ?? match[2] ?? "";
|
|
741
|
+
const innerRaw = match[3] ?? "";
|
|
742
|
+
if (name) {
|
|
743
|
+
subs[name] = cleanBlock(innerRaw);
|
|
744
|
+
}
|
|
745
|
+
base = base.replace(fullMatch, "");
|
|
746
|
+
}
|
|
747
|
+
return {
|
|
748
|
+
base: collapseSpaces(base),
|
|
749
|
+
subs,
|
|
750
|
+
hasSubs: Object.keys(subs).length > 0
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
|
|
711
754
|
// packages/domain/core/src/stateEngine.ts
|
|
712
755
|
init_cjs_shims();
|
|
713
756
|
var stateRegistry = /* @__PURE__ */ new Map();
|
|
@@ -715,22 +758,27 @@ if (typeof window !== "undefined") {
|
|
|
715
758
|
window.__TW_STATE_REGISTRY__ = stateRegistry;
|
|
716
759
|
}
|
|
717
760
|
var _hashStateCache = /* @__PURE__ */ new Map();
|
|
761
|
+
function _fnvHash62(s) {
|
|
762
|
+
let h = 2166136261;
|
|
763
|
+
for (let i = 0; i < s.length; i++) {
|
|
764
|
+
h ^= s.charCodeAt(i);
|
|
765
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
766
|
+
}
|
|
767
|
+
return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
|
|
768
|
+
}
|
|
718
769
|
function hashState(tag, state) {
|
|
719
770
|
const sortedKey = tag + JSON.stringify(Object.entries(state).sort());
|
|
720
771
|
const cached = _hashStateCache.get(sortedKey);
|
|
721
772
|
if (cached) return cached;
|
|
722
773
|
const native = getNativeBinding();
|
|
723
|
-
|
|
724
|
-
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
725
|
-
}
|
|
726
|
-
const id = `tw-s-${native.hashContent(sortedKey, "fnv", 6)}`;
|
|
774
|
+
const id = native?.hashContent ? `tw-s-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-s-${_fnvHash62(sortedKey)}`;
|
|
727
775
|
_hashStateCache.set(sortedKey, id);
|
|
728
776
|
return id;
|
|
729
777
|
}
|
|
730
778
|
function generateStateRules(id, state) {
|
|
731
779
|
const native = getNativeBinding();
|
|
732
780
|
if (!native?.generateRuntimeStateCss) {
|
|
733
|
-
|
|
781
|
+
return [];
|
|
734
782
|
}
|
|
735
783
|
return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
|
|
736
784
|
}
|
|
@@ -818,7 +866,13 @@ function _getParsedTemplate(template) {
|
|
|
818
866
|
}
|
|
819
867
|
const native = getNativeBinding();
|
|
820
868
|
if (!native?.parseSubcomponentBlocksNapi) {
|
|
821
|
-
|
|
869
|
+
const fb = parseTemplateJs(template);
|
|
870
|
+
const result2 = {
|
|
871
|
+
baseClasses: fb.base,
|
|
872
|
+
subMap: new Map(Object.entries(fb.subs))
|
|
873
|
+
};
|
|
874
|
+
_templateParseCache.set(template, result2);
|
|
875
|
+
return result2;
|
|
822
876
|
}
|
|
823
877
|
const r = native.parseSubcomponentBlocksNapi(template, "tw");
|
|
824
878
|
const raw = JSON.parse(r.subMapJson);
|
|
@@ -970,10 +1024,16 @@ function resolveVariants(variants, props, defaults) {
|
|
|
970
1024
|
}
|
|
971
1025
|
const binding = getNativeBinding();
|
|
972
1026
|
if (!binding?.resolveSimpleVariants) {
|
|
973
|
-
|
|
1027
|
+
const classes = [];
|
|
1028
|
+
for (const key of Object.keys(variants)) {
|
|
1029
|
+
const propValue = cleanProps[key] ?? defaults[key];
|
|
1030
|
+
if (propValue !== void 0 && variants[key]?.[propValue]) {
|
|
1031
|
+
classes.push(variants[key][propValue]);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
return classes.join(" ").trim().replace(/\s+/g, " ");
|
|
974
1035
|
}
|
|
975
|
-
|
|
976
|
-
return result.trim().replace(/\s+/g, " ");
|
|
1036
|
+
return binding.resolveSimpleVariants(null, variants, defaults, cleanProps).trim().replace(/\s+/g, " ");
|
|
977
1037
|
}
|
|
978
1038
|
function resolveStates(statesConfig, stateKeys, statesLookup, props) {
|
|
979
1039
|
if (statesLookup && stateKeys.length > 0) {
|
|
@@ -1185,49 +1245,8 @@ function wrapWithSubProxy(component, tagLabel) {
|
|
|
1185
1245
|
});
|
|
1186
1246
|
}
|
|
1187
1247
|
|
|
1188
|
-
// packages/domain/core/src/parseTemplateFallback.ts
|
|
1189
|
-
init_cjs_shims();
|
|
1190
|
-
var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
|
|
1191
|
-
var COMMENT_RE = /\/\/[^\n]*/g;
|
|
1192
|
-
function collapseSpaces(s) {
|
|
1193
|
-
return s.replace(/\s+/g, " ").trim();
|
|
1194
|
-
}
|
|
1195
|
-
function cleanBlock(raw) {
|
|
1196
|
-
const noComments = raw.replace(COMMENT_RE, "");
|
|
1197
|
-
const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
1198
|
-
return collapseSpaces(lines.join(" "));
|
|
1199
|
-
}
|
|
1200
|
-
function parseTemplateJs(raw) {
|
|
1201
|
-
const subs = {};
|
|
1202
|
-
let base = raw;
|
|
1203
|
-
for (const match of raw.matchAll(SUB_RE)) {
|
|
1204
|
-
const fullMatch = match[0];
|
|
1205
|
-
const name = match[1] ?? match[2] ?? "";
|
|
1206
|
-
const innerRaw = match[3] ?? "";
|
|
1207
|
-
if (name) {
|
|
1208
|
-
subs[name] = cleanBlock(innerRaw);
|
|
1209
|
-
}
|
|
1210
|
-
base = base.replace(fullMatch, "");
|
|
1211
|
-
}
|
|
1212
|
-
return {
|
|
1213
|
-
base: cleanBlock(base),
|
|
1214
|
-
subs,
|
|
1215
|
-
hasSubs: Object.keys(subs).length > 0
|
|
1216
|
-
};
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
1248
|
// packages/domain/core/src/twProxy.ts
|
|
1220
1249
|
var _parsedTemplateCache = /* @__PURE__ */ new Map();
|
|
1221
|
-
var warnedParseTemplateFallback = false;
|
|
1222
|
-
function warnParseTemplateFallbackOnce() {
|
|
1223
|
-
if (warnedParseTemplateFallback) return;
|
|
1224
|
-
warnedParseTemplateFallback = true;
|
|
1225
|
-
if (typeof console !== "undefined") {
|
|
1226
|
-
console.warn(
|
|
1227
|
-
"[tailwind-styled-v4] Native binding 'parseTemplate' tidak tersedia (normal di browser, untuk komponen yang di-chain dengan .extend/.withVariants/.animate/.withSub) \u2014 pakai pure-TS port dari algoritma Rust-nya. Hasil tetap benar; ini cuma informasi, bukan error."
|
|
1228
|
-
);
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
1250
|
function parseTemplate(strings, exprs) {
|
|
1232
1251
|
const raw = strings.raw.reduce((acc, str, i) => {
|
|
1233
1252
|
const expr = exprs[i];
|
|
@@ -1237,15 +1256,15 @@ function parseTemplate(strings, exprs) {
|
|
|
1237
1256
|
const cached = _parsedTemplateCache.get(raw);
|
|
1238
1257
|
if (cached) return cached;
|
|
1239
1258
|
const binding = getNativeBinding();
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
const
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
} else {
|
|
1246
|
-
warnParseTemplateFallbackOnce();
|
|
1247
|
-
result = parseTemplateJs(raw);
|
|
1259
|
+
if (!binding?.parseTemplate) {
|
|
1260
|
+
const fb = parseTemplateJs(raw);
|
|
1261
|
+
const result2 = { base: fb.base, subs: fb.subs, hasSubs: fb.hasSubs };
|
|
1262
|
+
_parsedTemplateCache.set(raw, result2);
|
|
1263
|
+
return result2;
|
|
1248
1264
|
}
|
|
1265
|
+
const r = binding.parseTemplate(raw);
|
|
1266
|
+
const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
|
|
1267
|
+
const result = { base: r.base, subs, hasSubs: r.hasSubs };
|
|
1249
1268
|
_parsedTemplateCache.set(raw, result);
|
|
1250
1269
|
return result;
|
|
1251
1270
|
}
|
|
@@ -1558,19 +1577,25 @@ function cn(...inputs) {
|
|
|
1558
1577
|
}
|
|
1559
1578
|
if (strings.length === 0) return "";
|
|
1560
1579
|
const native = getNativeBinding();
|
|
1561
|
-
if (
|
|
1580
|
+
if (native?.resolveClassNames) {
|
|
1581
|
+
return native.resolveClassNames(strings);
|
|
1582
|
+
}
|
|
1583
|
+
if (native !== null) {
|
|
1562
1584
|
throw new Error("Native binding 'resolveClassNames' is required but not available.");
|
|
1563
1585
|
}
|
|
1564
|
-
return
|
|
1586
|
+
return strings.filter(Boolean).join(" ");
|
|
1565
1587
|
}
|
|
1566
1588
|
function cx(...inputs) {
|
|
1567
1589
|
const filtered = inputs.flat().filter(Boolean);
|
|
1568
1590
|
if (filtered.length === 0) return "";
|
|
1569
1591
|
const native = getNativeBinding();
|
|
1570
|
-
if (
|
|
1592
|
+
if (native?.twMergeMany) {
|
|
1593
|
+
return native.twMergeMany(filtered);
|
|
1594
|
+
}
|
|
1595
|
+
if (native !== null) {
|
|
1571
1596
|
throw new Error("Native binding 'twMergeMany' is required but not available.");
|
|
1572
1597
|
}
|
|
1573
|
-
return
|
|
1598
|
+
return twMergeRawJs(filtered);
|
|
1574
1599
|
}
|
|
1575
1600
|
var cxm = cx;
|
|
1576
1601
|
|