tailwind-styled-v4 5.1.22 → 5.1.24

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.
Files changed (61) hide show
  1. package/README.md +216 -0
  2. package/dist/atomic.js +34 -4
  3. package/dist/atomic.js.map +1 -1
  4. package/dist/atomic.mjs +31 -2
  5. package/dist/atomic.mjs.map +1 -1
  6. package/dist/cli.js +132 -97
  7. package/dist/cli.js.map +1 -1
  8. package/dist/cli.mjs +129 -95
  9. package/dist/cli.mjs.map +1 -1
  10. package/dist/compiler.d.mts +195 -1
  11. package/dist/compiler.d.ts +195 -1
  12. package/dist/compiler.js +356 -12
  13. package/dist/compiler.js.map +1 -1
  14. package/dist/compiler.mjs +340 -10
  15. package/dist/compiler.mjs.map +1 -1
  16. package/dist/engine.js +194 -164
  17. package/dist/engine.js.map +1 -1
  18. package/dist/engine.mjs +184 -155
  19. package/dist/engine.mjs.map +1 -1
  20. package/dist/index.browser.mjs +136 -14
  21. package/dist/index.browser.mjs.map +1 -1
  22. package/dist/index.d.mts +45 -4
  23. package/dist/index.d.ts +45 -4
  24. package/dist/index.js +166 -9
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +177 -21
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/next.js +489 -158
  29. package/dist/next.js.map +1 -1
  30. package/dist/next.mjs +483 -153
  31. package/dist/next.mjs.map +1 -1
  32. package/dist/runtime-css.js +1 -1
  33. package/dist/runtime-css.js.map +1 -1
  34. package/dist/runtime-css.mjs +1 -1
  35. package/dist/runtime-css.mjs.map +1 -1
  36. package/dist/runtime.js +17 -0
  37. package/dist/runtime.js.map +1 -1
  38. package/dist/runtime.mjs +23 -0
  39. package/dist/runtime.mjs.map +1 -1
  40. package/dist/shared.js +91 -61
  41. package/dist/shared.js.map +1 -1
  42. package/dist/shared.mjs +85 -56
  43. package/dist/shared.mjs.map +1 -1
  44. package/dist/turbopackLoader.js +79 -49
  45. package/dist/turbopackLoader.js.map +1 -1
  46. package/dist/turbopackLoader.mjs +76 -47
  47. package/dist/turbopackLoader.mjs.map +1 -1
  48. package/dist/tw.js +132 -97
  49. package/dist/tw.js.map +1 -1
  50. package/dist/tw.mjs +129 -95
  51. package/dist/tw.mjs.map +1 -1
  52. package/dist/vite.js +157 -127
  53. package/dist/vite.js.map +1 -1
  54. package/dist/vite.mjs +150 -121
  55. package/dist/vite.mjs.map +1 -1
  56. package/dist/webpackLoader.js +39 -9
  57. package/dist/webpackLoader.js.map +1 -1
  58. package/dist/webpackLoader.mjs +36 -7
  59. package/dist/webpackLoader.mjs.map +1 -1
  60. package/package.json +1 -1
  61. package/CHANGELOG.md +0 -182
package/dist/index.d.mts CHANGED
@@ -50,9 +50,10 @@ type InferStatesProps<T extends ComponentConfig> = {
50
50
  [K in keyof T["states"]]?: boolean;
51
51
  };
52
52
  /**
53
- * Sub config bisa berupa:
54
- * - string: "font-bold text-lg" → render <span>
55
- * - Record<name, string>: nested object per HTML tag
53
+ * Sub-component config bisa berupa:
54
+ * - string: "font-bold text-lg" → render <span> dengan classes
55
+ * - Record<componentName, string>: nested HTML tag dengan component names dan classes
56
+ * - Record<componentName, SubComponentConfig>: nested HTML tag dengan component names dan full variant config
56
57
  *
57
58
  * @example
58
59
  * sub: {
@@ -60,9 +61,19 @@ type InferStatesProps<T extends ComponentConfig> = {
60
61
  * header: { topBar: "bg-gray-900" }, // → <header> dipanggil Card.topBar
61
62
  * h2: { title: "text-xl font-bold" }, // → <h2> dipanggil Card.title
62
63
  * section: { content: "px-6 py-4" }, // → <section> dipanggil Card.content
64
+ * canvas: { base: "p-6", variants: { layout: { wrap: "gap-4", column: "gap-0" } } } // → <div> dengan variants
63
65
  * }
64
66
  */
65
- type SubValue = string | Record<string, string>;
67
+ interface SubComponentConfig {
68
+ base?: string;
69
+ variants?: Record<string, Record<string, string>>;
70
+ defaultVariants?: Record<string, string>;
71
+ compoundVariants?: Array<{
72
+ class: string;
73
+ [key: string]: string;
74
+ }>;
75
+ }
76
+ type SubValue = string | Record<string, string | SubComponentConfig>;
66
77
  /**
67
78
  * Boolean props yang di-resolve via bitmask lookup table (pre-generated di build time).
68
79
  * Berbeda dari `state` (CSS data-attribute driven) — ini adalah React props boolean.
@@ -108,6 +119,36 @@ interface ComponentConfig {
108
119
  * @internal — jangan set manual, ini di-inject otomatis saat build/dev.
109
120
  */
110
121
  __hash?: string;
122
+ /**
123
+ * Wave 3: Semantic component type untuk auto-generated ARIA metadata.
124
+ * Digunakan oleh build-time ARIA injection plugin untuk determine semantic role.
125
+ *
126
+ * Common values: 'button', 'link', 'checkbox', 'radio', 'input', 'form', 'dialog',
127
+ * 'navigation', 'heading', 'alert', 'tab', 'section', 'status', 'aside'
128
+ *
129
+ * @example
130
+ * '@semantic': 'button' // → auto-inject role="button"
131
+ * '@semantic': 'dialog' // → auto-inject role="dialog", aria-modal="true"
132
+ */
133
+ '@semantic'?: string;
134
+ /**
135
+ * Wave 3: Explicit ARIA attributes untuk semantic component.
136
+ * Merged dengan auto-injected ARIA dari semantic type.
137
+ * User-provided ARIA memiliki precedence lebih tinggi (tidak di-override).
138
+ *
139
+ * @example
140
+ * '@aria': { role: 'tab', 'aria-selected': 'true' }
141
+ */
142
+ '@aria'?: Record<string, string>;
143
+ /**
144
+ * Wave 3: State → ARIA property mapping untuk semantic metadata.
145
+ * Determines mana variant/state yang map ke ARIA properties.
146
+ *
147
+ * @example
148
+ * '@state': { expanded: 'aria-expanded', disabled: 'aria-disabled' }
149
+ * → When expanded prop true → aria-expanded="true" auto-injected
150
+ */
151
+ '@state'?: Record<string, string>;
111
152
  }
112
153
  /**
113
154
  * Strip tag prefix dari "tag:name" format sub key.
package/dist/index.d.ts CHANGED
@@ -50,9 +50,10 @@ type InferStatesProps<T extends ComponentConfig> = {
50
50
  [K in keyof T["states"]]?: boolean;
51
51
  };
52
52
  /**
53
- * Sub config bisa berupa:
54
- * - string: "font-bold text-lg" → render <span>
55
- * - Record<name, string>: nested object per HTML tag
53
+ * Sub-component config bisa berupa:
54
+ * - string: "font-bold text-lg" → render <span> dengan classes
55
+ * - Record<componentName, string>: nested HTML tag dengan component names dan classes
56
+ * - Record<componentName, SubComponentConfig>: nested HTML tag dengan component names dan full variant config
56
57
  *
57
58
  * @example
58
59
  * sub: {
@@ -60,9 +61,19 @@ type InferStatesProps<T extends ComponentConfig> = {
60
61
  * header: { topBar: "bg-gray-900" }, // → <header> dipanggil Card.topBar
61
62
  * h2: { title: "text-xl font-bold" }, // → <h2> dipanggil Card.title
62
63
  * section: { content: "px-6 py-4" }, // → <section> dipanggil Card.content
64
+ * canvas: { base: "p-6", variants: { layout: { wrap: "gap-4", column: "gap-0" } } } // → <div> dengan variants
63
65
  * }
64
66
  */
65
- type SubValue = string | Record<string, string>;
67
+ interface SubComponentConfig {
68
+ base?: string;
69
+ variants?: Record<string, Record<string, string>>;
70
+ defaultVariants?: Record<string, string>;
71
+ compoundVariants?: Array<{
72
+ class: string;
73
+ [key: string]: string;
74
+ }>;
75
+ }
76
+ type SubValue = string | Record<string, string | SubComponentConfig>;
66
77
  /**
67
78
  * Boolean props yang di-resolve via bitmask lookup table (pre-generated di build time).
68
79
  * Berbeda dari `state` (CSS data-attribute driven) — ini adalah React props boolean.
@@ -108,6 +119,36 @@ interface ComponentConfig {
108
119
  * @internal — jangan set manual, ini di-inject otomatis saat build/dev.
109
120
  */
110
121
  __hash?: string;
122
+ /**
123
+ * Wave 3: Semantic component type untuk auto-generated ARIA metadata.
124
+ * Digunakan oleh build-time ARIA injection plugin untuk determine semantic role.
125
+ *
126
+ * Common values: 'button', 'link', 'checkbox', 'radio', 'input', 'form', 'dialog',
127
+ * 'navigation', 'heading', 'alert', 'tab', 'section', 'status', 'aside'
128
+ *
129
+ * @example
130
+ * '@semantic': 'button' // → auto-inject role="button"
131
+ * '@semantic': 'dialog' // → auto-inject role="dialog", aria-modal="true"
132
+ */
133
+ '@semantic'?: string;
134
+ /**
135
+ * Wave 3: Explicit ARIA attributes untuk semantic component.
136
+ * Merged dengan auto-injected ARIA dari semantic type.
137
+ * User-provided ARIA memiliki precedence lebih tinggi (tidak di-override).
138
+ *
139
+ * @example
140
+ * '@aria': { role: 'tab', 'aria-selected': 'true' }
141
+ */
142
+ '@aria'?: Record<string, string>;
143
+ /**
144
+ * Wave 3: State → ARIA property mapping untuk semantic metadata.
145
+ * Determines mana variant/state yang map ke ARIA properties.
146
+ *
147
+ * @example
148
+ * '@state': { expanded: 'aria-expanded', disabled: 'aria-disabled' }
149
+ * → When expanded prop true → aria-expanded="true" auto-injected
150
+ */
151
+ '@state'?: Record<string, string>;
111
152
  }
112
153
  /**
113
154
  * Strip tag prefix dari "tag:name" format sub key.
package/dist/index.js CHANGED
@@ -5,6 +5,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __commonJS = (cb, mod) => function __require() {
12
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
+ };
8
14
  var __export = (target, all) => {
9
15
  for (var name in all)
10
16
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,6 +33,128 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
33
  ));
28
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
35
 
36
+ // node_modules/tsup/assets/cjs_shims.js
37
+ var init_cjs_shims = __esm({
38
+ "node_modules/tsup/assets/cjs_shims.js"() {
39
+ "use strict";
40
+ }
41
+ });
42
+
43
+ // packages/domain/runtime-css/dist/batched.cjs
44
+ var require_batched = __commonJS({
45
+ "packages/domain/runtime-css/dist/batched.cjs"(exports2, module2) {
46
+ "use strict";
47
+ "use client";
48
+ init_cjs_shims();
49
+ var __defProp2 = Object.defineProperty;
50
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
51
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
52
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
53
+ var __export2 = (target, all) => {
54
+ for (var name in all)
55
+ __defProp2(target, name, { get: all[name], enumerable: true });
56
+ };
57
+ var __copyProps2 = (to, from, except, desc) => {
58
+ if (from && typeof from === "object" || typeof from === "function") {
59
+ for (let key of __getOwnPropNames2(from))
60
+ if (!__hasOwnProp2.call(to, key) && key !== except)
61
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
62
+ }
63
+ return to;
64
+ };
65
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
66
+ var batchedInjector_exports = {};
67
+ __export2(batchedInjector_exports, {
68
+ batchedInject: () => batchedInject,
69
+ flushBatchedCss: () => flushBatchedCss,
70
+ getBatchedCssStats: () => getBatchedCssStats,
71
+ isInjected: () => isInjected,
72
+ resetBatchedCss: () => resetBatchedCss,
73
+ syncInject: () => syncInject
74
+ });
75
+ module2.exports = __toCommonJS2(batchedInjector_exports);
76
+ var injected = /* @__PURE__ */ new Set();
77
+ var pending = [];
78
+ var _state = {
79
+ rafHandle: null,
80
+ styleEl: null
81
+ };
82
+ function getStyleElement() {
83
+ if (_state.styleEl && document.head.contains(_state.styleEl)) return _state.styleEl;
84
+ _state.styleEl = document.createElement("style");
85
+ _state.styleEl.id = "__tw-runtime-css";
86
+ _state.styleEl.setAttribute("data-tw-batched", "true");
87
+ document.head.appendChild(_state.styleEl);
88
+ return _state.styleEl;
89
+ }
90
+ function insertRuleToSheet(cssRule) {
91
+ const trimmed = cssRule.trim();
92
+ if (!trimmed) return;
93
+ const el = getStyleElement();
94
+ const sheet = el.sheet;
95
+ if (sheet) {
96
+ try {
97
+ sheet.insertRule(trimmed, sheet.cssRules.length);
98
+ return;
99
+ } catch {
100
+ if (process.env.NODE_ENV === "development") {
101
+ console.warn("[tw] insertRule failed, falling back to textContent append for rule:", trimmed.slice(0, 80));
102
+ }
103
+ }
104
+ }
105
+ el.textContent = (el.textContent ?? "") + `
106
+ ${trimmed}`;
107
+ }
108
+ function batchedInject(cssRule) {
109
+ if (typeof window === "undefined") return;
110
+ if (!cssRule || injected.has(cssRule)) return;
111
+ injected.add(cssRule);
112
+ pending.push(cssRule);
113
+ if (_state.rafHandle === null) {
114
+ _state.rafHandle = requestAnimationFrame(flushBatchedCss);
115
+ }
116
+ }
117
+ function flushBatchedCss() {
118
+ _state.rafHandle = null;
119
+ if (pending.length === 0 || typeof document === "undefined") return;
120
+ const rules = pending.splice(0);
121
+ for (const rule of rules) {
122
+ insertRuleToSheet(rule);
123
+ }
124
+ }
125
+ function syncInject(cssRule) {
126
+ if (typeof document === "undefined") return;
127
+ if (!cssRule || injected.has(cssRule)) return;
128
+ injected.add(cssRule);
129
+ insertRuleToSheet(cssRule);
130
+ }
131
+ function isInjected(cssRule) {
132
+ return injected.has(cssRule);
133
+ }
134
+ function resetBatchedCss() {
135
+ injected.clear();
136
+ pending.length = 0;
137
+ if (_state.rafHandle !== null) {
138
+ cancelAnimationFrame(_state.rafHandle);
139
+ _state.rafHandle = null;
140
+ }
141
+ if (typeof document !== "undefined" && _state.styleEl && document.head.contains(_state.styleEl)) {
142
+ document.head.removeChild(_state.styleEl);
143
+ _state.styleEl = null;
144
+ } else {
145
+ _state.styleEl = null;
146
+ }
147
+ }
148
+ function getBatchedCssStats() {
149
+ return {
150
+ totalInjected: injected.size,
151
+ pendingCount: pending.length,
152
+ hasBatchScheduled: _state.rafHandle !== null
153
+ };
154
+ }
155
+ }
156
+ });
157
+
30
158
  // src/umbrella/index.ts
31
159
  var umbrella_exports = {};
32
160
  __export(umbrella_exports, {
@@ -61,14 +189,21 @@ __export(umbrella_exports, {
61
189
  withSubComponents: () => withSubComponents
62
190
  });
63
191
  module.exports = __toCommonJS(umbrella_exports);
192
+ init_cjs_shims();
64
193
 
65
194
  // packages/domain/core/src/twProxy.ts
195
+ init_cjs_shims();
66
196
  var import_react2 = __toESM(require("react"), 1);
67
197
 
68
198
  // packages/domain/core/src/createComponent.ts
199
+ init_cjs_shims();
69
200
  var import_react = __toESM(require("react"), 1);
70
201
 
202
+ // packages/domain/core/src/containerQuery.ts
203
+ init_cjs_shims();
204
+
71
205
  // packages/domain/core/src/native.browser.ts
206
+ init_cjs_shims();
72
207
  var getNativeBinding = () => null;
73
208
 
74
209
  // packages/domain/core/src/containerQuery.ts
@@ -122,7 +257,7 @@ function buildContainerRules(id, container, containerName) {
122
257
  }
123
258
  var _cqBatchedInjectFn = null;
124
259
  try {
125
- const mod = require("@tailwind-styled/runtime-css/batched");
260
+ const mod = require_batched();
126
261
  if (typeof mod?.batchedInject === "function") _cqBatchedInjectFn = mod.batchedInject;
127
262
  } catch {
128
263
  }
@@ -196,7 +331,11 @@ function getContainerRegistry() {
196
331
  return containerRegistry;
197
332
  }
198
333
 
334
+ // packages/domain/core/src/merge.ts
335
+ init_cjs_shims();
336
+
199
337
  // packages/domain/core/src/mergeFallback.ts
338
+ init_cjs_shims();
200
339
  var TEXT_SIZE_SUFFIXES = /* @__PURE__ */ new Set([
201
340
  "xs",
202
341
  "sm",
@@ -512,6 +651,7 @@ function mergeWithRules(rules, ...classLists) {
512
651
  }
513
652
 
514
653
  // packages/domain/core/src/parseTemplateFallback.ts
654
+ init_cjs_shims();
515
655
  var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
516
656
  var COMMENT_RE = /\/\/[^\n]*/g;
517
657
  function collapseSpaces(s) {
@@ -542,6 +682,7 @@ function parseTemplateJs(raw) {
542
682
  }
543
683
 
544
684
  // packages/domain/core/src/stateEngine.ts
685
+ init_cjs_shims();
545
686
  var stateRegistry = /* @__PURE__ */ new Map();
546
687
  if (typeof window !== "undefined") {
547
688
  window.__TW_STATE_REGISTRY__ = stateRegistry;
@@ -574,7 +715,7 @@ function generateStateRules(id, state) {
574
715
  var _staticCssDetected = /* @__PURE__ */ new Set();
575
716
  var _batchedInjectFn = null;
576
717
  try {
577
- const mod = require("@tailwind-styled/runtime-css/batched");
718
+ const mod = require_batched();
578
719
  if (typeof mod?.batchedInject === "function") _batchedInjectFn = mod.batchedInject;
579
720
  } catch {
580
721
  }
@@ -771,15 +912,21 @@ function registerSubComponents(component, template, configSub) {
771
912
  value.trim().replace(/\s+/g, " "),
772
913
  tag
773
914
  );
915
+ } else if ("base" in value || "variants" in value) {
916
+ map[key] = createComponent("div", value);
774
917
  } else {
775
918
  const tag = key;
776
- for (const [componentName, classes] of Object.entries(value)) {
777
- map[componentName] = createSubComponentAccessor(
778
- displayName,
779
- componentName,
780
- classes.trim().replace(/\s+/g, " "),
781
- tag
782
- );
919
+ for (const [componentName, classesOrConfig] of Object.entries(value)) {
920
+ if (typeof classesOrConfig === "string") {
921
+ map[componentName] = createSubComponentAccessor(
922
+ displayName,
923
+ componentName,
924
+ classesOrConfig.trim().replace(/\s+/g, " "),
925
+ tag
926
+ );
927
+ } else {
928
+ map[componentName] = createComponent(tag, classesOrConfig);
929
+ }
783
930
  }
784
931
  }
785
932
  }
@@ -1022,6 +1169,10 @@ var SKIP_PROXY_KEYS = /* @__PURE__ */ new Set([
1022
1169
  ]);
1023
1170
  function wrapWithSubProxy(component, tagLabel) {
1024
1171
  return new Proxy(component, {
1172
+ // Forward function calls to target component
1173
+ apply(target, thisArg, args) {
1174
+ return Reflect.apply(target, thisArg, args);
1175
+ },
1025
1176
  get(target, prop) {
1026
1177
  const value = target[prop];
1027
1178
  if (value !== void 0) return value;
@@ -1220,6 +1371,7 @@ var tw = Object.assign(twCallable, tagFactories, {
1220
1371
  });
1221
1372
 
1222
1373
  // packages/domain/core/src/cv.ts
1374
+ init_cjs_shims();
1223
1375
  var __generatedRegistry = {};
1224
1376
  function registerVariantTable(componentId, table) {
1225
1377
  __generatedRegistry[componentId] = table;
@@ -1355,6 +1507,7 @@ function cv(config, componentId) {
1355
1507
  }
1356
1508
 
1357
1509
  // packages/domain/core/src/cx.ts
1510
+ init_cjs_shims();
1358
1511
  function cn(...inputs) {
1359
1512
  const strings = [];
1360
1513
  for (const item of inputs) {
@@ -1391,6 +1544,7 @@ function cx(...inputs) {
1391
1544
  var cxm = cx;
1392
1545
 
1393
1546
  // packages/domain/core/src/styledSystem.ts
1547
+ init_cjs_shims();
1394
1548
  function tokenVarName(prefix, group, name) {
1395
1549
  return `--${prefix}-${group}-${name}`;
1396
1550
  }
@@ -1556,6 +1710,7 @@ function createStyledSystem(config) {
1556
1710
  }
1557
1711
 
1558
1712
  // packages/domain/core/src/styled.ts
1713
+ init_cjs_shims();
1559
1714
  function resolveVariantClass(options, props) {
1560
1715
  const out = [];
1561
1716
  const variants = options.variants ?? {};
@@ -1587,6 +1742,7 @@ function styled(options) {
1587
1742
  }
1588
1743
 
1589
1744
  // packages/domain/core/src/twTheme.ts
1745
+ init_cjs_shims();
1590
1746
  function cssVar(varName, fallback) {
1591
1747
  const name = varName.startsWith("--") ? varName : `--${varName}`;
1592
1748
  return fallback ? `var(${name}, ${fallback})` : `var(${name})`;
@@ -1652,6 +1808,7 @@ var v4Tokens = {
1652
1808
  };
1653
1809
 
1654
1810
  // packages/domain/core/src/registry.ts
1811
+ init_cjs_shims();
1655
1812
  var import_react3 = __toESM(require("react"), 1);
1656
1813
  var subComponentRegistry = /* @__PURE__ */ new Map();
1657
1814
  function registerSubComponent(entry) {