tailwind-styled-v4 5.1.11 → 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 +224 -156
- 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 +226 -156
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +226 -156
- package/dist/index.mjs.map +1 -1
- package/dist/runtime-css.js +1 -0
- package/dist/runtime-css.mjs +1 -0
- package/dist/runtime.js +1 -0
- package/dist/runtime.mjs +1 -0
- 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/theme.js +1 -0
- package/dist/theme.mjs +1 -0
- 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/metafile-cjs.json +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
3
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
4
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
@@ -223,22 +224,27 @@ if (typeof window !== "undefined") {
|
|
|
223
224
|
window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
|
|
224
225
|
}
|
|
225
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
|
+
}
|
|
226
235
|
function hashContainer(tag, container, name) {
|
|
227
236
|
const sortedKey = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
|
|
228
237
|
const cached = _hashContainerCache.get(sortedKey);
|
|
229
238
|
if (cached) return cached;
|
|
230
239
|
const native = getNativeBinding();
|
|
231
|
-
|
|
232
|
-
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
233
|
-
}
|
|
234
|
-
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)}`;
|
|
235
241
|
_hashContainerCache.set(sortedKey, id);
|
|
236
242
|
return id;
|
|
237
243
|
}
|
|
238
244
|
function layoutClassesToCss(classes) {
|
|
239
245
|
const native = getNativeBinding();
|
|
240
246
|
if (!native?.layoutClassesToCss) {
|
|
241
|
-
|
|
247
|
+
return "";
|
|
242
248
|
}
|
|
243
249
|
return native.layoutClassesToCss(classes);
|
|
244
250
|
}
|
|
@@ -399,96 +405,97 @@ var FONT_WEIGHT_NAMES = /* @__PURE__ */ new Set([
|
|
|
399
405
|
var TEXT_ALIGN_VALUES = /* @__PURE__ */ new Set(["left", "center", "right", "justify", "start", "end"]);
|
|
400
406
|
var BORDER_SIDE_PREFIXES = ["t-", "r-", "b-", "l-", "x-", "y-", "s-", "e-"];
|
|
401
407
|
var BORDER_STYLE_VALUES = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none"]);
|
|
402
|
-
function conflictGroup(base) {
|
|
403
|
-
const
|
|
408
|
+
function conflictGroup(base, prefix = "") {
|
|
409
|
+
const b = prefix && base.startsWith(prefix) ? base.slice(prefix.length) : base;
|
|
410
|
+
const bracket = b.indexOf("[");
|
|
404
411
|
if (bracket !== -1) {
|
|
405
|
-
const
|
|
406
|
-
return
|
|
407
|
-
}
|
|
408
|
-
if (DISPLAY_VALUES.has(
|
|
409
|
-
if (POSITION_VALUES.has(
|
|
410
|
-
if (
|
|
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 (
|
|
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";
|
|
471
478
|
return "bg";
|
|
472
479
|
}
|
|
473
|
-
if (
|
|
474
|
-
if (
|
|
475
|
-
if (
|
|
476
|
-
if (
|
|
477
|
-
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);
|
|
478
485
|
if (isTextSize(suffix)) return "text-size";
|
|
479
486
|
if (suffix.startsWith("opacity-")) return "text-opacity";
|
|
480
487
|
if (TEXT_ALIGN_VALUES.has(suffix)) return "text-align";
|
|
481
488
|
return "text-color";
|
|
482
489
|
}
|
|
483
|
-
if (
|
|
484
|
-
const suffix =
|
|
490
|
+
if (b.startsWith("font-")) {
|
|
491
|
+
const suffix = b.slice("font-".length);
|
|
485
492
|
if (FONT_WEIGHT_NAMES.has(suffix) || isAsciiDigits(suffix)) return "font-weight";
|
|
486
493
|
return "font-family";
|
|
487
494
|
}
|
|
488
|
-
if (
|
|
489
|
-
if (
|
|
490
|
-
if (
|
|
491
|
-
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);
|
|
492
499
|
const sidePrefix = BORDER_SIDE_PREFIXES.find((p) => suffix.startsWith(p));
|
|
493
500
|
if (sidePrefix) {
|
|
494
501
|
const side = suffix.slice(0, 1);
|
|
@@ -502,67 +509,67 @@ function conflictGroup(base) {
|
|
|
502
509
|
if (BORDER_STYLE_VALUES.has(suffix)) return "border-style";
|
|
503
510
|
return "border-color";
|
|
504
511
|
}
|
|
505
|
-
if (
|
|
506
|
-
if (
|
|
507
|
-
if (
|
|
508
|
-
if (
|
|
509
|
-
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";
|
|
510
517
|
return `rounded-${firstChar}`;
|
|
511
518
|
}
|
|
512
|
-
if (
|
|
513
|
-
if (
|
|
514
|
-
if (
|
|
515
|
-
if (
|
|
516
|
-
if (
|
|
517
|
-
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);
|
|
518
525
|
const isWidth = rest === "0" || rest === "1" || rest === "2" || rest === "4" || rest === "8" || /^-?\d+(\.\d+)?$/.test(rest) || rest.startsWith("[") && rest.endsWith("]");
|
|
519
526
|
if (isWidth) return "ring-width";
|
|
520
527
|
if (rest === "inset") return "ring-inset";
|
|
521
528
|
return "ring-color";
|
|
522
529
|
}
|
|
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 (
|
|
538
|
-
if (
|
|
539
|
-
if (
|
|
540
|
-
if (
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
543
|
-
if (
|
|
544
|
-
if (
|
|
545
|
-
if (
|
|
546
|
-
if (
|
|
547
|
-
if (
|
|
548
|
-
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);
|
|
549
556
|
const seg = rest.split("-")[0] || "x";
|
|
550
557
|
return `backdrop-${seg}`;
|
|
551
558
|
}
|
|
552
|
-
if (
|
|
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 (
|
|
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";
|
|
566
573
|
return null;
|
|
567
574
|
}
|
|
568
575
|
function splitVariants(klass) {
|
|
@@ -577,7 +584,7 @@ function splitVariants(klass) {
|
|
|
577
584
|
if (lastColon === 0) return ["", klass];
|
|
578
585
|
return [klass.slice(0, lastColon), klass.slice(lastColon)];
|
|
579
586
|
}
|
|
580
|
-
function mergeClassStringJs(input) {
|
|
587
|
+
function mergeClassStringJs(input, prefix = "") {
|
|
581
588
|
const tokens = input.split(/\s+/).filter(Boolean);
|
|
582
589
|
if (tokens.length === 0) return "";
|
|
583
590
|
if (tokens.length === 1) return tokens[0];
|
|
@@ -585,7 +592,7 @@ function mergeClassStringJs(input) {
|
|
|
585
592
|
const slots = [];
|
|
586
593
|
for (const token of tokens) {
|
|
587
594
|
const [variants, base] = splitVariants(token);
|
|
588
|
-
const group = conflictGroup(base);
|
|
595
|
+
const group = conflictGroup(base, prefix);
|
|
589
596
|
if (group !== null) {
|
|
590
597
|
const key = `${variants}::${group}`;
|
|
591
598
|
const prevIdx = groupOwner.get(key);
|
|
@@ -598,10 +605,10 @@ function mergeClassStringJs(input) {
|
|
|
598
605
|
}
|
|
599
606
|
return slots.filter((s) => s !== null).join(" ");
|
|
600
607
|
}
|
|
601
|
-
function twMergeRawJs(classLists) {
|
|
608
|
+
function twMergeRawJs(classLists, prefix = "") {
|
|
602
609
|
const joined = classLists.map((s) => s.trim()).filter((s) => s.length > 0).join(" ");
|
|
603
610
|
if (joined.length === 0) return "";
|
|
604
|
-
return mergeClassStringJs(joined);
|
|
611
|
+
return mergeClassStringJs(joined, prefix);
|
|
605
612
|
}
|
|
606
613
|
|
|
607
614
|
// packages/domain/core/src/merge.ts
|
|
@@ -616,6 +623,7 @@ function warnFallbackOnce() {
|
|
|
616
623
|
}
|
|
617
624
|
}
|
|
618
625
|
function createTwMerge(options = {}) {
|
|
626
|
+
const prefix = options.prefix ?? "";
|
|
619
627
|
return function twMerge2(...classLists) {
|
|
620
628
|
const inputs = [];
|
|
621
629
|
for (let i = 0; i < classLists.length; i++) {
|
|
@@ -624,11 +632,16 @@ function createTwMerge(options = {}) {
|
|
|
624
632
|
}
|
|
625
633
|
if (inputs.length === 0) return "";
|
|
626
634
|
const native = getNativeBinding();
|
|
627
|
-
if (native
|
|
628
|
-
|
|
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
|
+
}
|
|
629
642
|
}
|
|
630
643
|
warnFallbackOnce();
|
|
631
|
-
return twMergeRawJs(inputs);
|
|
644
|
+
return twMergeRawJs(inputs, prefix);
|
|
632
645
|
};
|
|
633
646
|
}
|
|
634
647
|
var twMerge = createTwMerge();
|
|
@@ -641,6 +654,37 @@ function mergeWithRules(rules, ...classLists) {
|
|
|
641
654
|
return classes.join(" ");
|
|
642
655
|
}
|
|
643
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
|
+
|
|
644
688
|
// packages/domain/core/src/stateEngine.ts
|
|
645
689
|
init_esm_shims();
|
|
646
690
|
var stateRegistry = /* @__PURE__ */ new Map();
|
|
@@ -648,22 +692,27 @@ if (typeof window !== "undefined") {
|
|
|
648
692
|
window.__TW_STATE_REGISTRY__ = stateRegistry;
|
|
649
693
|
}
|
|
650
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
|
+
}
|
|
651
703
|
function hashState(tag, state) {
|
|
652
704
|
const sortedKey = tag + JSON.stringify(Object.entries(state).sort());
|
|
653
705
|
const cached = _hashStateCache.get(sortedKey);
|
|
654
706
|
if (cached) return cached;
|
|
655
707
|
const native = getNativeBinding();
|
|
656
|
-
|
|
657
|
-
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
658
|
-
}
|
|
659
|
-
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)}`;
|
|
660
709
|
_hashStateCache.set(sortedKey, id);
|
|
661
710
|
return id;
|
|
662
711
|
}
|
|
663
712
|
function generateStateRules(id, state) {
|
|
664
713
|
const native = getNativeBinding();
|
|
665
714
|
if (!native?.generateRuntimeStateCss) {
|
|
666
|
-
|
|
715
|
+
return [];
|
|
667
716
|
}
|
|
668
717
|
return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
|
|
669
718
|
}
|
|
@@ -751,7 +800,13 @@ function _getParsedTemplate(template) {
|
|
|
751
800
|
}
|
|
752
801
|
const native = getNativeBinding();
|
|
753
802
|
if (!native?.parseSubcomponentBlocksNapi) {
|
|
754
|
-
|
|
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;
|
|
755
810
|
}
|
|
756
811
|
const r = native.parseSubcomponentBlocksNapi(template, "tw");
|
|
757
812
|
const raw = JSON.parse(r.subMapJson);
|
|
@@ -903,10 +958,16 @@ function resolveVariants(variants, props, defaults) {
|
|
|
903
958
|
}
|
|
904
959
|
const binding = getNativeBinding();
|
|
905
960
|
if (!binding?.resolveSimpleVariants) {
|
|
906
|
-
|
|
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, " ");
|
|
907
969
|
}
|
|
908
|
-
|
|
909
|
-
return result.trim().replace(/\s+/g, " ");
|
|
970
|
+
return binding.resolveSimpleVariants(null, variants, defaults, cleanProps).trim().replace(/\s+/g, " ");
|
|
910
971
|
}
|
|
911
972
|
function resolveStates(statesConfig, stateKeys, statesLookup, props) {
|
|
912
973
|
if (statesLookup && stateKeys.length > 0) {
|
|
@@ -1130,7 +1191,10 @@ function parseTemplate(strings, exprs) {
|
|
|
1130
1191
|
if (cached) return cached;
|
|
1131
1192
|
const binding = getNativeBinding();
|
|
1132
1193
|
if (!binding?.parseTemplate) {
|
|
1133
|
-
|
|
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;
|
|
1134
1198
|
}
|
|
1135
1199
|
const r = binding.parseTemplate(raw);
|
|
1136
1200
|
const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
|
|
@@ -1447,19 +1511,25 @@ function cn(...inputs) {
|
|
|
1447
1511
|
}
|
|
1448
1512
|
if (strings.length === 0) return "";
|
|
1449
1513
|
const native = getNativeBinding();
|
|
1450
|
-
if (
|
|
1514
|
+
if (native?.resolveClassNames) {
|
|
1515
|
+
return native.resolveClassNames(strings);
|
|
1516
|
+
}
|
|
1517
|
+
if (native !== null) {
|
|
1451
1518
|
throw new Error("Native binding 'resolveClassNames' is required but not available.");
|
|
1452
1519
|
}
|
|
1453
|
-
return
|
|
1520
|
+
return strings.filter(Boolean).join(" ");
|
|
1454
1521
|
}
|
|
1455
1522
|
function cx(...inputs) {
|
|
1456
1523
|
const filtered = inputs.flat().filter(Boolean);
|
|
1457
1524
|
if (filtered.length === 0) return "";
|
|
1458
1525
|
const native = getNativeBinding();
|
|
1459
|
-
if (
|
|
1526
|
+
if (native?.twMergeMany) {
|
|
1527
|
+
return native.twMergeMany(filtered);
|
|
1528
|
+
}
|
|
1529
|
+
if (native !== null) {
|
|
1460
1530
|
throw new Error("Native binding 'twMergeMany' is required but not available.");
|
|
1461
1531
|
}
|
|
1462
|
-
return
|
|
1532
|
+
return twMergeRawJs(filtered);
|
|
1463
1533
|
}
|
|
1464
1534
|
var cxm = cx;
|
|
1465
1535
|
|