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.d.mts
CHANGED
|
@@ -253,19 +253,34 @@ declare function cv<C extends ComponentConfig>(config: C, componentId?: string):
|
|
|
253
253
|
|
|
254
254
|
/**
|
|
255
255
|
* tailwind-styled-v4 v2 — cx / cn
|
|
256
|
-
*
|
|
256
|
+
*
|
|
257
|
+
* Native Rust binding dipakai di Node.js/SSR untuk performa maksimal.
|
|
258
|
+
*
|
|
259
|
+
* Browser fallback (Bug 2 — "Native binding 'resolveClassNames' is required
|
|
260
|
+
* but not available." crash di browser):
|
|
261
|
+
*
|
|
262
|
+
* getNativeBinding() return `null` di browser (bukan throw). Ketika itu terjadi
|
|
263
|
+
* kita gunakan pure-TS fallback yang semantiknya identik dengan implementasi Rust:
|
|
264
|
+
* - cn(): filter falsy + join spasi (identik dengan resolve_class_names di Rust)
|
|
265
|
+
* - cx(): conflict-aware merge via twMergeRawJs (port dari tw_merge.rs)
|
|
266
|
+
* - cxn(): flatten nested array + filter falsy + join spasi
|
|
267
|
+
*
|
|
268
|
+
* Server path TIDAK DIUBAH: throw Error tetap dijalankan jika native null di
|
|
269
|
+
* Node.js (menandakan miskonfigurasi). Fallback hanya aktif saat isBrowser=true.
|
|
257
270
|
*/
|
|
258
271
|
type ClassValue = string | undefined | null | false | 0;
|
|
259
272
|
/**
|
|
260
273
|
* cn — simple class name joiner (no conflict resolution).
|
|
261
|
-
*
|
|
274
|
+
* Node.js: delegates ke Rust `resolve_class_names`.
|
|
275
|
+
* Browser: pure-TS fallback — filter falsy + join spasi.
|
|
262
276
|
*
|
|
263
277
|
* @example cn("p-4", isActive && "opacity-100") → "p-4 opacity-100"
|
|
264
278
|
*/
|
|
265
279
|
declare function cn(...inputs: (ClassValue | ClassValue[])[]): string;
|
|
266
280
|
/**
|
|
267
281
|
* cx — conflict-aware class merger.
|
|
268
|
-
*
|
|
282
|
+
* Node.js: delegates ke Rust `tw_merge_many`.
|
|
283
|
+
* Browser: pure-TS fallback via twMergeRawJs (port algoritma Rust).
|
|
269
284
|
*
|
|
270
285
|
* @example cx("p-4 p-8") → "p-8"
|
|
271
286
|
* @example cx("bg-red-500", "bg-blue-500") → "bg-blue-500"
|
package/dist/index.d.ts
CHANGED
|
@@ -253,19 +253,34 @@ declare function cv<C extends ComponentConfig>(config: C, componentId?: string):
|
|
|
253
253
|
|
|
254
254
|
/**
|
|
255
255
|
* tailwind-styled-v4 v2 — cx / cn
|
|
256
|
-
*
|
|
256
|
+
*
|
|
257
|
+
* Native Rust binding dipakai di Node.js/SSR untuk performa maksimal.
|
|
258
|
+
*
|
|
259
|
+
* Browser fallback (Bug 2 — "Native binding 'resolveClassNames' is required
|
|
260
|
+
* but not available." crash di browser):
|
|
261
|
+
*
|
|
262
|
+
* getNativeBinding() return `null` di browser (bukan throw). Ketika itu terjadi
|
|
263
|
+
* kita gunakan pure-TS fallback yang semantiknya identik dengan implementasi Rust:
|
|
264
|
+
* - cn(): filter falsy + join spasi (identik dengan resolve_class_names di Rust)
|
|
265
|
+
* - cx(): conflict-aware merge via twMergeRawJs (port dari tw_merge.rs)
|
|
266
|
+
* - cxn(): flatten nested array + filter falsy + join spasi
|
|
267
|
+
*
|
|
268
|
+
* Server path TIDAK DIUBAH: throw Error tetap dijalankan jika native null di
|
|
269
|
+
* Node.js (menandakan miskonfigurasi). Fallback hanya aktif saat isBrowser=true.
|
|
257
270
|
*/
|
|
258
271
|
type ClassValue = string | undefined | null | false | 0;
|
|
259
272
|
/**
|
|
260
273
|
* cn — simple class name joiner (no conflict resolution).
|
|
261
|
-
*
|
|
274
|
+
* Node.js: delegates ke Rust `resolve_class_names`.
|
|
275
|
+
* Browser: pure-TS fallback — filter falsy + join spasi.
|
|
262
276
|
*
|
|
263
277
|
* @example cn("p-4", isActive && "opacity-100") → "p-4 opacity-100"
|
|
264
278
|
*/
|
|
265
279
|
declare function cn(...inputs: (ClassValue | ClassValue[])[]): string;
|
|
266
280
|
/**
|
|
267
281
|
* cx — conflict-aware class merger.
|
|
268
|
-
*
|
|
282
|
+
* Node.js: delegates ke Rust `tw_merge_many`.
|
|
283
|
+
* Browser: pure-TS fallback via twMergeRawJs (port algoritma Rust).
|
|
269
284
|
*
|
|
270
285
|
* @example cx("p-4 p-8") → "p-8"
|
|
271
286
|
* @example cx("bg-red-500", "bg-blue-500") → "bg-blue-500"
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
"use strict";
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -289,22 +290,27 @@ if (typeof window !== "undefined") {
|
|
|
289
290
|
window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
|
|
290
291
|
}
|
|
291
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
|
+
}
|
|
292
301
|
function hashContainer(tag, container, name) {
|
|
293
302
|
const sortedKey = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
|
|
294
303
|
const cached = _hashContainerCache.get(sortedKey);
|
|
295
304
|
if (cached) return cached;
|
|
296
305
|
const native = getNativeBinding();
|
|
297
|
-
|
|
298
|
-
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
299
|
-
}
|
|
300
|
-
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)}`;
|
|
301
307
|
_hashContainerCache.set(sortedKey, id);
|
|
302
308
|
return id;
|
|
303
309
|
}
|
|
304
310
|
function layoutClassesToCss(classes) {
|
|
305
311
|
const native = getNativeBinding();
|
|
306
312
|
if (!native?.layoutClassesToCss) {
|
|
307
|
-
|
|
313
|
+
return "";
|
|
308
314
|
}
|
|
309
315
|
return native.layoutClassesToCss(classes);
|
|
310
316
|
}
|
|
@@ -465,96 +471,97 @@ var FONT_WEIGHT_NAMES = /* @__PURE__ */ new Set([
|
|
|
465
471
|
var TEXT_ALIGN_VALUES = /* @__PURE__ */ new Set(["left", "center", "right", "justify", "start", "end"]);
|
|
466
472
|
var BORDER_SIDE_PREFIXES = ["t-", "r-", "b-", "l-", "x-", "y-", "s-", "e-"];
|
|
467
473
|
var BORDER_STYLE_VALUES = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none"]);
|
|
468
|
-
function conflictGroup(base) {
|
|
469
|
-
const
|
|
474
|
+
function conflictGroup(base, prefix = "") {
|
|
475
|
+
const b = prefix && base.startsWith(prefix) ? base.slice(prefix.length) : base;
|
|
476
|
+
const bracket = b.indexOf("[");
|
|
470
477
|
if (bracket !== -1) {
|
|
471
|
-
const
|
|
472
|
-
return
|
|
473
|
-
}
|
|
474
|
-
if (DISPLAY_VALUES.has(
|
|
475
|
-
if (POSITION_VALUES.has(
|
|
476
|
-
if (
|
|
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 (
|
|
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";
|
|
537
544
|
return "bg";
|
|
538
545
|
}
|
|
539
|
-
if (
|
|
540
|
-
if (
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
543
|
-
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);
|
|
544
551
|
if (isTextSize(suffix)) return "text-size";
|
|
545
552
|
if (suffix.startsWith("opacity-")) return "text-opacity";
|
|
546
553
|
if (TEXT_ALIGN_VALUES.has(suffix)) return "text-align";
|
|
547
554
|
return "text-color";
|
|
548
555
|
}
|
|
549
|
-
if (
|
|
550
|
-
const suffix =
|
|
556
|
+
if (b.startsWith("font-")) {
|
|
557
|
+
const suffix = b.slice("font-".length);
|
|
551
558
|
if (FONT_WEIGHT_NAMES.has(suffix) || isAsciiDigits(suffix)) return "font-weight";
|
|
552
559
|
return "font-family";
|
|
553
560
|
}
|
|
554
|
-
if (
|
|
555
|
-
if (
|
|
556
|
-
if (
|
|
557
|
-
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);
|
|
558
565
|
const sidePrefix = BORDER_SIDE_PREFIXES.find((p) => suffix.startsWith(p));
|
|
559
566
|
if (sidePrefix) {
|
|
560
567
|
const side = suffix.slice(0, 1);
|
|
@@ -568,67 +575,67 @@ function conflictGroup(base) {
|
|
|
568
575
|
if (BORDER_STYLE_VALUES.has(suffix)) return "border-style";
|
|
569
576
|
return "border-color";
|
|
570
577
|
}
|
|
571
|
-
if (
|
|
572
|
-
if (
|
|
573
|
-
if (
|
|
574
|
-
if (
|
|
575
|
-
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";
|
|
576
583
|
return `rounded-${firstChar}`;
|
|
577
584
|
}
|
|
578
|
-
if (
|
|
579
|
-
if (
|
|
580
|
-
if (
|
|
581
|
-
if (
|
|
582
|
-
if (
|
|
583
|
-
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);
|
|
584
591
|
const isWidth = rest === "0" || rest === "1" || rest === "2" || rest === "4" || rest === "8" || /^-?\d+(\.\d+)?$/.test(rest) || rest.startsWith("[") && rest.endsWith("]");
|
|
585
592
|
if (isWidth) return "ring-width";
|
|
586
593
|
if (rest === "inset") return "ring-inset";
|
|
587
594
|
return "ring-color";
|
|
588
595
|
}
|
|
589
|
-
if (
|
|
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
|
-
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);
|
|
615
622
|
const seg = rest.split("-")[0] || "x";
|
|
616
623
|
return `backdrop-${seg}`;
|
|
617
624
|
}
|
|
618
|
-
if (
|
|
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 (
|
|
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";
|
|
632
639
|
return null;
|
|
633
640
|
}
|
|
634
641
|
function splitVariants(klass) {
|
|
@@ -643,7 +650,7 @@ function splitVariants(klass) {
|
|
|
643
650
|
if (lastColon === 0) return ["", klass];
|
|
644
651
|
return [klass.slice(0, lastColon), klass.slice(lastColon)];
|
|
645
652
|
}
|
|
646
|
-
function mergeClassStringJs(input) {
|
|
653
|
+
function mergeClassStringJs(input, prefix = "") {
|
|
647
654
|
const tokens = input.split(/\s+/).filter(Boolean);
|
|
648
655
|
if (tokens.length === 0) return "";
|
|
649
656
|
if (tokens.length === 1) return tokens[0];
|
|
@@ -651,7 +658,7 @@ function mergeClassStringJs(input) {
|
|
|
651
658
|
const slots = [];
|
|
652
659
|
for (const token of tokens) {
|
|
653
660
|
const [variants, base] = splitVariants(token);
|
|
654
|
-
const group = conflictGroup(base);
|
|
661
|
+
const group = conflictGroup(base, prefix);
|
|
655
662
|
if (group !== null) {
|
|
656
663
|
const key = `${variants}::${group}`;
|
|
657
664
|
const prevIdx = groupOwner.get(key);
|
|
@@ -664,10 +671,10 @@ function mergeClassStringJs(input) {
|
|
|
664
671
|
}
|
|
665
672
|
return slots.filter((s) => s !== null).join(" ");
|
|
666
673
|
}
|
|
667
|
-
function twMergeRawJs(classLists) {
|
|
674
|
+
function twMergeRawJs(classLists, prefix = "") {
|
|
668
675
|
const joined = classLists.map((s) => s.trim()).filter((s) => s.length > 0).join(" ");
|
|
669
676
|
if (joined.length === 0) return "";
|
|
670
|
-
return mergeClassStringJs(joined);
|
|
677
|
+
return mergeClassStringJs(joined, prefix);
|
|
671
678
|
}
|
|
672
679
|
|
|
673
680
|
// packages/domain/core/src/merge.ts
|
|
@@ -682,6 +689,7 @@ function warnFallbackOnce() {
|
|
|
682
689
|
}
|
|
683
690
|
}
|
|
684
691
|
function createTwMerge(options = {}) {
|
|
692
|
+
const prefix = options.prefix ?? "";
|
|
685
693
|
return function twMerge2(...classLists) {
|
|
686
694
|
const inputs = [];
|
|
687
695
|
for (let i = 0; i < classLists.length; i++) {
|
|
@@ -690,11 +698,16 @@ function createTwMerge(options = {}) {
|
|
|
690
698
|
}
|
|
691
699
|
if (inputs.length === 0) return "";
|
|
692
700
|
const native = getNativeBinding();
|
|
693
|
-
if (native
|
|
694
|
-
|
|
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
|
+
}
|
|
695
708
|
}
|
|
696
709
|
warnFallbackOnce();
|
|
697
|
-
return twMergeRawJs(inputs);
|
|
710
|
+
return twMergeRawJs(inputs, prefix);
|
|
698
711
|
};
|
|
699
712
|
}
|
|
700
713
|
var twMerge = createTwMerge();
|
|
@@ -707,6 +720,37 @@ function mergeWithRules(rules, ...classLists) {
|
|
|
707
720
|
return classes.join(" ");
|
|
708
721
|
}
|
|
709
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
|
+
|
|
710
754
|
// packages/domain/core/src/stateEngine.ts
|
|
711
755
|
init_cjs_shims();
|
|
712
756
|
var stateRegistry = /* @__PURE__ */ new Map();
|
|
@@ -714,22 +758,27 @@ if (typeof window !== "undefined") {
|
|
|
714
758
|
window.__TW_STATE_REGISTRY__ = stateRegistry;
|
|
715
759
|
}
|
|
716
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
|
+
}
|
|
717
769
|
function hashState(tag, state) {
|
|
718
770
|
const sortedKey = tag + JSON.stringify(Object.entries(state).sort());
|
|
719
771
|
const cached = _hashStateCache.get(sortedKey);
|
|
720
772
|
if (cached) return cached;
|
|
721
773
|
const native = getNativeBinding();
|
|
722
|
-
|
|
723
|
-
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
724
|
-
}
|
|
725
|
-
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)}`;
|
|
726
775
|
_hashStateCache.set(sortedKey, id);
|
|
727
776
|
return id;
|
|
728
777
|
}
|
|
729
778
|
function generateStateRules(id, state) {
|
|
730
779
|
const native = getNativeBinding();
|
|
731
780
|
if (!native?.generateRuntimeStateCss) {
|
|
732
|
-
|
|
781
|
+
return [];
|
|
733
782
|
}
|
|
734
783
|
return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
|
|
735
784
|
}
|
|
@@ -817,7 +866,13 @@ function _getParsedTemplate(template) {
|
|
|
817
866
|
}
|
|
818
867
|
const native = getNativeBinding();
|
|
819
868
|
if (!native?.parseSubcomponentBlocksNapi) {
|
|
820
|
-
|
|
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;
|
|
821
876
|
}
|
|
822
877
|
const r = native.parseSubcomponentBlocksNapi(template, "tw");
|
|
823
878
|
const raw = JSON.parse(r.subMapJson);
|
|
@@ -969,10 +1024,16 @@ function resolveVariants(variants, props, defaults) {
|
|
|
969
1024
|
}
|
|
970
1025
|
const binding = getNativeBinding();
|
|
971
1026
|
if (!binding?.resolveSimpleVariants) {
|
|
972
|
-
|
|
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, " ");
|
|
973
1035
|
}
|
|
974
|
-
|
|
975
|
-
return result.trim().replace(/\s+/g, " ");
|
|
1036
|
+
return binding.resolveSimpleVariants(null, variants, defaults, cleanProps).trim().replace(/\s+/g, " ");
|
|
976
1037
|
}
|
|
977
1038
|
function resolveStates(statesConfig, stateKeys, statesLookup, props) {
|
|
978
1039
|
if (statesLookup && stateKeys.length > 0) {
|
|
@@ -1196,7 +1257,10 @@ function parseTemplate(strings, exprs) {
|
|
|
1196
1257
|
if (cached) return cached;
|
|
1197
1258
|
const binding = getNativeBinding();
|
|
1198
1259
|
if (!binding?.parseTemplate) {
|
|
1199
|
-
|
|
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;
|
|
1200
1264
|
}
|
|
1201
1265
|
const r = binding.parseTemplate(raw);
|
|
1202
1266
|
const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
|
|
@@ -1513,19 +1577,25 @@ function cn(...inputs) {
|
|
|
1513
1577
|
}
|
|
1514
1578
|
if (strings.length === 0) return "";
|
|
1515
1579
|
const native = getNativeBinding();
|
|
1516
|
-
if (
|
|
1580
|
+
if (native?.resolveClassNames) {
|
|
1581
|
+
return native.resolveClassNames(strings);
|
|
1582
|
+
}
|
|
1583
|
+
if (native !== null) {
|
|
1517
1584
|
throw new Error("Native binding 'resolveClassNames' is required but not available.");
|
|
1518
1585
|
}
|
|
1519
|
-
return
|
|
1586
|
+
return strings.filter(Boolean).join(" ");
|
|
1520
1587
|
}
|
|
1521
1588
|
function cx(...inputs) {
|
|
1522
1589
|
const filtered = inputs.flat().filter(Boolean);
|
|
1523
1590
|
if (filtered.length === 0) return "";
|
|
1524
1591
|
const native = getNativeBinding();
|
|
1525
|
-
if (
|
|
1592
|
+
if (native?.twMergeMany) {
|
|
1593
|
+
return native.twMergeMany(filtered);
|
|
1594
|
+
}
|
|
1595
|
+
if (native !== null) {
|
|
1526
1596
|
throw new Error("Native binding 'twMergeMany' is required but not available.");
|
|
1527
1597
|
}
|
|
1528
|
-
return
|
|
1598
|
+
return twMergeRawJs(filtered);
|
|
1529
1599
|
}
|
|
1530
1600
|
var cxm = cx;
|
|
1531
1601
|
|