tailwind-styled-v4 5.1.9 → 5.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,3 @@
1
- "use client"
2
-
3
1
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
2
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
3
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -183,7 +181,7 @@ var nativeBinding = null;
183
181
  var bindingLoadAttempted = false;
184
182
  var getBinding = () => {
185
183
  if (isBrowser2) {
186
- throw new Error(NATIVE_UNAVAILABLE_MESSAGE + "\n\nNative bindings are not available in browser. Use the compiled CSS output instead.");
184
+ return null;
187
185
  }
188
186
  if (nativeBinding) return nativeBinding;
189
187
  if (bindingLoadAttempted) {
@@ -191,10 +189,10 @@ var getBinding = () => {
191
189
  }
192
190
  bindingLoadAttempted = true;
193
191
  try {
194
- const runtimeDir = isBrowser2 ? "" : dirname(
192
+ const runtimeDir = dirname(
195
193
  typeof __filename !== "undefined" ? __filename : typeof import.meta !== "undefined" && import.meta.url ? fileURLToPath3(import.meta.url) : process.cwd()
196
194
  );
197
- const result = isBrowser2 ? { path: null, source: "not-found", platform: "browser", tried: [] } : resolveNativeBinary(runtimeDir);
195
+ const result = resolveNativeBinary(runtimeDir);
198
196
  if (result.path && result.path.endsWith(".node")) {
199
197
  const mod = _loadNative(result.path);
200
198
  if (mod?.batchSplitClasses) {
@@ -333,7 +331,291 @@ function getContainerRegistry() {
333
331
 
334
332
  // packages/domain/core/src/merge.ts
335
333
  init_esm_shims();
336
- function createTwMerge(_options = {}) {
334
+
335
+ // packages/domain/core/src/mergeFallback.ts
336
+ init_esm_shims();
337
+ var TEXT_SIZE_SUFFIXES = /* @__PURE__ */ new Set([
338
+ "xs",
339
+ "sm",
340
+ "base",
341
+ "lg",
342
+ "xl",
343
+ "2xl",
344
+ "3xl",
345
+ "4xl",
346
+ "5xl",
347
+ "6xl",
348
+ "7xl",
349
+ "8xl",
350
+ "9xl"
351
+ ]);
352
+ function isTextSize(suffix) {
353
+ if (TEXT_SIZE_SUFFIXES.has(suffix)) return true;
354
+ if (suffix.startsWith("[")) return true;
355
+ return false;
356
+ }
357
+ function isAsciiDigits(s) {
358
+ if (s.length === 0) return true;
359
+ for (let i = 0; i < s.length; i++) {
360
+ const code = s.charCodeAt(i);
361
+ if (code < 48 || code > 57) return false;
362
+ }
363
+ return true;
364
+ }
365
+ function isU32(s) {
366
+ return s.length > 0 && /^[0-9]+$/.test(s);
367
+ }
368
+ var DISPLAY_VALUES = /* @__PURE__ */ new Set([
369
+ "block",
370
+ "inline-block",
371
+ "inline",
372
+ "flex",
373
+ "inline-flex",
374
+ "grid",
375
+ "inline-grid",
376
+ "table",
377
+ "inline-table",
378
+ "table-row",
379
+ "table-cell",
380
+ "table-column",
381
+ "table-caption",
382
+ "contents",
383
+ "list-item",
384
+ "hidden",
385
+ "flow-root"
386
+ ]);
387
+ var POSITION_VALUES = /* @__PURE__ */ new Set(["static", "relative", "absolute", "fixed", "sticky"]);
388
+ var FONT_WEIGHT_NAMES = /* @__PURE__ */ new Set([
389
+ "thin",
390
+ "extralight",
391
+ "light",
392
+ "normal",
393
+ "medium",
394
+ "semibold",
395
+ "bold",
396
+ "extrabold",
397
+ "black"
398
+ ]);
399
+ var TEXT_ALIGN_VALUES = /* @__PURE__ */ new Set(["left", "center", "right", "justify", "start", "end"]);
400
+ var BORDER_SIDE_PREFIXES = ["t-", "r-", "b-", "l-", "x-", "y-", "s-", "e-"];
401
+ var BORDER_STYLE_VALUES = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "hidden", "none"]);
402
+ function conflictGroup(base) {
403
+ const bracket = base.indexOf("[");
404
+ if (bracket !== -1) {
405
+ const prefix = base.slice(0, bracket).replace(/-+$/, "");
406
+ return prefix.length > 0 ? prefix : "arbitrary";
407
+ }
408
+ if (DISPLAY_VALUES.has(base)) return "display";
409
+ if (POSITION_VALUES.has(base)) return "position";
410
+ if (base.startsWith("overflow-x-")) return "overflow-x";
411
+ if (base.startsWith("overflow-y-")) return "overflow-y";
412
+ if (base.startsWith("overflow-")) return "overflow";
413
+ if (base.startsWith("flex-")) return "flex";
414
+ if (base.startsWith("grid-cols-")) return "grid-cols";
415
+ if (base.startsWith("grid-rows-")) return "grid-rows";
416
+ if (base.startsWith("grid-flow-")) return "grid-flow";
417
+ if (base.startsWith("col-")) return "col";
418
+ if (base.startsWith("row-")) return "row";
419
+ if (base === "grow" || base.startsWith("grow-")) return "grow";
420
+ if (base === "shrink" || base.startsWith("shrink-")) return "shrink";
421
+ if (base.startsWith("gap-x-")) return "gap-x";
422
+ if (base.startsWith("gap-y-")) return "gap-y";
423
+ if (base.startsWith("gap-")) return "gap";
424
+ if (base.startsWith("justify-items-")) return "justify-items";
425
+ if (base.startsWith("justify-self-")) return "justify-self";
426
+ if (base.startsWith("justify-")) return "justify";
427
+ if (base.startsWith("items-")) return "items";
428
+ if (base.startsWith("self-")) return "self";
429
+ if (base.startsWith("place-content-")) return "place-content";
430
+ if (base.startsWith("place-items-")) return "place-items";
431
+ if (base.startsWith("place-self-")) return "place-self";
432
+ if (base.startsWith("content-")) return "content";
433
+ if (base.startsWith("px-")) return "px";
434
+ if (base.startsWith("py-")) return "py";
435
+ if (base.startsWith("pt-")) return "pt";
436
+ if (base.startsWith("pr-")) return "pr";
437
+ if (base.startsWith("pb-")) return "pb";
438
+ if (base.startsWith("pl-")) return "pl";
439
+ if (base.startsWith("ps-")) return "ps";
440
+ if (base.startsWith("pe-")) return "pe";
441
+ if (base.startsWith("p-")) return "p";
442
+ if (base.startsWith("mx-")) return "mx";
443
+ if (base.startsWith("my-")) return "my";
444
+ if (base.startsWith("mt-")) return "mt";
445
+ if (base.startsWith("mr-")) return "mr";
446
+ if (base.startsWith("mb-")) return "mb";
447
+ if (base.startsWith("ml-")) return "ml";
448
+ if (base.startsWith("ms-")) return "ms";
449
+ if (base.startsWith("me-")) return "me";
450
+ if (base === "-m" || base.startsWith("m-") || base.startsWith("-m-")) return "m";
451
+ if (base.startsWith("space-x-")) return "space-x";
452
+ if (base.startsWith("space-y-")) return "space-y";
453
+ if (base.startsWith("size-")) return "size";
454
+ if (base.startsWith("min-w-")) return "min-w";
455
+ if (base.startsWith("max-w-")) return "max-w";
456
+ if (base.startsWith("w-")) return "w";
457
+ if (base.startsWith("min-h-")) return "min-h";
458
+ if (base.startsWith("max-h-")) return "max-h";
459
+ if (base.startsWith("h-")) return "h";
460
+ if (base.startsWith("inset-x-")) return "inset-x";
461
+ if (base.startsWith("inset-y-")) return "inset-y";
462
+ if (base.startsWith("inset-")) return "inset";
463
+ if (base.startsWith("top-")) return "top";
464
+ if (base.startsWith("right-") || base.startsWith("end-")) return "right";
465
+ if (base.startsWith("bottom-")) return "bottom";
466
+ if (base.startsWith("left-") || base.startsWith("start-")) return "left";
467
+ if (base.startsWith("z-")) return "z";
468
+ if (base.startsWith("opacity-")) return "opacity";
469
+ if (base.startsWith("bg-")) {
470
+ if (base.startsWith("bg-opacity-")) return "bg-opacity";
471
+ return "bg";
472
+ }
473
+ if (base.startsWith("from-")) return "from";
474
+ if (base.startsWith("via-")) return "via";
475
+ if (base.startsWith("to-")) return "to";
476
+ if (base.startsWith("text-")) {
477
+ const suffix = base.slice("text-".length);
478
+ if (isTextSize(suffix)) return "text-size";
479
+ if (suffix.startsWith("opacity-")) return "text-opacity";
480
+ if (TEXT_ALIGN_VALUES.has(suffix)) return "text-align";
481
+ return "text-color";
482
+ }
483
+ if (base.startsWith("font-")) {
484
+ const suffix = base.slice("font-".length);
485
+ if (FONT_WEIGHT_NAMES.has(suffix) || isAsciiDigits(suffix)) return "font-weight";
486
+ return "font-family";
487
+ }
488
+ if (base.startsWith("leading-")) return "leading";
489
+ if (base.startsWith("tracking-")) return "tracking";
490
+ if (base.startsWith("border-")) {
491
+ const suffix = base.slice("border-".length);
492
+ const sidePrefix = BORDER_SIDE_PREFIXES.find((p) => suffix.startsWith(p));
493
+ if (sidePrefix) {
494
+ const side = suffix.slice(0, 1);
495
+ const rest = suffix.slice(2);
496
+ if (isU32(rest) || rest.length === 0) return `border-${side}-width`;
497
+ return `border-${side}-color`;
498
+ }
499
+ if (isU32(suffix) || suffix.length === 0) return "border-width";
500
+ if (suffix.startsWith("opacity-")) return "border-opacity";
501
+ if (suffix === "collapse" || suffix === "separate") return "border-collapse";
502
+ if (BORDER_STYLE_VALUES.has(suffix)) return "border-style";
503
+ return "border-color";
504
+ }
505
+ if (base === "border") return "border-width";
506
+ if (base.startsWith("outline-")) return "outline";
507
+ if (base === "outline") return "outline";
508
+ if (base.startsWith("rounded-t") || base.startsWith("rounded-r") || base.startsWith("rounded-b") || base.startsWith("rounded-l") || base.startsWith("rounded-s") || base.startsWith("rounded-e")) {
509
+ const firstChar = base.slice("rounded-".length).charAt(0) || "x";
510
+ return `rounded-${firstChar}`;
511
+ }
512
+ if (base === "rounded" || base.startsWith("rounded-")) return "rounded";
513
+ if (base === "shadow" || base.startsWith("shadow-")) return "shadow";
514
+ if (base.startsWith("ring-offset-")) return "ring-offset";
515
+ if (base === "ring") return "ring-width";
516
+ if (base.startsWith("ring-")) {
517
+ const rest = base.slice("ring-".length);
518
+ const isWidth = rest === "0" || rest === "1" || rest === "2" || rest === "4" || rest === "8" || /^-?\d+(\.\d+)?$/.test(rest) || rest.startsWith("[") && rest.endsWith("]");
519
+ if (isWidth) return "ring-width";
520
+ if (rest === "inset") return "ring-inset";
521
+ return "ring-color";
522
+ }
523
+ if (base.startsWith("rotate-")) return "rotate";
524
+ if (base.startsWith("scale-x-")) return "scale-x";
525
+ if (base.startsWith("scale-y-")) return "scale-y";
526
+ if (base.startsWith("scale-")) return "scale";
527
+ if (base.startsWith("translate-x-")) return "translate-x";
528
+ if (base.startsWith("translate-y-")) return "translate-y";
529
+ if (base.startsWith("skew-x-")) return "skew-x";
530
+ if (base.startsWith("skew-y-")) return "skew-y";
531
+ if (base === "transition" || base.startsWith("transition-")) return "transition";
532
+ if (base.startsWith("duration-")) return "duration";
533
+ if (base.startsWith("ease-")) return "ease";
534
+ if (base.startsWith("delay-")) return "delay";
535
+ if (base === "animate" || base.startsWith("animate-")) return "animate";
536
+ if (base.startsWith("cursor-")) return "cursor";
537
+ if (base.startsWith("pointer-events-")) return "pointer-events";
538
+ if (base.startsWith("select-")) return "select";
539
+ if (base === "visible" || base === "invisible" || base === "collapse") return "visibility";
540
+ if (base.startsWith("object-")) return "object";
541
+ if (base.startsWith("aspect-")) return "aspect";
542
+ if (base.startsWith("order-")) return "order";
543
+ if (base.startsWith("whitespace-")) return "whitespace";
544
+ if (base.startsWith("list-")) return "list";
545
+ if (base.startsWith("fill-")) return "fill";
546
+ if (base.startsWith("stroke-")) return "stroke";
547
+ if (base.startsWith("backdrop-")) {
548
+ const rest = base.slice("backdrop-".length);
549
+ const seg = rest.split("-")[0] || "x";
550
+ return `backdrop-${seg}`;
551
+ }
552
+ if (base.startsWith("scroll-")) return "scroll";
553
+ if (base.startsWith("snap-")) return "snap";
554
+ if (base.startsWith("touch-")) return "touch";
555
+ if (base.startsWith("decoration-")) return "text-decoration";
556
+ if (base.startsWith("caret-")) return "caret";
557
+ if (base.startsWith("accent-")) return "accent";
558
+ if (base.startsWith("appearance-")) return "appearance";
559
+ if (base === "isolate" || base === "isolation-auto") return "isolation";
560
+ if (base.startsWith("mix-blend-")) return "mix-blend";
561
+ if (base.startsWith("bg-blend-")) return "bg-blend";
562
+ if (base.startsWith("float-")) return "float";
563
+ if (base.startsWith("clear-")) return "clear";
564
+ if (base.startsWith("break-")) return "break";
565
+ if (base.startsWith("columns-")) return "columns";
566
+ return null;
567
+ }
568
+ function splitVariants(klass) {
569
+ let depth = 0;
570
+ let lastColon = 0;
571
+ for (let i = 0; i < klass.length; i++) {
572
+ const ch = klass.charCodeAt(i);
573
+ if (ch === 91) depth++;
574
+ else if (ch === 93) depth = depth > 0 ? depth - 1 : 0;
575
+ else if (ch === 58 && depth === 0) lastColon = i + 1;
576
+ }
577
+ if (lastColon === 0) return ["", klass];
578
+ return [klass.slice(0, lastColon), klass.slice(lastColon)];
579
+ }
580
+ function mergeClassStringJs(input) {
581
+ const tokens = input.split(/\s+/).filter(Boolean);
582
+ if (tokens.length === 0) return "";
583
+ if (tokens.length === 1) return tokens[0];
584
+ const groupOwner = /* @__PURE__ */ new Map();
585
+ const slots = [];
586
+ for (const token of tokens) {
587
+ const [variants, base] = splitVariants(token);
588
+ const group = conflictGroup(base);
589
+ if (group !== null) {
590
+ const key = `${variants}::${group}`;
591
+ const prevIdx = groupOwner.get(key);
592
+ if (prevIdx !== void 0) slots[prevIdx] = null;
593
+ groupOwner.set(key, slots.length);
594
+ slots.push(token);
595
+ } else {
596
+ slots.push(token);
597
+ }
598
+ }
599
+ return slots.filter((s) => s !== null).join(" ");
600
+ }
601
+ function twMergeRawJs(classLists) {
602
+ const joined = classLists.map((s) => s.trim()).filter((s) => s.length > 0).join(" ");
603
+ if (joined.length === 0) return "";
604
+ return mergeClassStringJs(joined);
605
+ }
606
+
607
+ // packages/domain/core/src/merge.ts
608
+ var warnedFallback = false;
609
+ function warnFallbackOnce() {
610
+ if (warnedFallback) return;
611
+ warnedFallback = true;
612
+ if (typeof console !== "undefined") {
613
+ console.warn(
614
+ "[tailwind-styled-v4] Native binding 'twMergeRaw' tidak tersedia (normal di browser) \u2014 pakai pure-TS port dari algoritma Rust-nya. Hasil className tetap benar; ini cuma informasi, bukan error."
615
+ );
616
+ }
617
+ }
618
+ function createTwMerge(options = {}) {
337
619
  return function twMerge2(...classLists) {
338
620
  const inputs = [];
339
621
  for (let i = 0; i < classLists.length; i++) {
@@ -342,10 +624,11 @@ function createTwMerge(_options = {}) {
342
624
  }
343
625
  if (inputs.length === 0) return "";
344
626
  const native = getNativeBinding();
345
- if (!native?.twMergeRaw) {
346
- throw new Error("Native binding 'twMergeRaw' is required but not available.");
627
+ if (native?.twMergeRaw) {
628
+ return native.twMergeRaw(inputs);
347
629
  }
348
- return native.twMergeRaw(inputs);
630
+ warnFallbackOnce();
631
+ return twMergeRawJs(inputs);
349
632
  };
350
633
  }
351
634
  var twMerge = createTwMerge();