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.mjs
CHANGED
|
@@ -224,22 +224,27 @@ if (typeof window !== "undefined") {
|
|
|
224
224
|
window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
|
|
225
225
|
}
|
|
226
226
|
var _hashContainerCache = /* @__PURE__ */ new Map();
|
|
227
|
+
function _fnvHash6(s) {
|
|
228
|
+
let h = 2166136261;
|
|
229
|
+
for (let i = 0; i < s.length; i++) {
|
|
230
|
+
h ^= s.charCodeAt(i);
|
|
231
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
232
|
+
}
|
|
233
|
+
return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
|
|
234
|
+
}
|
|
227
235
|
function hashContainer(tag, container, name) {
|
|
228
236
|
const sortedKey = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
|
|
229
237
|
const cached = _hashContainerCache.get(sortedKey);
|
|
230
238
|
if (cached) return cached;
|
|
231
239
|
const native = getNativeBinding();
|
|
232
|
-
|
|
233
|
-
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
234
|
-
}
|
|
235
|
-
const id = `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
|
|
240
|
+
const id = native?.hashContent ? `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-cq-${_fnvHash6(sortedKey)}`;
|
|
236
241
|
_hashContainerCache.set(sortedKey, id);
|
|
237
242
|
return id;
|
|
238
243
|
}
|
|
239
244
|
function layoutClassesToCss(classes) {
|
|
240
245
|
const native = getNativeBinding();
|
|
241
246
|
if (!native?.layoutClassesToCss) {
|
|
242
|
-
|
|
247
|
+
return "";
|
|
243
248
|
}
|
|
244
249
|
return native.layoutClassesToCss(classes);
|
|
245
250
|
}
|
|
@@ -400,96 +405,97 @@ var FONT_WEIGHT_NAMES = /* @__PURE__ */ new Set([
|
|
|
400
405
|
var TEXT_ALIGN_VALUES = /* @__PURE__ */ new Set(["left", "center", "right", "justify", "start", "end"]);
|
|
401
406
|
var BORDER_SIDE_PREFIXES = ["t-", "r-", "b-", "l-", "x-", "y-", "s-", "e-"];
|
|
402
407
|
var BORDER_STYLE_VALUES = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none"]);
|
|
403
|
-
function conflictGroup(base) {
|
|
404
|
-
const
|
|
408
|
+
function conflictGroup(base, prefix = "") {
|
|
409
|
+
const b = prefix && base.startsWith(prefix) ? base.slice(prefix.length) : base;
|
|
410
|
+
const bracket = b.indexOf("[");
|
|
405
411
|
if (bracket !== -1) {
|
|
406
|
-
const
|
|
407
|
-
return
|
|
408
|
-
}
|
|
409
|
-
if (DISPLAY_VALUES.has(
|
|
410
|
-
if (POSITION_VALUES.has(
|
|
411
|
-
if (
|
|
412
|
-
if (
|
|
413
|
-
if (
|
|
414
|
-
if (
|
|
415
|
-
if (
|
|
416
|
-
if (
|
|
417
|
-
if (
|
|
418
|
-
if (
|
|
419
|
-
if (
|
|
420
|
-
if (
|
|
421
|
-
if (
|
|
422
|
-
if (
|
|
423
|
-
if (
|
|
424
|
-
if (
|
|
425
|
-
if (
|
|
426
|
-
if (
|
|
427
|
-
if (
|
|
428
|
-
if (
|
|
429
|
-
if (
|
|
430
|
-
if (
|
|
431
|
-
if (
|
|
432
|
-
if (
|
|
433
|
-
if (
|
|
434
|
-
if (
|
|
435
|
-
if (
|
|
436
|
-
if (
|
|
437
|
-
if (
|
|
438
|
-
if (
|
|
439
|
-
if (
|
|
440
|
-
if (
|
|
441
|
-
if (
|
|
442
|
-
if (
|
|
443
|
-
if (
|
|
444
|
-
if (
|
|
445
|
-
if (
|
|
446
|
-
if (
|
|
447
|
-
if (
|
|
448
|
-
if (
|
|
449
|
-
if (
|
|
450
|
-
if (
|
|
451
|
-
if (
|
|
452
|
-
if (
|
|
453
|
-
if (
|
|
454
|
-
if (
|
|
455
|
-
if (
|
|
456
|
-
if (
|
|
457
|
-
if (
|
|
458
|
-
if (
|
|
459
|
-
if (
|
|
460
|
-
if (
|
|
461
|
-
if (
|
|
462
|
-
if (
|
|
463
|
-
if (
|
|
464
|
-
if (
|
|
465
|
-
if (
|
|
466
|
-
if (
|
|
467
|
-
if (
|
|
468
|
-
if (
|
|
469
|
-
if (
|
|
470
|
-
if (
|
|
471
|
-
if (
|
|
412
|
+
const grp = b.slice(0, bracket).replace(/-+$/, "");
|
|
413
|
+
return grp.length > 0 ? grp : "arbitrary";
|
|
414
|
+
}
|
|
415
|
+
if (DISPLAY_VALUES.has(b)) return "display";
|
|
416
|
+
if (POSITION_VALUES.has(b)) return "position";
|
|
417
|
+
if (b.startsWith("overflow-x-")) return "overflow-x";
|
|
418
|
+
if (b.startsWith("overflow-y-")) return "overflow-y";
|
|
419
|
+
if (b.startsWith("overflow-")) return "overflow";
|
|
420
|
+
if (b.startsWith("flex-")) return "flex";
|
|
421
|
+
if (b.startsWith("grid-cols-")) return "grid-cols";
|
|
422
|
+
if (b.startsWith("grid-rows-")) return "grid-rows";
|
|
423
|
+
if (b.startsWith("grid-flow-")) return "grid-flow";
|
|
424
|
+
if (b.startsWith("col-")) return "col";
|
|
425
|
+
if (b.startsWith("row-")) return "row";
|
|
426
|
+
if (b === "grow" || b.startsWith("grow-")) return "grow";
|
|
427
|
+
if (b === "shrink" || b.startsWith("shrink-")) return "shrink";
|
|
428
|
+
if (b.startsWith("gap-x-")) return "gap-x";
|
|
429
|
+
if (b.startsWith("gap-y-")) return "gap-y";
|
|
430
|
+
if (b.startsWith("gap-")) return "gap";
|
|
431
|
+
if (b.startsWith("justify-items-")) return "justify-items";
|
|
432
|
+
if (b.startsWith("justify-self-")) return "justify-self";
|
|
433
|
+
if (b.startsWith("justify-")) return "justify";
|
|
434
|
+
if (b.startsWith("items-")) return "items";
|
|
435
|
+
if (b.startsWith("self-")) return "self";
|
|
436
|
+
if (b.startsWith("place-content-")) return "place-content";
|
|
437
|
+
if (b.startsWith("place-items-")) return "place-items";
|
|
438
|
+
if (b.startsWith("place-self-")) return "place-self";
|
|
439
|
+
if (b.startsWith("content-")) return "content";
|
|
440
|
+
if (b.startsWith("px-")) return "px";
|
|
441
|
+
if (b.startsWith("py-")) return "py";
|
|
442
|
+
if (b.startsWith("pt-")) return "pt";
|
|
443
|
+
if (b.startsWith("pr-")) return "pr";
|
|
444
|
+
if (b.startsWith("pb-")) return "pb";
|
|
445
|
+
if (b.startsWith("pl-")) return "pl";
|
|
446
|
+
if (b.startsWith("ps-")) return "ps";
|
|
447
|
+
if (b.startsWith("pe-")) return "pe";
|
|
448
|
+
if (b.startsWith("p-")) return "p";
|
|
449
|
+
if (b.startsWith("mx-")) return "mx";
|
|
450
|
+
if (b.startsWith("my-")) return "my";
|
|
451
|
+
if (b.startsWith("mt-")) return "mt";
|
|
452
|
+
if (b.startsWith("mr-")) return "mr";
|
|
453
|
+
if (b.startsWith("mb-")) return "mb";
|
|
454
|
+
if (b.startsWith("ml-")) return "ml";
|
|
455
|
+
if (b.startsWith("ms-")) return "ms";
|
|
456
|
+
if (b.startsWith("me-")) return "me";
|
|
457
|
+
if (b === "-m" || b.startsWith("m-") || b.startsWith("-m-")) return "m";
|
|
458
|
+
if (b.startsWith("space-x-")) return "space-x";
|
|
459
|
+
if (b.startsWith("space-y-")) return "space-y";
|
|
460
|
+
if (b.startsWith("size-")) return "size";
|
|
461
|
+
if (b.startsWith("min-w-")) return "min-w";
|
|
462
|
+
if (b.startsWith("max-w-")) return "max-w";
|
|
463
|
+
if (b.startsWith("w-")) return "w";
|
|
464
|
+
if (b.startsWith("min-h-")) return "min-h";
|
|
465
|
+
if (b.startsWith("max-h-")) return "max-h";
|
|
466
|
+
if (b.startsWith("h-")) return "h";
|
|
467
|
+
if (b.startsWith("inset-x-")) return "inset-x";
|
|
468
|
+
if (b.startsWith("inset-y-")) return "inset-y";
|
|
469
|
+
if (b.startsWith("inset-")) return "inset";
|
|
470
|
+
if (b.startsWith("top-")) return "top";
|
|
471
|
+
if (b.startsWith("right-") || b.startsWith("end-")) return "right";
|
|
472
|
+
if (b.startsWith("bottom-")) return "bottom";
|
|
473
|
+
if (b.startsWith("left-") || b.startsWith("start-")) return "left";
|
|
474
|
+
if (b.startsWith("z-")) return "z";
|
|
475
|
+
if (b.startsWith("opacity-")) return "opacity";
|
|
476
|
+
if (b.startsWith("bg-")) {
|
|
477
|
+
if (b.startsWith("bg-opacity-")) return "bg-opacity";
|
|
472
478
|
return "bg";
|
|
473
479
|
}
|
|
474
|
-
if (
|
|
475
|
-
if (
|
|
476
|
-
if (
|
|
477
|
-
if (
|
|
478
|
-
const suffix =
|
|
480
|
+
if (b.startsWith("from-")) return "from";
|
|
481
|
+
if (b.startsWith("via-")) return "via";
|
|
482
|
+
if (b.startsWith("to-")) return "to";
|
|
483
|
+
if (b.startsWith("text-")) {
|
|
484
|
+
const suffix = b.slice("text-".length);
|
|
479
485
|
if (isTextSize(suffix)) return "text-size";
|
|
480
486
|
if (suffix.startsWith("opacity-")) return "text-opacity";
|
|
481
487
|
if (TEXT_ALIGN_VALUES.has(suffix)) return "text-align";
|
|
482
488
|
return "text-color";
|
|
483
489
|
}
|
|
484
|
-
if (
|
|
485
|
-
const suffix =
|
|
490
|
+
if (b.startsWith("font-")) {
|
|
491
|
+
const suffix = b.slice("font-".length);
|
|
486
492
|
if (FONT_WEIGHT_NAMES.has(suffix) || isAsciiDigits(suffix)) return "font-weight";
|
|
487
493
|
return "font-family";
|
|
488
494
|
}
|
|
489
|
-
if (
|
|
490
|
-
if (
|
|
491
|
-
if (
|
|
492
|
-
const suffix =
|
|
495
|
+
if (b.startsWith("leading-")) return "leading";
|
|
496
|
+
if (b.startsWith("tracking-")) return "tracking";
|
|
497
|
+
if (b.startsWith("border-")) {
|
|
498
|
+
const suffix = b.slice("border-".length);
|
|
493
499
|
const sidePrefix = BORDER_SIDE_PREFIXES.find((p) => suffix.startsWith(p));
|
|
494
500
|
if (sidePrefix) {
|
|
495
501
|
const side = suffix.slice(0, 1);
|
|
@@ -503,67 +509,67 @@ function conflictGroup(base) {
|
|
|
503
509
|
if (BORDER_STYLE_VALUES.has(suffix)) return "border-style";
|
|
504
510
|
return "border-color";
|
|
505
511
|
}
|
|
506
|
-
if (
|
|
507
|
-
if (
|
|
508
|
-
if (
|
|
509
|
-
if (
|
|
510
|
-
const firstChar =
|
|
512
|
+
if (b === "border") return "border-width";
|
|
513
|
+
if (b.startsWith("outline-")) return "outline";
|
|
514
|
+
if (b === "outline") return "outline";
|
|
515
|
+
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")) {
|
|
516
|
+
const firstChar = b.slice("rounded-".length).charAt(0) || "x";
|
|
511
517
|
return `rounded-${firstChar}`;
|
|
512
518
|
}
|
|
513
|
-
if (
|
|
514
|
-
if (
|
|
515
|
-
if (
|
|
516
|
-
if (
|
|
517
|
-
if (
|
|
518
|
-
const rest =
|
|
519
|
+
if (b === "rounded" || b.startsWith("rounded-")) return "rounded";
|
|
520
|
+
if (b === "shadow" || b.startsWith("shadow-")) return "shadow";
|
|
521
|
+
if (b.startsWith("ring-offset-")) return "ring-offset";
|
|
522
|
+
if (b === "ring") return "ring-width";
|
|
523
|
+
if (b.startsWith("ring-")) {
|
|
524
|
+
const rest = b.slice("ring-".length);
|
|
519
525
|
const isWidth = rest === "0" || rest === "1" || rest === "2" || rest === "4" || rest === "8" || /^-?\d+(\.\d+)?$/.test(rest) || rest.startsWith("[") && rest.endsWith("]");
|
|
520
526
|
if (isWidth) return "ring-width";
|
|
521
527
|
if (rest === "inset") return "ring-inset";
|
|
522
528
|
return "ring-color";
|
|
523
529
|
}
|
|
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 (
|
|
538
|
-
if (
|
|
539
|
-
if (
|
|
540
|
-
if (
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
543
|
-
if (
|
|
544
|
-
if (
|
|
545
|
-
if (
|
|
546
|
-
if (
|
|
547
|
-
if (
|
|
548
|
-
if (
|
|
549
|
-
const rest =
|
|
530
|
+
if (b.startsWith("rotate-")) return "rotate";
|
|
531
|
+
if (b.startsWith("scale-x-")) return "scale-x";
|
|
532
|
+
if (b.startsWith("scale-y-")) return "scale-y";
|
|
533
|
+
if (b.startsWith("scale-")) return "scale";
|
|
534
|
+
if (b.startsWith("translate-x-")) return "translate-x";
|
|
535
|
+
if (b.startsWith("translate-y-")) return "translate-y";
|
|
536
|
+
if (b.startsWith("skew-x-")) return "skew-x";
|
|
537
|
+
if (b.startsWith("skew-y-")) return "skew-y";
|
|
538
|
+
if (b === "transition" || b.startsWith("transition-")) return "transition";
|
|
539
|
+
if (b.startsWith("duration-")) return "duration";
|
|
540
|
+
if (b.startsWith("ease-")) return "ease";
|
|
541
|
+
if (b.startsWith("delay-")) return "delay";
|
|
542
|
+
if (b === "animate" || b.startsWith("animate-")) return "animate";
|
|
543
|
+
if (b.startsWith("cursor-")) return "cursor";
|
|
544
|
+
if (b.startsWith("pointer-events-")) return "pointer-events";
|
|
545
|
+
if (b.startsWith("select-")) return "select";
|
|
546
|
+
if (b === "visible" || b === "invisible" || b === "collapse") return "visibility";
|
|
547
|
+
if (b.startsWith("object-")) return "object";
|
|
548
|
+
if (b.startsWith("aspect-")) return "aspect";
|
|
549
|
+
if (b.startsWith("order-")) return "order";
|
|
550
|
+
if (b.startsWith("whitespace-")) return "whitespace";
|
|
551
|
+
if (b.startsWith("list-")) return "list";
|
|
552
|
+
if (b.startsWith("fill-")) return "fill";
|
|
553
|
+
if (b.startsWith("stroke-")) return "stroke";
|
|
554
|
+
if (b.startsWith("backdrop-")) {
|
|
555
|
+
const rest = b.slice("backdrop-".length);
|
|
550
556
|
const seg = rest.split("-")[0] || "x";
|
|
551
557
|
return `backdrop-${seg}`;
|
|
552
558
|
}
|
|
553
|
-
if (
|
|
554
|
-
if (
|
|
555
|
-
if (
|
|
556
|
-
if (
|
|
557
|
-
if (
|
|
558
|
-
if (
|
|
559
|
-
if (
|
|
560
|
-
if (
|
|
561
|
-
if (
|
|
562
|
-
if (
|
|
563
|
-
if (
|
|
564
|
-
if (
|
|
565
|
-
if (
|
|
566
|
-
if (
|
|
559
|
+
if (b.startsWith("scroll-")) return "scroll";
|
|
560
|
+
if (b.startsWith("snap-")) return "snap";
|
|
561
|
+
if (b.startsWith("touch-")) return "touch";
|
|
562
|
+
if (b.startsWith("decoration-")) return "text-decoration";
|
|
563
|
+
if (b.startsWith("caret-")) return "caret";
|
|
564
|
+
if (b.startsWith("accent-")) return "accent";
|
|
565
|
+
if (b.startsWith("appearance-")) return "appearance";
|
|
566
|
+
if (b === "isolate" || b === "isolation-auto") return "isolation";
|
|
567
|
+
if (b.startsWith("mix-blend-")) return "mix-blend";
|
|
568
|
+
if (b.startsWith("bg-blend-")) return "bg-blend";
|
|
569
|
+
if (b.startsWith("float-")) return "float";
|
|
570
|
+
if (b.startsWith("clear-")) return "clear";
|
|
571
|
+
if (b.startsWith("break-")) return "break";
|
|
572
|
+
if (b.startsWith("columns-")) return "columns";
|
|
567
573
|
return null;
|
|
568
574
|
}
|
|
569
575
|
function splitVariants(klass) {
|
|
@@ -578,7 +584,7 @@ function splitVariants(klass) {
|
|
|
578
584
|
if (lastColon === 0) return ["", klass];
|
|
579
585
|
return [klass.slice(0, lastColon), klass.slice(lastColon)];
|
|
580
586
|
}
|
|
581
|
-
function mergeClassStringJs(input) {
|
|
587
|
+
function mergeClassStringJs(input, prefix = "") {
|
|
582
588
|
const tokens = input.split(/\s+/).filter(Boolean);
|
|
583
589
|
if (tokens.length === 0) return "";
|
|
584
590
|
if (tokens.length === 1) return tokens[0];
|
|
@@ -586,7 +592,7 @@ function mergeClassStringJs(input) {
|
|
|
586
592
|
const slots = [];
|
|
587
593
|
for (const token of tokens) {
|
|
588
594
|
const [variants, base] = splitVariants(token);
|
|
589
|
-
const group = conflictGroup(base);
|
|
595
|
+
const group = conflictGroup(base, prefix);
|
|
590
596
|
if (group !== null) {
|
|
591
597
|
const key = `${variants}::${group}`;
|
|
592
598
|
const prevIdx = groupOwner.get(key);
|
|
@@ -599,10 +605,10 @@ function mergeClassStringJs(input) {
|
|
|
599
605
|
}
|
|
600
606
|
return slots.filter((s) => s !== null).join(" ");
|
|
601
607
|
}
|
|
602
|
-
function twMergeRawJs(classLists) {
|
|
608
|
+
function twMergeRawJs(classLists, prefix = "") {
|
|
603
609
|
const joined = classLists.map((s) => s.trim()).filter((s) => s.length > 0).join(" ");
|
|
604
610
|
if (joined.length === 0) return "";
|
|
605
|
-
return mergeClassStringJs(joined);
|
|
611
|
+
return mergeClassStringJs(joined, prefix);
|
|
606
612
|
}
|
|
607
613
|
|
|
608
614
|
// packages/domain/core/src/merge.ts
|
|
@@ -617,6 +623,7 @@ function warnFallbackOnce() {
|
|
|
617
623
|
}
|
|
618
624
|
}
|
|
619
625
|
function createTwMerge(options = {}) {
|
|
626
|
+
const prefix = options.prefix ?? "";
|
|
620
627
|
return function twMerge2(...classLists) {
|
|
621
628
|
const inputs = [];
|
|
622
629
|
for (let i = 0; i < classLists.length; i++) {
|
|
@@ -625,11 +632,16 @@ function createTwMerge(options = {}) {
|
|
|
625
632
|
}
|
|
626
633
|
if (inputs.length === 0) return "";
|
|
627
634
|
const native = getNativeBinding();
|
|
628
|
-
if (native
|
|
629
|
-
|
|
635
|
+
if (native) {
|
|
636
|
+
if (prefix && native.twMergeRawWithOptions) {
|
|
637
|
+
return native.twMergeRawWithOptions(inputs, { prefix });
|
|
638
|
+
}
|
|
639
|
+
if (native.twMergeRaw) {
|
|
640
|
+
return native.twMergeRaw(inputs);
|
|
641
|
+
}
|
|
630
642
|
}
|
|
631
643
|
warnFallbackOnce();
|
|
632
|
-
return twMergeRawJs(inputs);
|
|
644
|
+
return twMergeRawJs(inputs, prefix);
|
|
633
645
|
};
|
|
634
646
|
}
|
|
635
647
|
var twMerge = createTwMerge();
|
|
@@ -642,6 +654,37 @@ function mergeWithRules(rules, ...classLists) {
|
|
|
642
654
|
return classes.join(" ");
|
|
643
655
|
}
|
|
644
656
|
|
|
657
|
+
// packages/domain/core/src/parseTemplateFallback.ts
|
|
658
|
+
init_esm_shims();
|
|
659
|
+
var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
|
|
660
|
+
var COMMENT_RE = /\/\/[^\n]*/g;
|
|
661
|
+
function collapseSpaces(s) {
|
|
662
|
+
return s.replace(/\s+/g, " ").trim();
|
|
663
|
+
}
|
|
664
|
+
function cleanBlock(raw) {
|
|
665
|
+
const noComments = raw.replace(COMMENT_RE, "");
|
|
666
|
+
const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
667
|
+
return collapseSpaces(lines.join(" "));
|
|
668
|
+
}
|
|
669
|
+
function parseTemplateJs(raw) {
|
|
670
|
+
const subs = {};
|
|
671
|
+
let base = raw;
|
|
672
|
+
for (const match of raw.matchAll(SUB_RE)) {
|
|
673
|
+
const fullMatch = match[0];
|
|
674
|
+
const name = match[1] ?? match[2] ?? "";
|
|
675
|
+
const innerRaw = match[3] ?? "";
|
|
676
|
+
if (name) {
|
|
677
|
+
subs[name] = cleanBlock(innerRaw);
|
|
678
|
+
}
|
|
679
|
+
base = base.replace(fullMatch, "");
|
|
680
|
+
}
|
|
681
|
+
return {
|
|
682
|
+
base: collapseSpaces(base),
|
|
683
|
+
subs,
|
|
684
|
+
hasSubs: Object.keys(subs).length > 0
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
|
|
645
688
|
// packages/domain/core/src/stateEngine.ts
|
|
646
689
|
init_esm_shims();
|
|
647
690
|
var stateRegistry = /* @__PURE__ */ new Map();
|
|
@@ -649,22 +692,27 @@ if (typeof window !== "undefined") {
|
|
|
649
692
|
window.__TW_STATE_REGISTRY__ = stateRegistry;
|
|
650
693
|
}
|
|
651
694
|
var _hashStateCache = /* @__PURE__ */ new Map();
|
|
695
|
+
function _fnvHash62(s) {
|
|
696
|
+
let h = 2166136261;
|
|
697
|
+
for (let i = 0; i < s.length; i++) {
|
|
698
|
+
h ^= s.charCodeAt(i);
|
|
699
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
700
|
+
}
|
|
701
|
+
return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
|
|
702
|
+
}
|
|
652
703
|
function hashState(tag, state) {
|
|
653
704
|
const sortedKey = tag + JSON.stringify(Object.entries(state).sort());
|
|
654
705
|
const cached = _hashStateCache.get(sortedKey);
|
|
655
706
|
if (cached) return cached;
|
|
656
707
|
const native = getNativeBinding();
|
|
657
|
-
|
|
658
|
-
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
659
|
-
}
|
|
660
|
-
const id = `tw-s-${native.hashContent(sortedKey, "fnv", 6)}`;
|
|
708
|
+
const id = native?.hashContent ? `tw-s-${native.hashContent(sortedKey, "fnv", 6)}` : `tw-s-${_fnvHash62(sortedKey)}`;
|
|
661
709
|
_hashStateCache.set(sortedKey, id);
|
|
662
710
|
return id;
|
|
663
711
|
}
|
|
664
712
|
function generateStateRules(id, state) {
|
|
665
713
|
const native = getNativeBinding();
|
|
666
714
|
if (!native?.generateRuntimeStateCss) {
|
|
667
|
-
|
|
715
|
+
return [];
|
|
668
716
|
}
|
|
669
717
|
return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
|
|
670
718
|
}
|
|
@@ -752,7 +800,13 @@ function _getParsedTemplate(template) {
|
|
|
752
800
|
}
|
|
753
801
|
const native = getNativeBinding();
|
|
754
802
|
if (!native?.parseSubcomponentBlocksNapi) {
|
|
755
|
-
|
|
803
|
+
const fb = parseTemplateJs(template);
|
|
804
|
+
const result2 = {
|
|
805
|
+
baseClasses: fb.base,
|
|
806
|
+
subMap: new Map(Object.entries(fb.subs))
|
|
807
|
+
};
|
|
808
|
+
_templateParseCache.set(template, result2);
|
|
809
|
+
return result2;
|
|
756
810
|
}
|
|
757
811
|
const r = native.parseSubcomponentBlocksNapi(template, "tw");
|
|
758
812
|
const raw = JSON.parse(r.subMapJson);
|
|
@@ -904,10 +958,16 @@ function resolveVariants(variants, props, defaults) {
|
|
|
904
958
|
}
|
|
905
959
|
const binding = getNativeBinding();
|
|
906
960
|
if (!binding?.resolveSimpleVariants) {
|
|
907
|
-
|
|
961
|
+
const classes = [];
|
|
962
|
+
for (const key of Object.keys(variants)) {
|
|
963
|
+
const propValue = cleanProps[key] ?? defaults[key];
|
|
964
|
+
if (propValue !== void 0 && variants[key]?.[propValue]) {
|
|
965
|
+
classes.push(variants[key][propValue]);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
return classes.join(" ").trim().replace(/\s+/g, " ");
|
|
908
969
|
}
|
|
909
|
-
|
|
910
|
-
return result.trim().replace(/\s+/g, " ");
|
|
970
|
+
return binding.resolveSimpleVariants(null, variants, defaults, cleanProps).trim().replace(/\s+/g, " ");
|
|
911
971
|
}
|
|
912
972
|
function resolveStates(statesConfig, stateKeys, statesLookup, props) {
|
|
913
973
|
if (statesLookup && stateKeys.length > 0) {
|
|
@@ -1119,49 +1179,8 @@ function wrapWithSubProxy(component, tagLabel) {
|
|
|
1119
1179
|
});
|
|
1120
1180
|
}
|
|
1121
1181
|
|
|
1122
|
-
// packages/domain/core/src/parseTemplateFallback.ts
|
|
1123
|
-
init_esm_shims();
|
|
1124
|
-
var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
|
|
1125
|
-
var COMMENT_RE = /\/\/[^\n]*/g;
|
|
1126
|
-
function collapseSpaces(s) {
|
|
1127
|
-
return s.replace(/\s+/g, " ").trim();
|
|
1128
|
-
}
|
|
1129
|
-
function cleanBlock(raw) {
|
|
1130
|
-
const noComments = raw.replace(COMMENT_RE, "");
|
|
1131
|
-
const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
1132
|
-
return collapseSpaces(lines.join(" "));
|
|
1133
|
-
}
|
|
1134
|
-
function parseTemplateJs(raw) {
|
|
1135
|
-
const subs = {};
|
|
1136
|
-
let base = raw;
|
|
1137
|
-
for (const match of raw.matchAll(SUB_RE)) {
|
|
1138
|
-
const fullMatch = match[0];
|
|
1139
|
-
const name = match[1] ?? match[2] ?? "";
|
|
1140
|
-
const innerRaw = match[3] ?? "";
|
|
1141
|
-
if (name) {
|
|
1142
|
-
subs[name] = cleanBlock(innerRaw);
|
|
1143
|
-
}
|
|
1144
|
-
base = base.replace(fullMatch, "");
|
|
1145
|
-
}
|
|
1146
|
-
return {
|
|
1147
|
-
base: cleanBlock(base),
|
|
1148
|
-
subs,
|
|
1149
|
-
hasSubs: Object.keys(subs).length > 0
|
|
1150
|
-
};
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
1182
|
// packages/domain/core/src/twProxy.ts
|
|
1154
1183
|
var _parsedTemplateCache = /* @__PURE__ */ new Map();
|
|
1155
|
-
var warnedParseTemplateFallback = false;
|
|
1156
|
-
function warnParseTemplateFallbackOnce() {
|
|
1157
|
-
if (warnedParseTemplateFallback) return;
|
|
1158
|
-
warnedParseTemplateFallback = true;
|
|
1159
|
-
if (typeof console !== "undefined") {
|
|
1160
|
-
console.warn(
|
|
1161
|
-
"[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."
|
|
1162
|
-
);
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
1184
|
function parseTemplate(strings, exprs) {
|
|
1166
1185
|
const raw = strings.raw.reduce((acc, str, i) => {
|
|
1167
1186
|
const expr = exprs[i];
|
|
@@ -1171,15 +1190,15 @@ function parseTemplate(strings, exprs) {
|
|
|
1171
1190
|
const cached = _parsedTemplateCache.get(raw);
|
|
1172
1191
|
if (cached) return cached;
|
|
1173
1192
|
const binding = getNativeBinding();
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
} else {
|
|
1180
|
-
warnParseTemplateFallbackOnce();
|
|
1181
|
-
result = parseTemplateJs(raw);
|
|
1193
|
+
if (!binding?.parseTemplate) {
|
|
1194
|
+
const fb = parseTemplateJs(raw);
|
|
1195
|
+
const result2 = { base: fb.base, subs: fb.subs, hasSubs: fb.hasSubs };
|
|
1196
|
+
_parsedTemplateCache.set(raw, result2);
|
|
1197
|
+
return result2;
|
|
1182
1198
|
}
|
|
1199
|
+
const r = binding.parseTemplate(raw);
|
|
1200
|
+
const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
|
|
1201
|
+
const result = { base: r.base, subs, hasSubs: r.hasSubs };
|
|
1183
1202
|
_parsedTemplateCache.set(raw, result);
|
|
1184
1203
|
return result;
|
|
1185
1204
|
}
|
|
@@ -1492,19 +1511,25 @@ function cn(...inputs) {
|
|
|
1492
1511
|
}
|
|
1493
1512
|
if (strings.length === 0) return "";
|
|
1494
1513
|
const native = getNativeBinding();
|
|
1495
|
-
if (
|
|
1514
|
+
if (native?.resolveClassNames) {
|
|
1515
|
+
return native.resolveClassNames(strings);
|
|
1516
|
+
}
|
|
1517
|
+
if (native !== null) {
|
|
1496
1518
|
throw new Error("Native binding 'resolveClassNames' is required but not available.");
|
|
1497
1519
|
}
|
|
1498
|
-
return
|
|
1520
|
+
return strings.filter(Boolean).join(" ");
|
|
1499
1521
|
}
|
|
1500
1522
|
function cx(...inputs) {
|
|
1501
1523
|
const filtered = inputs.flat().filter(Boolean);
|
|
1502
1524
|
if (filtered.length === 0) return "";
|
|
1503
1525
|
const native = getNativeBinding();
|
|
1504
|
-
if (
|
|
1526
|
+
if (native?.twMergeMany) {
|
|
1527
|
+
return native.twMergeMany(filtered);
|
|
1528
|
+
}
|
|
1529
|
+
if (native !== null) {
|
|
1505
1530
|
throw new Error("Native binding 'twMergeMany' is required but not available.");
|
|
1506
1531
|
}
|
|
1507
|
-
return
|
|
1532
|
+
return twMergeRawJs(filtered);
|
|
1508
1533
|
}
|
|
1509
1534
|
var cxm = cx;
|
|
1510
1535
|
|