tailwind-styled-v4 1.0.1 → 5.0.0
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/animate.cjs +771 -0
- package/dist/animate.cjs.map +1 -0
- package/dist/animate.d.cts +73 -0
- package/dist/animate.d.ts +73 -0
- package/dist/animate.js +752 -0
- package/dist/animate.js.map +1 -0
- package/dist/chunk-VZEJV27B.js +11 -0
- package/dist/chunk-VZEJV27B.js.map +1 -0
- package/dist/chunk-Y5D3E72P.cjs +13 -0
- package/dist/chunk-Y5D3E72P.cjs.map +1 -0
- package/dist/css.cjs +121 -0
- package/dist/css.cjs.map +1 -0
- package/dist/css.d.cts +30 -0
- package/dist/css.d.ts +30 -0
- package/dist/css.js +112 -0
- package/dist/css.js.map +1 -0
- package/dist/devtools.cjs +1071 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.cts +22 -0
- package/dist/devtools.d.ts +22 -0
- package/dist/devtools.js +1064 -0
- package/dist/devtools.js.map +1 -0
- package/dist/index.cjs +1353 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +655 -0
- package/dist/index.d.ts +508 -968
- package/dist/index.js +1304 -3
- package/dist/index.js.map +1 -1
- package/dist/next.cjs +248 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +54 -0
- package/dist/next.d.ts +54 -0
- package/dist/next.js +241 -0
- package/dist/next.js.map +1 -0
- package/dist/preset.cjs +423 -0
- package/dist/preset.cjs.map +1 -0
- package/dist/preset.d.cts +276 -0
- package/dist/preset.d.ts +276 -0
- package/dist/preset.js +416 -0
- package/dist/preset.js.map +1 -0
- package/dist/turbopackLoader.cjs +37 -0
- package/dist/turbopackLoader.cjs.map +1 -0
- package/dist/turbopackLoader.d.cts +12 -0
- package/dist/turbopackLoader.d.ts +12 -0
- package/dist/turbopackLoader.js +35 -0
- package/dist/turbopackLoader.js.map +1 -0
- package/dist/vite.cjs +138 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.cts +51 -0
- package/dist/vite.d.ts +51 -0
- package/dist/vite.js +128 -0
- package/dist/vite.js.map +1 -0
- package/dist/webpackLoader.cjs +51 -0
- package/dist/webpackLoader.cjs.map +1 -0
- package/dist/webpackLoader.d.cts +17 -0
- package/dist/webpackLoader.d.ts +17 -0
- package/dist/webpackLoader.js +49 -0
- package/dist/webpackLoader.js.map +1 -0
- package/package.json +65 -32
- package/CHANGELOG.md +0 -75
- package/LICENSE +0 -21
- package/README.md +0 -608
- package/dist/cli/init.js +0 -208
- package/dist/compiler/index.d.mts +0 -214
- package/dist/compiler/index.d.ts +0 -214
- package/dist/compiler/index.js +0 -546
- package/dist/compiler/index.js.map +0 -1
- package/dist/compiler/index.mjs +0 -504
- package/dist/compiler/index.mjs.map +0 -1
- package/dist/index.d.mts +0 -1115
- package/dist/index.mjs +0 -4
- package/dist/index.mjs.map +0 -1
- package/dist/turbopack-loader.js +0 -232
- package/dist/webpack-loader.js +0 -213
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1353 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkY5D3E72P_cjs = require('./chunk-Y5D3E72P.cjs');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var tailwindMerge = require('tailwind-merge');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
10
|
+
|
|
11
|
+
/* tailwind-styled-v4 v4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
12
|
+
|
|
13
|
+
// src/containerQuery.ts
|
|
14
|
+
var CONTAINER_BREAKPOINTS = {
|
|
15
|
+
xs: "240px",
|
|
16
|
+
sm: "320px",
|
|
17
|
+
md: "640px",
|
|
18
|
+
lg: "1024px",
|
|
19
|
+
xl: "1280px",
|
|
20
|
+
"2xl": "1536px"
|
|
21
|
+
};
|
|
22
|
+
var containerRegistry = /* @__PURE__ */ new Map();
|
|
23
|
+
if (typeof window !== "undefined") {
|
|
24
|
+
window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
|
|
25
|
+
}
|
|
26
|
+
function hashContainer(tag, container, name) {
|
|
27
|
+
const key = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
|
|
28
|
+
let hash = 5381;
|
|
29
|
+
for (let i = 0; i < key.length; i++) {
|
|
30
|
+
hash = (hash << 5) + hash ^ key.charCodeAt(i);
|
|
31
|
+
}
|
|
32
|
+
return `tw-cq-${Math.abs(hash).toString(36).slice(0, 6)}`;
|
|
33
|
+
}
|
|
34
|
+
var LAYOUT_MAP = {
|
|
35
|
+
"flex-col": "flex-direction:column",
|
|
36
|
+
"flex-row": "flex-direction:row",
|
|
37
|
+
"flex-wrap": "flex-wrap:wrap",
|
|
38
|
+
"flex-nowrap": "flex-wrap:nowrap",
|
|
39
|
+
"flex-1": "flex:1 1 0%",
|
|
40
|
+
hidden: "display:none",
|
|
41
|
+
block: "display:block",
|
|
42
|
+
flex: "display:flex",
|
|
43
|
+
grid: "display:grid",
|
|
44
|
+
"grid-cols-1": "grid-template-columns:repeat(1,minmax(0,1fr))",
|
|
45
|
+
"grid-cols-2": "grid-template-columns:repeat(2,minmax(0,1fr))",
|
|
46
|
+
"grid-cols-3": "grid-template-columns:repeat(3,minmax(0,1fr))",
|
|
47
|
+
"grid-cols-4": "grid-template-columns:repeat(4,minmax(0,1fr))",
|
|
48
|
+
"grid-cols-6": "grid-template-columns:repeat(6,minmax(0,1fr))",
|
|
49
|
+
"grid-cols-12": "grid-template-columns:repeat(12,minmax(0,1fr))",
|
|
50
|
+
"text-sm": "font-size:0.875rem;line-height:1.25rem",
|
|
51
|
+
"text-base": "font-size:1rem;line-height:1.5rem",
|
|
52
|
+
"text-lg": "font-size:1.125rem;line-height:1.75rem",
|
|
53
|
+
"text-xl": "font-size:1.25rem;line-height:1.75rem",
|
|
54
|
+
"text-2xl": "font-size:1.5rem;line-height:2rem",
|
|
55
|
+
"text-xs": "font-size:0.75rem;line-height:1rem",
|
|
56
|
+
"p-2": "padding:0.5rem",
|
|
57
|
+
"p-4": "padding:1rem",
|
|
58
|
+
"p-6": "padding:1.5rem",
|
|
59
|
+
"p-8": "padding:2rem",
|
|
60
|
+
"px-2": "padding-left:0.5rem;padding-right:0.5rem",
|
|
61
|
+
"px-4": "padding-left:1rem;padding-right:1rem",
|
|
62
|
+
"px-6": "padding-left:1.5rem;padding-right:1.5rem",
|
|
63
|
+
"py-2": "padding-top:0.5rem;padding-bottom:0.5rem",
|
|
64
|
+
"py-4": "padding-top:1rem;padding-bottom:1rem",
|
|
65
|
+
"gap-2": "gap:0.5rem",
|
|
66
|
+
"gap-4": "gap:1rem",
|
|
67
|
+
"gap-6": "gap:1.5rem",
|
|
68
|
+
"gap-8": "gap:2rem",
|
|
69
|
+
"w-full": "width:100%",
|
|
70
|
+
"w-1/2": "width:50%",
|
|
71
|
+
"w-1/3": "width:33.333333%",
|
|
72
|
+
"w-2/3": "width:66.666667%",
|
|
73
|
+
"max-w-sm": "max-width:24rem",
|
|
74
|
+
"max-w-md": "max-width:28rem",
|
|
75
|
+
"max-w-lg": "max-width:32rem",
|
|
76
|
+
"max-w-xl": "max-width:36rem",
|
|
77
|
+
"items-center": "align-items:center",
|
|
78
|
+
"items-start": "align-items:flex-start",
|
|
79
|
+
"items-end": "align-items:flex-end",
|
|
80
|
+
"justify-center": "justify-content:center",
|
|
81
|
+
"justify-between": "justify-content:space-between",
|
|
82
|
+
"justify-start": "justify-content:flex-start",
|
|
83
|
+
"justify-end": "justify-content:flex-end"
|
|
84
|
+
};
|
|
85
|
+
function layoutClassesToCss(classes) {
|
|
86
|
+
const decls = [];
|
|
87
|
+
for (const cls of classes.trim().split(/\s+/)) {
|
|
88
|
+
if (LAYOUT_MAP[cls]) decls.push(LAYOUT_MAP[cls]);
|
|
89
|
+
else if (cls.startsWith("w-[")) {
|
|
90
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
91
|
+
if (val) decls.push(`width:${val}`);
|
|
92
|
+
} else if (cls.startsWith("max-w-[")) {
|
|
93
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
94
|
+
if (val) decls.push(`max-width:${val}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return decls.join(";");
|
|
98
|
+
}
|
|
99
|
+
function buildContainerRules(id, container, containerName) {
|
|
100
|
+
const rules = [];
|
|
101
|
+
for (const [key, value] of Object.entries(container)) {
|
|
102
|
+
let minWidth;
|
|
103
|
+
let classes;
|
|
104
|
+
if (typeof value === "string") {
|
|
105
|
+
minWidth = CONTAINER_BREAKPOINTS[key] ?? key;
|
|
106
|
+
classes = value;
|
|
107
|
+
} else {
|
|
108
|
+
minWidth = value.minWidth ?? CONTAINER_BREAKPOINTS[key] ?? key;
|
|
109
|
+
classes = value.classes;
|
|
110
|
+
}
|
|
111
|
+
const css = layoutClassesToCss(classes);
|
|
112
|
+
if (!css) continue;
|
|
113
|
+
const query = containerName ? `@container ${containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
|
|
114
|
+
rules.push(`${query}{.${id}{${css}}}`);
|
|
115
|
+
}
|
|
116
|
+
return rules.join("\n");
|
|
117
|
+
}
|
|
118
|
+
function injectContainerStyles(id, container, containerName) {
|
|
119
|
+
if (typeof document === "undefined") return;
|
|
120
|
+
const styleId = `tw-cq-${id}`;
|
|
121
|
+
if (document.getElementById(styleId)) return;
|
|
122
|
+
const css = buildContainerRules(id, container, containerName);
|
|
123
|
+
if (!css) return;
|
|
124
|
+
try {
|
|
125
|
+
const { batchedInject } = chunkY5D3E72P_cjs.__require("@tailwind-styled/runtime-css/batched");
|
|
126
|
+
for (const rule of css.split("\n").filter(Boolean)) batchedInject(rule);
|
|
127
|
+
return;
|
|
128
|
+
} catch {
|
|
129
|
+
}
|
|
130
|
+
const style = document.createElement("style");
|
|
131
|
+
style.id = styleId;
|
|
132
|
+
style.setAttribute("data-tw-container", id);
|
|
133
|
+
style.textContent = css;
|
|
134
|
+
document.head.appendChild(style);
|
|
135
|
+
}
|
|
136
|
+
function processContainer(tag, container, containerName) {
|
|
137
|
+
const id = hashContainer(tag, container, containerName);
|
|
138
|
+
if (!containerRegistry.has(id)) {
|
|
139
|
+
const breakpoints = Object.entries(container).map(([key, value]) => ({
|
|
140
|
+
minWidth: CONTAINER_BREAKPOINTS[key] ?? key,
|
|
141
|
+
classes: typeof value === "string" ? value : value.classes
|
|
142
|
+
}));
|
|
143
|
+
containerRegistry.set(id, {
|
|
144
|
+
id,
|
|
145
|
+
tag,
|
|
146
|
+
containerName,
|
|
147
|
+
breakpoints,
|
|
148
|
+
cssInjected: false
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
injectContainerStyles(id, container, containerName);
|
|
152
|
+
containerRegistry.get(id).cssInjected = true;
|
|
153
|
+
return { containerClass: id, hasContainer: true };
|
|
154
|
+
}
|
|
155
|
+
function generateContainerCss(tag, container, containerName) {
|
|
156
|
+
const id = hashContainer(tag, container, containerName);
|
|
157
|
+
return buildContainerRules(id, container, containerName);
|
|
158
|
+
}
|
|
159
|
+
function getContainerRegistry() {
|
|
160
|
+
return containerRegistry;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// src/stateEngine.ts
|
|
164
|
+
var stateRegistry = /* @__PURE__ */ new Map();
|
|
165
|
+
if (typeof window !== "undefined") {
|
|
166
|
+
window.__TW_STATE_REGISTRY__ = stateRegistry;
|
|
167
|
+
}
|
|
168
|
+
function hashState(tag, state) {
|
|
169
|
+
const key = tag + JSON.stringify(Object.entries(state).sort());
|
|
170
|
+
let hash = 5381;
|
|
171
|
+
for (let i = 0; i < key.length; i++) {
|
|
172
|
+
hash = (hash << 5) + hash ^ key.charCodeAt(i);
|
|
173
|
+
}
|
|
174
|
+
return `tw-s-${Math.abs(hash).toString(36).slice(0, 6)}`;
|
|
175
|
+
}
|
|
176
|
+
var TW_MAP = {
|
|
177
|
+
// Display
|
|
178
|
+
hidden: "display:none",
|
|
179
|
+
block: "display:block",
|
|
180
|
+
flex: "display:flex",
|
|
181
|
+
inline: "display:inline",
|
|
182
|
+
"inline-flex": "display:inline-flex",
|
|
183
|
+
grid: "display:grid",
|
|
184
|
+
// Opacity
|
|
185
|
+
"opacity-0": "opacity:0",
|
|
186
|
+
"opacity-5": "opacity:0.05",
|
|
187
|
+
"opacity-10": "opacity:0.1",
|
|
188
|
+
"opacity-20": "opacity:0.2",
|
|
189
|
+
"opacity-25": "opacity:0.25",
|
|
190
|
+
"opacity-30": "opacity:0.3",
|
|
191
|
+
"opacity-40": "opacity:0.4",
|
|
192
|
+
"opacity-50": "opacity:0.5",
|
|
193
|
+
"opacity-60": "opacity:0.6",
|
|
194
|
+
"opacity-70": "opacity:0.7",
|
|
195
|
+
"opacity-75": "opacity:0.75",
|
|
196
|
+
"opacity-80": "opacity:0.8",
|
|
197
|
+
"opacity-90": "opacity:0.9",
|
|
198
|
+
"opacity-95": "opacity:0.95",
|
|
199
|
+
"opacity-100": "opacity:1",
|
|
200
|
+
// Cursor
|
|
201
|
+
"cursor-pointer": "cursor:pointer",
|
|
202
|
+
"cursor-not-allowed": "cursor:not-allowed",
|
|
203
|
+
"cursor-default": "cursor:default",
|
|
204
|
+
"cursor-wait": "cursor:wait",
|
|
205
|
+
"cursor-move": "cursor:move",
|
|
206
|
+
"cursor-grab": "cursor:grab",
|
|
207
|
+
"cursor-grabbing": "cursor:grabbing",
|
|
208
|
+
// Pointer events
|
|
209
|
+
"pointer-events-none": "pointer-events:none",
|
|
210
|
+
"pointer-events-auto": "pointer-events:auto",
|
|
211
|
+
// Scale
|
|
212
|
+
"scale-90": "transform:scale(0.9)",
|
|
213
|
+
"scale-95": "transform:scale(0.95)",
|
|
214
|
+
"scale-100": "transform:scale(1)",
|
|
215
|
+
"scale-105": "transform:scale(1.05)",
|
|
216
|
+
"scale-110": "transform:scale(1.1)",
|
|
217
|
+
// Translate
|
|
218
|
+
"translate-x-0": "transform:translateX(0)",
|
|
219
|
+
"translate-y-0": "transform:translateY(0)",
|
|
220
|
+
"-translate-x-1": "transform:translateX(-0.25rem)",
|
|
221
|
+
"-translate-y-1": "transform:translateY(-0.25rem)",
|
|
222
|
+
"translate-x-1": "transform:translateX(0.25rem)",
|
|
223
|
+
"translate-y-1": "transform:translateY(0.25rem)",
|
|
224
|
+
// Ring
|
|
225
|
+
ring: "box-shadow:0 0 0 3px rgba(59,130,246,0.5)",
|
|
226
|
+
"ring-2": "box-shadow:0 0 0 2px rgba(59,130,246,0.5)",
|
|
227
|
+
"ring-4": "box-shadow:0 0 0 4px rgba(59,130,246,0.5)",
|
|
228
|
+
"ring-inset": "box-shadow:inset 0 0 0 3px rgba(59,130,246,0.5)",
|
|
229
|
+
// Border
|
|
230
|
+
border: "border-width:1px",
|
|
231
|
+
"border-2": "border-width:2px",
|
|
232
|
+
"border-transparent": "border-color:transparent",
|
|
233
|
+
// Outline
|
|
234
|
+
"outline-none": "outline:2px solid transparent;outline-offset:2px",
|
|
235
|
+
outline: "outline:2px solid currentColor",
|
|
236
|
+
// Overflow
|
|
237
|
+
"overflow-hidden": "overflow:hidden",
|
|
238
|
+
"overflow-auto": "overflow:auto",
|
|
239
|
+
"overflow-scroll": "overflow:scroll",
|
|
240
|
+
// Text decoration
|
|
241
|
+
underline: "text-decoration-line:underline",
|
|
242
|
+
"no-underline": "text-decoration-line:none",
|
|
243
|
+
"line-through": "text-decoration-line:line-through",
|
|
244
|
+
// Font weight
|
|
245
|
+
"font-bold": "font-weight:700",
|
|
246
|
+
"font-semibold": "font-weight:600",
|
|
247
|
+
"font-medium": "font-weight:500",
|
|
248
|
+
"font-normal": "font-weight:400",
|
|
249
|
+
// Background colors (common)
|
|
250
|
+
"bg-transparent": "background-color:transparent",
|
|
251
|
+
"bg-white": "background-color:#fff",
|
|
252
|
+
"bg-black": "background-color:#000",
|
|
253
|
+
"bg-blue-500": "background-color:rgb(59,130,246)",
|
|
254
|
+
"bg-blue-600": "background-color:rgb(37,99,235)",
|
|
255
|
+
"bg-red-500": "background-color:rgb(239,68,68)",
|
|
256
|
+
"bg-green-500": "background-color:rgb(34,197,94)",
|
|
257
|
+
"bg-yellow-500": "background-color:rgb(234,179,8)",
|
|
258
|
+
"bg-zinc-900": "background-color:rgb(24,24,27)",
|
|
259
|
+
"bg-zinc-800": "background-color:rgb(39,39,42)",
|
|
260
|
+
// Text colors
|
|
261
|
+
"text-white": "color:#fff",
|
|
262
|
+
"text-black": "color:#000",
|
|
263
|
+
"text-blue-500": "color:rgb(59,130,246)",
|
|
264
|
+
"text-red-500": "color:rgb(239,68,68)",
|
|
265
|
+
"text-zinc-400": "color:rgb(161,161,170)",
|
|
266
|
+
"text-zinc-500": "color:rgb(113,113,122)"
|
|
267
|
+
};
|
|
268
|
+
function twClassesToCss(classes) {
|
|
269
|
+
const decls = [];
|
|
270
|
+
for (const cls of classes.trim().split(/\s+/)) {
|
|
271
|
+
if (TW_MAP[cls]) decls.push(TW_MAP[cls]);
|
|
272
|
+
else if (cls.includes("[") && cls.includes("]")) {
|
|
273
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
274
|
+
if (!val) continue;
|
|
275
|
+
if (cls.startsWith("bg-[")) decls.push(`background-color:${val}`);
|
|
276
|
+
else if (cls.startsWith("text-[")) decls.push(`color:${val}`);
|
|
277
|
+
else if (cls.startsWith("w-[")) decls.push(`width:${val}`);
|
|
278
|
+
else if (cls.startsWith("h-[")) decls.push(`height:${val}`);
|
|
279
|
+
else if (cls.startsWith("opacity-[")) decls.push(`opacity:${val}`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return decls.join(";");
|
|
283
|
+
}
|
|
284
|
+
function injectStateStyles(id, state) {
|
|
285
|
+
if (typeof document === "undefined") return;
|
|
286
|
+
const styleId = `tw-state-${id}`;
|
|
287
|
+
if (document.getElementById(styleId)) return;
|
|
288
|
+
const rules = [];
|
|
289
|
+
for (const [stateName, classes] of Object.entries(state)) {
|
|
290
|
+
const css = twClassesToCss(classes);
|
|
291
|
+
if (css) {
|
|
292
|
+
rules.push(`.${id}[data-${stateName}="true"]{${css}}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (rules.length === 0) return;
|
|
296
|
+
try {
|
|
297
|
+
const { batchedInject } = chunkY5D3E72P_cjs.__require("@tailwind-styled/runtime-css/batched");
|
|
298
|
+
for (const rule of rules) batchedInject(rule);
|
|
299
|
+
return;
|
|
300
|
+
} catch {
|
|
301
|
+
}
|
|
302
|
+
const style = document.createElement("style");
|
|
303
|
+
style.id = styleId;
|
|
304
|
+
style.setAttribute("data-tw-state", id);
|
|
305
|
+
style.textContent = rules.join("\n");
|
|
306
|
+
document.head.appendChild(style);
|
|
307
|
+
}
|
|
308
|
+
function processState(tag, state) {
|
|
309
|
+
const id = hashState(tag, state);
|
|
310
|
+
const stateNames = Object.keys(state);
|
|
311
|
+
if (!stateRegistry.has(id)) {
|
|
312
|
+
stateRegistry.set(id, {
|
|
313
|
+
id,
|
|
314
|
+
tag,
|
|
315
|
+
states: stateNames,
|
|
316
|
+
cssInjected: false
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
injectStateStyles(id, state);
|
|
320
|
+
const entry = stateRegistry.get(id);
|
|
321
|
+
entry.cssInjected = true;
|
|
322
|
+
return { stateClass: id, hasState: true, stateNames };
|
|
323
|
+
}
|
|
324
|
+
function generateStateCss(tag, state) {
|
|
325
|
+
const id = hashState(tag, state);
|
|
326
|
+
const rules = [];
|
|
327
|
+
for (const [stateName, classes] of Object.entries(state)) {
|
|
328
|
+
const css = twClassesToCss(classes);
|
|
329
|
+
if (css) {
|
|
330
|
+
rules.push(`.${id}[data-${stateName}="true"]{${css}}`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return rules.join("\n");
|
|
334
|
+
}
|
|
335
|
+
function getStateRegistry() {
|
|
336
|
+
return stateRegistry;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/createComponent.ts
|
|
340
|
+
var ALWAYS_BLOCKED = /* @__PURE__ */ new Set(["base", "_ref", "state", "container", "containerName"]);
|
|
341
|
+
function makeFilterProps(variantKeys) {
|
|
342
|
+
return function filterProps(props) {
|
|
343
|
+
const out = {};
|
|
344
|
+
for (const key in props) {
|
|
345
|
+
if (variantKeys.has(key)) continue;
|
|
346
|
+
if (key.startsWith("$")) continue;
|
|
347
|
+
if (ALWAYS_BLOCKED.has(key)) continue;
|
|
348
|
+
out[key] = props[key];
|
|
349
|
+
}
|
|
350
|
+
return out;
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
function resolveVariants(variants, props, defaults) {
|
|
354
|
+
const classes = [];
|
|
355
|
+
for (const key in variants) {
|
|
356
|
+
const val = props[key] ?? defaults[key];
|
|
357
|
+
if (val !== void 0 && variants[key][String(val)]) {
|
|
358
|
+
classes.push(variants[key][String(val)]);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return classes.join(" ");
|
|
362
|
+
}
|
|
363
|
+
function resolveCompound(compounds, props) {
|
|
364
|
+
const classes = [];
|
|
365
|
+
for (const compound of compounds) {
|
|
366
|
+
const { class: cls, ...conditions } = compound;
|
|
367
|
+
const match = Object.entries(conditions).every(([k, v]) => props[k] === v);
|
|
368
|
+
if (match) classes.push(cls);
|
|
369
|
+
}
|
|
370
|
+
return classes.join(" ");
|
|
371
|
+
}
|
|
372
|
+
function createComponent(tag, config) {
|
|
373
|
+
const isStatic = typeof config === "string";
|
|
374
|
+
const base = isStatic ? config : config.base ?? "";
|
|
375
|
+
const variants = isStatic ? {} : config.variants ?? {};
|
|
376
|
+
const compoundVariants = isStatic ? [] : config.compoundVariants ?? [];
|
|
377
|
+
const defaultVariants = isStatic ? {} : config.defaultVariants ?? {};
|
|
378
|
+
const stateConfig = isStatic ? void 0 : config.state;
|
|
379
|
+
const containerConfig = isStatic ? void 0 : config.container;
|
|
380
|
+
const containerName = isStatic ? void 0 : config.containerName;
|
|
381
|
+
const stateResult = stateConfig ? processState(typeof tag === "string" ? tag : "component", stateConfig) : null;
|
|
382
|
+
const containerResult = containerConfig ? processContainer(typeof tag === "string" ? tag : "component", containerConfig, containerName) : null;
|
|
383
|
+
const engineClasses = [stateResult?.stateClass, containerResult?.containerClass].filter(Boolean).join(" ");
|
|
384
|
+
const variantKeySet = new Set(Object.keys(variants));
|
|
385
|
+
const filterProps = makeFilterProps(variantKeySet);
|
|
386
|
+
const tagStr = typeof tag === "string" ? tag : tag.displayName ?? "Component";
|
|
387
|
+
if (isStatic || Object.keys(variants).length === 0) {
|
|
388
|
+
const Component2 = React__default.default.forwardRef((props, ref) => {
|
|
389
|
+
const { className, ...rest } = props;
|
|
390
|
+
return React__default.default.createElement(tag, {
|
|
391
|
+
ref,
|
|
392
|
+
...filterProps(rest),
|
|
393
|
+
className: tailwindMerge.twMerge(base, engineClasses, className)
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
Component2.displayName = `tw.${tagStr}`;
|
|
397
|
+
attachExtend(Component2, tag, base, config);
|
|
398
|
+
return Component2;
|
|
399
|
+
}
|
|
400
|
+
const Component = React__default.default.forwardRef((props, ref) => {
|
|
401
|
+
const { className } = props;
|
|
402
|
+
const variantClasses = resolveVariants(variants, props, defaultVariants);
|
|
403
|
+
const compoundClasses = resolveCompound(compoundVariants, props);
|
|
404
|
+
return React__default.default.createElement(tag, {
|
|
405
|
+
ref,
|
|
406
|
+
...filterProps(props),
|
|
407
|
+
className: tailwindMerge.twMerge(base, variantClasses, compoundClasses, engineClasses, className)
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
Component.displayName = `tw.${tagStr}`;
|
|
411
|
+
attachExtend(Component, tag, base, config);
|
|
412
|
+
return Component;
|
|
413
|
+
}
|
|
414
|
+
function attachExtend(Component, originalTag, base, config) {
|
|
415
|
+
Component.extend = (strings, ..._exprs) => {
|
|
416
|
+
const extra = strings.raw.join("").trim().replace(/\s+/g, " ");
|
|
417
|
+
const merged = tailwindMerge.twMerge(base, extra);
|
|
418
|
+
return createComponent(
|
|
419
|
+
originalTag,
|
|
420
|
+
typeof config === "string" ? merged : { ...config, base: merged }
|
|
421
|
+
);
|
|
422
|
+
};
|
|
423
|
+
Component.withVariants = (newConfig) => {
|
|
424
|
+
const existing = typeof config === "object" ? config : {};
|
|
425
|
+
return createComponent(originalTag, {
|
|
426
|
+
...existing,
|
|
427
|
+
base,
|
|
428
|
+
variants: { ...existing.variants ?? void 0, ...newConfig.variants ?? void 0 },
|
|
429
|
+
compoundVariants: [
|
|
430
|
+
...existing.compoundVariants ?? [],
|
|
431
|
+
...newConfig.compoundVariants ?? []
|
|
432
|
+
],
|
|
433
|
+
defaultVariants: {
|
|
434
|
+
...existing.defaultVariants ?? void 0,
|
|
435
|
+
...newConfig.defaultVariants ?? void 0
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
Component.animate = async (opts) => {
|
|
440
|
+
try {
|
|
441
|
+
const { animate: animateFn } = chunkY5D3E72P_cjs.__require("@tailwind-styled/animate");
|
|
442
|
+
const animClass = await animateFn(opts);
|
|
443
|
+
const merged = tailwindMerge.twMerge(base, animClass);
|
|
444
|
+
return createComponent(
|
|
445
|
+
originalTag,
|
|
446
|
+
typeof config === "string" ? merged : { ...config, base: merged }
|
|
447
|
+
);
|
|
448
|
+
} catch {
|
|
449
|
+
console.warn("[tailwind-styled-v4] .animate() requires @tailwind-styled/animate");
|
|
450
|
+
return Component;
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function cv(config) {
|
|
455
|
+
const { base = "", variants = {}, compoundVariants = [], defaultVariants = {} } = config;
|
|
456
|
+
return (props = {}) => {
|
|
457
|
+
const classes = [base];
|
|
458
|
+
for (const key in variants) {
|
|
459
|
+
const val = props[key] ?? defaultVariants[key];
|
|
460
|
+
if (val !== void 0 && variants[key][String(val)]) {
|
|
461
|
+
classes.push(variants[key][String(val)]);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
for (const compound of compoundVariants) {
|
|
465
|
+
const { class: cls, ...conditions } = compound;
|
|
466
|
+
const match = Object.entries(conditions).every(([k, v]) => props[k] === v);
|
|
467
|
+
if (match) classes.push(cls);
|
|
468
|
+
}
|
|
469
|
+
if (props.className) classes.push(props.className);
|
|
470
|
+
return tailwindMerge.twMerge(...classes);
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function cn(...inputs) {
|
|
474
|
+
return inputs.filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
475
|
+
}
|
|
476
|
+
function cx(...inputs) {
|
|
477
|
+
return tailwindMerge.twMerge(...inputs.filter(Boolean));
|
|
478
|
+
}
|
|
479
|
+
var cxm = cx;
|
|
480
|
+
function normalizeClassInput(classLists) {
|
|
481
|
+
return classLists.filter(Boolean).map((v) => String(v).trim()).filter((v) => v.length > 0);
|
|
482
|
+
}
|
|
483
|
+
function createTwMerge(_options = {}) {
|
|
484
|
+
return function twMerge5(...classLists) {
|
|
485
|
+
const clean = normalizeClassInput(classLists);
|
|
486
|
+
return tailwindMerge.twMerge(clean.join(" "));
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
var twMerge4 = createTwMerge();
|
|
490
|
+
function mergeWithRules(rules, ...classLists) {
|
|
491
|
+
const base = twMerge4(...classLists);
|
|
492
|
+
let classes = base.split(/\s+/).filter(Boolean);
|
|
493
|
+
for (const rule of Object.values(rules)) {
|
|
494
|
+
const next = rule(classes);
|
|
495
|
+
classes = twMerge4(next).split(/\s+/).filter(Boolean);
|
|
496
|
+
}
|
|
497
|
+
return classes.join(" ");
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// src/liveTokenEngine.ts
|
|
501
|
+
var _currentTokens = {};
|
|
502
|
+
var _subscribers = /* @__PURE__ */ new Set();
|
|
503
|
+
var _styleEl = null;
|
|
504
|
+
if (typeof window !== "undefined") {
|
|
505
|
+
window.__TW_TOKEN_ENGINE__ = {
|
|
506
|
+
getTokens: () => _currentTokens,
|
|
507
|
+
setToken: (name, value) => setToken(name, value),
|
|
508
|
+
subscribe: (fn) => subscribeTokens(fn)
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function tokenVar(name) {
|
|
512
|
+
const normalized = name.replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
|
|
513
|
+
return `--tw-token-${normalized}`;
|
|
514
|
+
}
|
|
515
|
+
function tokenRef(name) {
|
|
516
|
+
return `var(${tokenVar(name)})`;
|
|
517
|
+
}
|
|
518
|
+
function buildRootCss(tokens) {
|
|
519
|
+
const vars = Object.entries(tokens).map(([name, value]) => ` ${tokenVar(name)}: ${value};`).join("\n");
|
|
520
|
+
return `:root {
|
|
521
|
+
${vars}
|
|
522
|
+
}`;
|
|
523
|
+
}
|
|
524
|
+
function syncStyleEl() {
|
|
525
|
+
if (typeof document === "undefined") return;
|
|
526
|
+
if (!_styleEl) {
|
|
527
|
+
_styleEl = document.createElement("style");
|
|
528
|
+
_styleEl.id = "tw-live-tokens";
|
|
529
|
+
_styleEl.setAttribute("data-tw-tokens", "true");
|
|
530
|
+
document.head.appendChild(_styleEl);
|
|
531
|
+
}
|
|
532
|
+
_styleEl.textContent = buildRootCss(_currentTokens);
|
|
533
|
+
}
|
|
534
|
+
function notifySubscribers() {
|
|
535
|
+
const snapshot = { ..._currentTokens };
|
|
536
|
+
for (const sub of _subscribers) {
|
|
537
|
+
try {
|
|
538
|
+
sub(snapshot);
|
|
539
|
+
} catch {
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
function liveToken(tokens) {
|
|
544
|
+
_currentTokens = { ..._currentTokens, ...tokens };
|
|
545
|
+
syncStyleEl();
|
|
546
|
+
const vars = {};
|
|
547
|
+
for (const name of Object.keys(tokens)) {
|
|
548
|
+
vars[name] = tokenRef(name);
|
|
549
|
+
}
|
|
550
|
+
return {
|
|
551
|
+
vars,
|
|
552
|
+
get(name) {
|
|
553
|
+
return _currentTokens[name];
|
|
554
|
+
},
|
|
555
|
+
set(name, value) {
|
|
556
|
+
setToken(name, value);
|
|
557
|
+
},
|
|
558
|
+
setAll(newTokens) {
|
|
559
|
+
setTokens(newTokens);
|
|
560
|
+
},
|
|
561
|
+
snapshot() {
|
|
562
|
+
return { ..._currentTokens };
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
function setToken(name, value) {
|
|
567
|
+
_currentTokens = { ..._currentTokens, [name]: value };
|
|
568
|
+
if (typeof document !== "undefined") {
|
|
569
|
+
document.documentElement.style.setProperty(tokenVar(name), value);
|
|
570
|
+
}
|
|
571
|
+
notifySubscribers();
|
|
572
|
+
}
|
|
573
|
+
function setTokens(tokens) {
|
|
574
|
+
_currentTokens = { ..._currentTokens, ...tokens };
|
|
575
|
+
if (typeof document !== "undefined") {
|
|
576
|
+
const root = document.documentElement;
|
|
577
|
+
for (const [name, value] of Object.entries(tokens)) {
|
|
578
|
+
root.style.setProperty(tokenVar(name), value);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
notifySubscribers();
|
|
582
|
+
}
|
|
583
|
+
function applyTokenSet(tokens) {
|
|
584
|
+
if (typeof document !== "undefined") {
|
|
585
|
+
const root = document.documentElement;
|
|
586
|
+
for (const name of Object.keys(_currentTokens)) {
|
|
587
|
+
if (!(name in tokens)) {
|
|
588
|
+
root.style.removeProperty(tokenVar(name));
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
_currentTokens = { ...tokens };
|
|
593
|
+
syncStyleEl();
|
|
594
|
+
notifySubscribers();
|
|
595
|
+
}
|
|
596
|
+
function getToken(name) {
|
|
597
|
+
return _currentTokens[name];
|
|
598
|
+
}
|
|
599
|
+
function getTokens() {
|
|
600
|
+
return { ..._currentTokens };
|
|
601
|
+
}
|
|
602
|
+
function subscribeTokens(fn) {
|
|
603
|
+
_subscribers.add(fn);
|
|
604
|
+
return () => {
|
|
605
|
+
_subscribers.delete(fn);
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
function generateTokenCssString() {
|
|
609
|
+
return buildRootCss(_currentTokens);
|
|
610
|
+
}
|
|
611
|
+
function createUseTokens() {
|
|
612
|
+
let useState, useEffect;
|
|
613
|
+
try {
|
|
614
|
+
const react = chunkY5D3E72P_cjs.__require("react");
|
|
615
|
+
useState = react.useState;
|
|
616
|
+
useEffect = react.useEffect;
|
|
617
|
+
} catch {
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
return function useTokens() {
|
|
621
|
+
const [tokens, setTokens_] = useState({
|
|
622
|
+
..._currentTokens
|
|
623
|
+
});
|
|
624
|
+
useEffect(() => {
|
|
625
|
+
setTokens_({ ..._currentTokens });
|
|
626
|
+
const unsub = subscribeTokens((t2) => setTokens_({ ...t2 }));
|
|
627
|
+
return unsub;
|
|
628
|
+
}, []);
|
|
629
|
+
return tokens;
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// src/styledSystem.ts
|
|
634
|
+
function tokenVarName(prefix, group, name) {
|
|
635
|
+
return `--${prefix}-${group}-${name}`;
|
|
636
|
+
}
|
|
637
|
+
function tokenVarRef(prefix, group, name) {
|
|
638
|
+
return `var(${tokenVarName(prefix, group, name)})`;
|
|
639
|
+
}
|
|
640
|
+
function resolveTokenRef(tokens, prefix, value) {
|
|
641
|
+
if (value.startsWith("token:")) {
|
|
642
|
+
const path = value.slice(6);
|
|
643
|
+
const [group, name] = path.split(".");
|
|
644
|
+
if (group && name && tokens[group]?.[name] !== void 0) {
|
|
645
|
+
return tokenVarRef(prefix, group, name);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return value;
|
|
649
|
+
}
|
|
650
|
+
function injectTokensToRoot(tokens, prefix) {
|
|
651
|
+
if (typeof document === "undefined") return;
|
|
652
|
+
const styleId = `__tw-sys-tokens-${prefix}`;
|
|
653
|
+
if (document.getElementById(styleId)) return;
|
|
654
|
+
const lines = [":root {"];
|
|
655
|
+
for (const [group, map] of Object.entries(tokens)) {
|
|
656
|
+
for (const [name, value] of Object.entries(map)) {
|
|
657
|
+
lines.push(` ${tokenVarName(prefix, group, name)}: ${value};`);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
lines.push("}");
|
|
661
|
+
const style = document.createElement("style");
|
|
662
|
+
style.id = styleId;
|
|
663
|
+
style.textContent = lines.join("\n");
|
|
664
|
+
document.head.appendChild(style);
|
|
665
|
+
}
|
|
666
|
+
function resolveComponentConfig(config, tokens, prefix) {
|
|
667
|
+
const resolveStr = (s) => resolveTokenRef(tokens, prefix, s);
|
|
668
|
+
const base = resolveStr(config.base ?? "");
|
|
669
|
+
const systemBase = resolveStr(config.systemBase ?? "");
|
|
670
|
+
const mergedBase = [systemBase, base].filter(Boolean).join(" ");
|
|
671
|
+
const variants = {};
|
|
672
|
+
for (const [variantKey, variantMap] of Object.entries(config.variants ?? {})) {
|
|
673
|
+
variants[variantKey] = {};
|
|
674
|
+
for (const [optKey, classes] of Object.entries(variantMap)) {
|
|
675
|
+
variants[variantKey][optKey] = classes.split(" ").map(resolveStr).join(" ");
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
const compoundVariants = (config.compoundVariants ?? []).map((cv2) => {
|
|
679
|
+
const { class: cls, ...rest } = cv2;
|
|
680
|
+
return { class: resolveStr(cls), ...rest };
|
|
681
|
+
});
|
|
682
|
+
return {
|
|
683
|
+
base: mergedBase,
|
|
684
|
+
variants,
|
|
685
|
+
compoundVariants,
|
|
686
|
+
defaultVariants: config.defaultVariants ?? {},
|
|
687
|
+
state: config.state,
|
|
688
|
+
container: config.container,
|
|
689
|
+
containerName: config.containerName
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
function createStyledSystem(config) {
|
|
693
|
+
const prefix = config.prefix ?? "sys";
|
|
694
|
+
const tokens = config.tokens ?? {};
|
|
695
|
+
const componentDefs = config.components ?? {};
|
|
696
|
+
const shouldInject = config.injectTokens !== false;
|
|
697
|
+
if (shouldInject && typeof window !== "undefined") {
|
|
698
|
+
injectTokensToRoot(tokens, prefix);
|
|
699
|
+
}
|
|
700
|
+
const resolvedConfigs = /* @__PURE__ */ new Map();
|
|
701
|
+
for (const [name, compCfg] of Object.entries(componentDefs)) {
|
|
702
|
+
resolvedConfigs.set(
|
|
703
|
+
name,
|
|
704
|
+
resolveComponentConfig(compCfg, tokens, prefix)
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
const factories = {};
|
|
708
|
+
for (const [name, compCfg] of Object.entries(componentDefs)) {
|
|
709
|
+
const tag = compCfg.tag ?? "div";
|
|
710
|
+
factories[name] = (overrides) => {
|
|
711
|
+
const baseResolved = resolvedConfigs.get(name);
|
|
712
|
+
if (!overrides || Object.keys(overrides).length === 0) {
|
|
713
|
+
return createComponent(tag, baseResolved);
|
|
714
|
+
}
|
|
715
|
+
const overrideResolved = resolveComponentConfig(
|
|
716
|
+
overrides,
|
|
717
|
+
tokens,
|
|
718
|
+
prefix
|
|
719
|
+
);
|
|
720
|
+
const merged = {
|
|
721
|
+
base: [baseResolved.base, overrideResolved.base].filter(Boolean).join(" "),
|
|
722
|
+
variants: {
|
|
723
|
+
...baseResolved.variants ?? void 0,
|
|
724
|
+
...overrideResolved.variants ?? void 0
|
|
725
|
+
},
|
|
726
|
+
compoundVariants: [
|
|
727
|
+
...baseResolved.compoundVariants ?? [],
|
|
728
|
+
...overrideResolved.compoundVariants ?? []
|
|
729
|
+
],
|
|
730
|
+
defaultVariants: {
|
|
731
|
+
...baseResolved.defaultVariants ?? void 0,
|
|
732
|
+
...overrideResolved.defaultVariants ?? void 0
|
|
733
|
+
},
|
|
734
|
+
state: overrideResolved.state ?? baseResolved.state,
|
|
735
|
+
container: overrideResolved.container ?? baseResolved.container,
|
|
736
|
+
containerName: overrideResolved.containerName ?? baseResolved.containerName
|
|
737
|
+
};
|
|
738
|
+
return createComponent(tag, merged);
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
function token(path) {
|
|
742
|
+
const [group, name] = path.split(".");
|
|
743
|
+
if (!group || !name) return path;
|
|
744
|
+
return tokenVarRef(prefix, group, name);
|
|
745
|
+
}
|
|
746
|
+
function rawToken(path) {
|
|
747
|
+
const [group, name] = path.split(".");
|
|
748
|
+
if (!group || !name) return void 0;
|
|
749
|
+
return tokens[group]?.[name];
|
|
750
|
+
}
|
|
751
|
+
function setTokens2(updates) {
|
|
752
|
+
if (typeof document === "undefined") return;
|
|
753
|
+
const styleId = `__tw-sys-tokens-${prefix}`;
|
|
754
|
+
let style = document.getElementById(styleId);
|
|
755
|
+
if (!style) {
|
|
756
|
+
style = document.createElement("style");
|
|
757
|
+
style.id = styleId;
|
|
758
|
+
document.head.appendChild(style);
|
|
759
|
+
}
|
|
760
|
+
for (const [group, map] of Object.entries(updates)) {
|
|
761
|
+
if (!tokens[group]) continue;
|
|
762
|
+
for (const [name, value] of Object.entries(map)) {
|
|
763
|
+
tokens[group][name] = value;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
const lines = [":root {"];
|
|
767
|
+
for (const [group, map] of Object.entries(tokens)) {
|
|
768
|
+
for (const [name, value] of Object.entries(map)) {
|
|
769
|
+
lines.push(` ${tokenVarName(prefix, group, name)}: ${value};`);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
lines.push("}");
|
|
773
|
+
style.textContent = lines.join("\n");
|
|
774
|
+
}
|
|
775
|
+
function getConfig(name) {
|
|
776
|
+
return resolvedConfigs.get(name);
|
|
777
|
+
}
|
|
778
|
+
return Object.assign(factories, {
|
|
779
|
+
token,
|
|
780
|
+
rawToken,
|
|
781
|
+
setTokens: setTokens2,
|
|
782
|
+
getConfig,
|
|
783
|
+
tokens
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// src/styled.ts
|
|
788
|
+
function resolveVariantClass(options, props) {
|
|
789
|
+
const out = [];
|
|
790
|
+
const variants = options.variants ?? {};
|
|
791
|
+
const defaults = options.defaultVariants ?? {};
|
|
792
|
+
for (const [variantName, valueMap] of Object.entries(variants)) {
|
|
793
|
+
const value = props[variantName] ?? defaults[variantName];
|
|
794
|
+
if (value === void 0) continue;
|
|
795
|
+
const key = String(value);
|
|
796
|
+
const cls = valueMap[key];
|
|
797
|
+
if (cls) out.push(cls);
|
|
798
|
+
}
|
|
799
|
+
for (const compound of options.compoundVariants ?? []) {
|
|
800
|
+
const matches = Object.entries(compound.variants).every(([k, expected]) => {
|
|
801
|
+
const current = props[k] ?? defaults[k];
|
|
802
|
+
return String(current) === expected;
|
|
803
|
+
});
|
|
804
|
+
if (matches) out.push(compound.className);
|
|
805
|
+
}
|
|
806
|
+
return out;
|
|
807
|
+
}
|
|
808
|
+
function resolveStyledClassName(options, props = {}) {
|
|
809
|
+
const parts = [options.base ?? "", ...resolveVariantClass(options, props), props.className ?? ""];
|
|
810
|
+
return twMerge4(...parts);
|
|
811
|
+
}
|
|
812
|
+
function styled(options) {
|
|
813
|
+
return function getClassName(props = {}) {
|
|
814
|
+
return resolveStyledClassName(options, props);
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// src/twProxy.ts
|
|
819
|
+
function parseTemplate(strings, exprs) {
|
|
820
|
+
return strings.raw.reduce((acc, str, i) => {
|
|
821
|
+
const expr = exprs[i];
|
|
822
|
+
const exprStr = typeof expr === "function" ? "" : expr ?? "";
|
|
823
|
+
return acc + str + String(exprStr);
|
|
824
|
+
}, "").split("\n").map((l) => l.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
825
|
+
}
|
|
826
|
+
function makeTag(tag) {
|
|
827
|
+
return ((stringsOrConfig, ...exprs) => {
|
|
828
|
+
if (!Array.isArray(stringsOrConfig) && typeof stringsOrConfig === "object" && stringsOrConfig !== null && !("raw" in stringsOrConfig)) {
|
|
829
|
+
return createComponent(tag, stringsOrConfig);
|
|
830
|
+
}
|
|
831
|
+
const classes = parseTemplate(stringsOrConfig, exprs);
|
|
832
|
+
return createComponent(tag, classes);
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
var HTML_TAGS = [
|
|
836
|
+
"div",
|
|
837
|
+
"section",
|
|
838
|
+
"article",
|
|
839
|
+
"aside",
|
|
840
|
+
"header",
|
|
841
|
+
"footer",
|
|
842
|
+
"main",
|
|
843
|
+
"nav",
|
|
844
|
+
"figure",
|
|
845
|
+
"figcaption",
|
|
846
|
+
"details",
|
|
847
|
+
"summary",
|
|
848
|
+
"h1",
|
|
849
|
+
"h2",
|
|
850
|
+
"h3",
|
|
851
|
+
"h4",
|
|
852
|
+
"h5",
|
|
853
|
+
"h6",
|
|
854
|
+
"p",
|
|
855
|
+
"span",
|
|
856
|
+
"strong",
|
|
857
|
+
"em",
|
|
858
|
+
"b",
|
|
859
|
+
"i",
|
|
860
|
+
"s",
|
|
861
|
+
"u",
|
|
862
|
+
"small",
|
|
863
|
+
"mark",
|
|
864
|
+
"abbr",
|
|
865
|
+
"cite",
|
|
866
|
+
"code",
|
|
867
|
+
"kbd",
|
|
868
|
+
"samp",
|
|
869
|
+
"var",
|
|
870
|
+
"time",
|
|
871
|
+
"address",
|
|
872
|
+
"blockquote",
|
|
873
|
+
"q",
|
|
874
|
+
"del",
|
|
875
|
+
"ins",
|
|
876
|
+
"sub",
|
|
877
|
+
"sup",
|
|
878
|
+
"ul",
|
|
879
|
+
"ol",
|
|
880
|
+
"li",
|
|
881
|
+
"dl",
|
|
882
|
+
"dt",
|
|
883
|
+
"dd",
|
|
884
|
+
"table",
|
|
885
|
+
"thead",
|
|
886
|
+
"tbody",
|
|
887
|
+
"tfoot",
|
|
888
|
+
"tr",
|
|
889
|
+
"th",
|
|
890
|
+
"td",
|
|
891
|
+
"caption",
|
|
892
|
+
"colgroup",
|
|
893
|
+
"col",
|
|
894
|
+
"img",
|
|
895
|
+
"picture",
|
|
896
|
+
"video",
|
|
897
|
+
"audio",
|
|
898
|
+
"source",
|
|
899
|
+
"track",
|
|
900
|
+
"canvas",
|
|
901
|
+
"svg",
|
|
902
|
+
"path",
|
|
903
|
+
"circle",
|
|
904
|
+
"rect",
|
|
905
|
+
"line",
|
|
906
|
+
"polyline",
|
|
907
|
+
"polygon",
|
|
908
|
+
"g",
|
|
909
|
+
"defs",
|
|
910
|
+
"use",
|
|
911
|
+
"symbol",
|
|
912
|
+
"form",
|
|
913
|
+
"input",
|
|
914
|
+
"textarea",
|
|
915
|
+
"select",
|
|
916
|
+
"option",
|
|
917
|
+
"optgroup",
|
|
918
|
+
"button",
|
|
919
|
+
"label",
|
|
920
|
+
"fieldset",
|
|
921
|
+
"legend",
|
|
922
|
+
"output",
|
|
923
|
+
"progress",
|
|
924
|
+
"meter",
|
|
925
|
+
"datalist",
|
|
926
|
+
"a",
|
|
927
|
+
"area",
|
|
928
|
+
"map",
|
|
929
|
+
"iframe",
|
|
930
|
+
"embed",
|
|
931
|
+
"object",
|
|
932
|
+
"pre",
|
|
933
|
+
"hr",
|
|
934
|
+
"br",
|
|
935
|
+
"wbr",
|
|
936
|
+
"dialog",
|
|
937
|
+
"menu",
|
|
938
|
+
"template",
|
|
939
|
+
"slot"
|
|
940
|
+
];
|
|
941
|
+
function makeServerTag(tag) {
|
|
942
|
+
const baseFactory = makeTag(tag);
|
|
943
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV !== "production") {
|
|
944
|
+
return ((...args) => {
|
|
945
|
+
const tagName = typeof tag === "string" ? tag : tag.displayName ?? "Component";
|
|
946
|
+
console.warn(
|
|
947
|
+
`[tailwind-styled-v4] tw.server.${tagName} rendered in browser. Ensure withTailwindStyled or Vite plugin is configured.`
|
|
948
|
+
);
|
|
949
|
+
return baseFactory(...args);
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
return baseFactory;
|
|
953
|
+
}
|
|
954
|
+
var serverFactories = {};
|
|
955
|
+
for (const tag of HTML_TAGS) {
|
|
956
|
+
serverFactories[tag] = makeServerTag(tag);
|
|
957
|
+
}
|
|
958
|
+
var server = serverFactories;
|
|
959
|
+
var tagFactories = {};
|
|
960
|
+
for (const tag of HTML_TAGS) {
|
|
961
|
+
tagFactories[tag] = makeTag(tag);
|
|
962
|
+
}
|
|
963
|
+
function twCallable(component) {
|
|
964
|
+
return makeTag(component);
|
|
965
|
+
}
|
|
966
|
+
var tw = Object.assign(twCallable, tagFactories, {
|
|
967
|
+
server
|
|
968
|
+
});
|
|
969
|
+
|
|
970
|
+
// src/twTheme.ts
|
|
971
|
+
function cssVar(varName, fallback) {
|
|
972
|
+
const name = varName.startsWith("--") ? varName : `--${varName}`;
|
|
973
|
+
return fallback ? `var(${name}, ${fallback})` : `var(${name})`;
|
|
974
|
+
}
|
|
975
|
+
function twVar(property, varName, fallback) {
|
|
976
|
+
const ref = fallback ? `var(--${varName},${fallback})` : `var(--${varName})`;
|
|
977
|
+
return `${property}-[${ref}]`;
|
|
978
|
+
}
|
|
979
|
+
var t = {
|
|
980
|
+
/** Background color from CSS variable: t.bg("color-primary") → "bg-[var(--color-primary)]" */
|
|
981
|
+
bg: (v, fb) => twVar("bg", v, fb),
|
|
982
|
+
/** Text color from CSS variable */
|
|
983
|
+
text: (v, fb) => twVar("text", v, fb),
|
|
984
|
+
/** Border color from CSS variable */
|
|
985
|
+
border: (v, fb) => twVar("border", v, fb),
|
|
986
|
+
/** Ring color from CSS variable */
|
|
987
|
+
ring: (v, fb) => twVar("ring", v, fb),
|
|
988
|
+
/** Outline color from CSS variable */
|
|
989
|
+
outline: (v, fb) => twVar("outline", v, fb),
|
|
990
|
+
/** Fill color from CSS variable (SVG) */
|
|
991
|
+
fill: (v, fb) => twVar("fill", v, fb),
|
|
992
|
+
/** Stroke color from CSS variable (SVG) */
|
|
993
|
+
stroke: (v, fb) => twVar("stroke", v, fb),
|
|
994
|
+
/** Font family from CSS variable */
|
|
995
|
+
font: (v, fb) => twVar("font", v, fb),
|
|
996
|
+
/** Shadow from CSS variable */
|
|
997
|
+
shadow: (v, fb) => twVar("shadow", v, fb),
|
|
998
|
+
/** Any arbitrary property from CSS variable */
|
|
999
|
+
var: (property, v, fb) => twVar(property, v, fb)
|
|
1000
|
+
};
|
|
1001
|
+
function createTheme(tokenMap) {
|
|
1002
|
+
const resolved = {};
|
|
1003
|
+
for (const group in tokenMap) {
|
|
1004
|
+
resolved[group] = {};
|
|
1005
|
+
const tokens = tokenMap[group];
|
|
1006
|
+
for (const name in tokens) {
|
|
1007
|
+
const varName = tokens[name];
|
|
1008
|
+
const prefix = getGroupPrefix(group);
|
|
1009
|
+
resolved[group][name] = prefix ? twVar(prefix, varName) : cssVar(varName);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
return resolved;
|
|
1013
|
+
}
|
|
1014
|
+
function getGroupPrefix(group) {
|
|
1015
|
+
const map = {
|
|
1016
|
+
colors: "bg",
|
|
1017
|
+
// default to bg; user can use t.text() for text colors
|
|
1018
|
+
fonts: "font",
|
|
1019
|
+
spacing: "p",
|
|
1020
|
+
shadows: "shadow"
|
|
1021
|
+
};
|
|
1022
|
+
return map[group] ?? "";
|
|
1023
|
+
}
|
|
1024
|
+
var v4Tokens = {
|
|
1025
|
+
/** bg-[var(--color-background)] */
|
|
1026
|
+
bg: twVar("bg", "color-background"),
|
|
1027
|
+
/** text-[var(--color-foreground)] */
|
|
1028
|
+
text: twVar("text", "color-foreground"),
|
|
1029
|
+
/** font-[var(--font-sans)] */
|
|
1030
|
+
fontSans: twVar("font", "font-sans"),
|
|
1031
|
+
/** font-[var(--font-mono)] */
|
|
1032
|
+
fontMono: twVar("font", "font-mono")
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
// src/parser.ts
|
|
1036
|
+
var _getNodePath = () => typeof chunkY5D3E72P_cjs.__require !== "undefined" ? chunkY5D3E72P_cjs.__require("path") : null;
|
|
1037
|
+
var _getCreateRequire = () => {
|
|
1038
|
+
if (typeof chunkY5D3E72P_cjs.__require !== "undefined") {
|
|
1039
|
+
try {
|
|
1040
|
+
return chunkY5D3E72P_cjs.__require("module").createRequire;
|
|
1041
|
+
} catch {
|
|
1042
|
+
return null;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
return null;
|
|
1046
|
+
};
|
|
1047
|
+
var _binding;
|
|
1048
|
+
function getBinding() {
|
|
1049
|
+
if (_binding !== void 0) return _binding;
|
|
1050
|
+
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
|
|
1051
|
+
return _binding = null;
|
|
1052
|
+
}
|
|
1053
|
+
if (typeof process === "undefined" || typeof process.cwd !== "function") {
|
|
1054
|
+
return _binding = null;
|
|
1055
|
+
}
|
|
1056
|
+
const runtimeDir = typeof __dirname === "string" ? __dirname : process.cwd();
|
|
1057
|
+
const nodePath = _getNodePath();
|
|
1058
|
+
const nodeCreateRequire = _getCreateRequire();
|
|
1059
|
+
if (!nodePath) return _binding = null;
|
|
1060
|
+
const req = typeof chunkY5D3E72P_cjs.__require === "function" ? chunkY5D3E72P_cjs.__require : nodeCreateRequire ? nodeCreateRequire(nodePath.join(runtimeDir, "noop.cjs")) : null;
|
|
1061
|
+
if (!req) return _binding = null;
|
|
1062
|
+
const candidates = [
|
|
1063
|
+
nodePath.resolve(process.cwd(), "native", "tailwind_styled_parser.node"),
|
|
1064
|
+
nodePath.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
1065
|
+
nodePath.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node")
|
|
1066
|
+
];
|
|
1067
|
+
for (const c of candidates) {
|
|
1068
|
+
try {
|
|
1069
|
+
const mod = req(c);
|
|
1070
|
+
if (mod?.parseClasses) return _binding = mod;
|
|
1071
|
+
} catch {
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
return _binding = null;
|
|
1075
|
+
}
|
|
1076
|
+
function splitClassListJS(input) {
|
|
1077
|
+
const out = [];
|
|
1078
|
+
let token = "";
|
|
1079
|
+
let square = 0;
|
|
1080
|
+
let round = 0;
|
|
1081
|
+
let escaped = false;
|
|
1082
|
+
for (const ch of input) {
|
|
1083
|
+
if (escaped) {
|
|
1084
|
+
token += ch;
|
|
1085
|
+
escaped = false;
|
|
1086
|
+
continue;
|
|
1087
|
+
}
|
|
1088
|
+
if (ch === "\\") {
|
|
1089
|
+
token += ch;
|
|
1090
|
+
escaped = true;
|
|
1091
|
+
continue;
|
|
1092
|
+
}
|
|
1093
|
+
if (ch === "[") square++;
|
|
1094
|
+
else if (ch === "]") square = Math.max(0, square - 1);
|
|
1095
|
+
else if (ch === "(") round++;
|
|
1096
|
+
else if (ch === ")") round = Math.max(0, round - 1);
|
|
1097
|
+
const isSpace = /\s/.test(ch);
|
|
1098
|
+
if (isSpace && square === 0 && round === 0) {
|
|
1099
|
+
if (token.trim().length > 0) out.push(token.trim());
|
|
1100
|
+
token = "";
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
token += ch;
|
|
1104
|
+
}
|
|
1105
|
+
if (token.trim().length > 0) out.push(token.trim());
|
|
1106
|
+
return out;
|
|
1107
|
+
}
|
|
1108
|
+
function parseClassTokenJS(rawToken) {
|
|
1109
|
+
const parts = [];
|
|
1110
|
+
let current = "";
|
|
1111
|
+
let square = 0;
|
|
1112
|
+
let round = 0;
|
|
1113
|
+
let escaped = false;
|
|
1114
|
+
for (const ch of rawToken) {
|
|
1115
|
+
if (escaped) {
|
|
1116
|
+
current += ch;
|
|
1117
|
+
escaped = false;
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1120
|
+
if (ch === "\\") {
|
|
1121
|
+
current += ch;
|
|
1122
|
+
escaped = true;
|
|
1123
|
+
continue;
|
|
1124
|
+
}
|
|
1125
|
+
if (ch === "[") square++;
|
|
1126
|
+
else if (ch === "]") square = Math.max(0, square - 1);
|
|
1127
|
+
else if (ch === "(") round++;
|
|
1128
|
+
else if (ch === ")") round = Math.max(0, round - 1);
|
|
1129
|
+
if (ch === ":" && square === 0 && round === 0) {
|
|
1130
|
+
parts.push(current);
|
|
1131
|
+
current = "";
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
current += ch;
|
|
1135
|
+
}
|
|
1136
|
+
parts.push(current);
|
|
1137
|
+
const variants = parts.slice(0, -1).filter(Boolean);
|
|
1138
|
+
const baseToken = parts[parts.length - 1] ?? "";
|
|
1139
|
+
const parsed = { raw: rawToken, base: baseToken, variants };
|
|
1140
|
+
const opacityMatch = baseToken.match(/^(.*)\/(\d{1,3})$/);
|
|
1141
|
+
if (opacityMatch && opacityMatch[1].length > 0) {
|
|
1142
|
+
parsed.base = opacityMatch[1];
|
|
1143
|
+
parsed.modifier = { type: "opacity", value: opacityMatch[2] };
|
|
1144
|
+
return parsed;
|
|
1145
|
+
}
|
|
1146
|
+
const arbitraryMatch = baseToken.match(/\((--[a-zA-Z0-9_-]+)\)/);
|
|
1147
|
+
if (arbitraryMatch) {
|
|
1148
|
+
parsed.modifier = { type: "arbitrary", value: arbitraryMatch[1] };
|
|
1149
|
+
}
|
|
1150
|
+
return parsed;
|
|
1151
|
+
}
|
|
1152
|
+
function splitClassList(input) {
|
|
1153
|
+
const binding = getBinding();
|
|
1154
|
+
if (binding?.parseClasses) {
|
|
1155
|
+
try {
|
|
1156
|
+
return binding.parseClasses(input).map((p) => p.raw);
|
|
1157
|
+
} catch {
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
return splitClassListJS(input);
|
|
1161
|
+
}
|
|
1162
|
+
function parseClassToken(rawToken) {
|
|
1163
|
+
const binding = getBinding();
|
|
1164
|
+
if (binding?.parseClasses) {
|
|
1165
|
+
try {
|
|
1166
|
+
const results = binding.parseClasses(rawToken);
|
|
1167
|
+
if (results.length === 1) {
|
|
1168
|
+
const r = results[0];
|
|
1169
|
+
const parsed = {
|
|
1170
|
+
raw: r.raw,
|
|
1171
|
+
base: r.base,
|
|
1172
|
+
variants: r.variants
|
|
1173
|
+
};
|
|
1174
|
+
if (r.modifierType && r.modifierValue) {
|
|
1175
|
+
parsed.modifier = {
|
|
1176
|
+
type: r.modifierType,
|
|
1177
|
+
value: r.modifierValue
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
return parsed;
|
|
1181
|
+
}
|
|
1182
|
+
} catch {
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return parseClassTokenJS(rawToken);
|
|
1186
|
+
}
|
|
1187
|
+
function parseTailwindClasses(input) {
|
|
1188
|
+
const binding = getBinding();
|
|
1189
|
+
if (binding?.parseClasses) {
|
|
1190
|
+
try {
|
|
1191
|
+
return binding.parseClasses(input).map((r) => {
|
|
1192
|
+
const parsed = { raw: r.raw, base: r.base, variants: r.variants };
|
|
1193
|
+
if (r.modifierType && r.modifierValue) {
|
|
1194
|
+
parsed.modifier = {
|
|
1195
|
+
type: r.modifierType,
|
|
1196
|
+
value: r.modifierValue
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
return parsed;
|
|
1200
|
+
});
|
|
1201
|
+
} catch {
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
return splitClassListJS(input).map(parseClassTokenJS);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
// src/themeReader.ts
|
|
1208
|
+
var THEME_BLOCK_RE = /@theme\s*\{([\s\S]*?)\}/g;
|
|
1209
|
+
var CSS_VAR_RE = /--([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/g;
|
|
1210
|
+
var cache = /* @__PURE__ */ new Map();
|
|
1211
|
+
function createEmptyTheme() {
|
|
1212
|
+
return {
|
|
1213
|
+
colors: {},
|
|
1214
|
+
spacing: {},
|
|
1215
|
+
fonts: {},
|
|
1216
|
+
breakpoints: {},
|
|
1217
|
+
animations: {},
|
|
1218
|
+
raw: {}
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
function setToken2(theme, key, value) {
|
|
1222
|
+
theme.raw[key] = value;
|
|
1223
|
+
if (key.startsWith("color-")) {
|
|
1224
|
+
theme.colors[key.slice("color-".length)] = value;
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
if (key.startsWith("spacing-")) {
|
|
1228
|
+
theme.spacing[key.slice("spacing-".length)] = value;
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
if (key.startsWith("font-")) {
|
|
1232
|
+
theme.fonts[key.slice("font-".length)] = value;
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
if (key.startsWith("breakpoint-")) {
|
|
1236
|
+
theme.breakpoints[key.slice("breakpoint-".length)] = value;
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
if (key.startsWith("animate-")) {
|
|
1240
|
+
theme.animations[key.slice("animate-".length)] = value;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
function resolveThemeValue(key, theme, visited = /* @__PURE__ */ new Set()) {
|
|
1244
|
+
const token = key.replace(/^--/, "");
|
|
1245
|
+
const raw = theme.raw[token];
|
|
1246
|
+
if (!raw) return "";
|
|
1247
|
+
if (visited.has(token)) return raw;
|
|
1248
|
+
const nested = raw.match(/^var\((--[a-zA-Z0-9_-]+)\)$/);
|
|
1249
|
+
if (!nested) return raw;
|
|
1250
|
+
visited.add(token);
|
|
1251
|
+
return resolveThemeValue(nested[1], theme, visited);
|
|
1252
|
+
}
|
|
1253
|
+
function extractThemeFromCSS(cssContent) {
|
|
1254
|
+
const hit = cache.get(cssContent);
|
|
1255
|
+
if (hit) return hit;
|
|
1256
|
+
const theme = createEmptyTheme();
|
|
1257
|
+
let blockMatch;
|
|
1258
|
+
while ((blockMatch = THEME_BLOCK_RE.exec(cssContent)) !== null) {
|
|
1259
|
+
const block = blockMatch[1];
|
|
1260
|
+
let varMatch;
|
|
1261
|
+
while ((varMatch = CSS_VAR_RE.exec(block)) !== null) {
|
|
1262
|
+
const key = varMatch[1];
|
|
1263
|
+
const value = varMatch[2].trim();
|
|
1264
|
+
setToken2(theme, key, value);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
for (const key of Object.keys(theme.raw)) {
|
|
1268
|
+
const resolved = resolveThemeValue(`--${key}`, theme);
|
|
1269
|
+
theme.raw[key] = resolved;
|
|
1270
|
+
if (key.startsWith("color-")) {
|
|
1271
|
+
theme.colors[key.slice("color-".length)] = resolved;
|
|
1272
|
+
} else if (key.startsWith("spacing-")) {
|
|
1273
|
+
theme.spacing[key.slice("spacing-".length)] = resolved;
|
|
1274
|
+
} else if (key.startsWith("font-")) {
|
|
1275
|
+
theme.fonts[key.slice("font-".length)] = resolved;
|
|
1276
|
+
} else if (key.startsWith("breakpoint-")) {
|
|
1277
|
+
theme.breakpoints[key.slice("breakpoint-".length)] = resolved;
|
|
1278
|
+
} else if (key.startsWith("animate-")) {
|
|
1279
|
+
theme.animations[key.slice("animate-".length)] = resolved;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
cache.set(cssContent, theme);
|
|
1283
|
+
return theme;
|
|
1284
|
+
}
|
|
1285
|
+
function generateTypeDefinitions(theme) {
|
|
1286
|
+
const toRecordType = (name, obj) => {
|
|
1287
|
+
const keys = Object.keys(obj);
|
|
1288
|
+
if (keys.length === 0) return ` ${name}: Record<string, string>`;
|
|
1289
|
+
const mapped = keys.map((k) => ` "${k}": string`).join("\n");
|
|
1290
|
+
return ` ${name}: {
|
|
1291
|
+
${mapped}
|
|
1292
|
+
}`;
|
|
1293
|
+
};
|
|
1294
|
+
return [
|
|
1295
|
+
"export interface TailwindStyledThemeTokens {",
|
|
1296
|
+
toRecordType("colors", theme.colors),
|
|
1297
|
+
toRecordType("spacing", theme.spacing),
|
|
1298
|
+
toRecordType("fonts", theme.fonts),
|
|
1299
|
+
toRecordType("breakpoints", theme.breakpoints),
|
|
1300
|
+
toRecordType("animations", theme.animations),
|
|
1301
|
+
"}",
|
|
1302
|
+
""
|
|
1303
|
+
].join("\n");
|
|
1304
|
+
}
|
|
1305
|
+
function clearThemeReaderCache() {
|
|
1306
|
+
cache.clear();
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
exports.applyTokenSet = applyTokenSet;
|
|
1310
|
+
exports.clearThemeReaderCache = clearThemeReaderCache;
|
|
1311
|
+
exports.cn = cn;
|
|
1312
|
+
exports.containerRef = tokenRef;
|
|
1313
|
+
exports.createComponent = createComponent;
|
|
1314
|
+
exports.createStyledSystem = createStyledSystem;
|
|
1315
|
+
exports.createTheme = createTheme;
|
|
1316
|
+
exports.createTwMerge = createTwMerge;
|
|
1317
|
+
exports.createUseTokens = createUseTokens;
|
|
1318
|
+
exports.cssVar = cssVar;
|
|
1319
|
+
exports.cv = cv;
|
|
1320
|
+
exports.cx = cx;
|
|
1321
|
+
exports.cxm = cxm;
|
|
1322
|
+
exports.extractThemeFromCSS = extractThemeFromCSS;
|
|
1323
|
+
exports.generateContainerCss = generateContainerCss;
|
|
1324
|
+
exports.generateStateCss = generateStateCss;
|
|
1325
|
+
exports.generateTokenCssString = generateTokenCssString;
|
|
1326
|
+
exports.generateTypeDefinitions = generateTypeDefinitions;
|
|
1327
|
+
exports.getContainerRegistry = getContainerRegistry;
|
|
1328
|
+
exports.getStateRegistry = getStateRegistry;
|
|
1329
|
+
exports.getToken = getToken;
|
|
1330
|
+
exports.getTokens = getTokens;
|
|
1331
|
+
exports.liveToken = liveToken;
|
|
1332
|
+
exports.mergeWithRules = mergeWithRules;
|
|
1333
|
+
exports.parseClassToken = parseClassToken;
|
|
1334
|
+
exports.parseTailwindClasses = parseTailwindClasses;
|
|
1335
|
+
exports.processContainer = processContainer;
|
|
1336
|
+
exports.processState = processState;
|
|
1337
|
+
exports.resolveStyledClassName = resolveStyledClassName;
|
|
1338
|
+
exports.resolveThemeValue = resolveThemeValue;
|
|
1339
|
+
exports.server = server;
|
|
1340
|
+
exports.setToken = setToken;
|
|
1341
|
+
exports.setTokens = setTokens;
|
|
1342
|
+
exports.splitClassList = splitClassList;
|
|
1343
|
+
exports.styled = styled;
|
|
1344
|
+
exports.subscribeTokens = subscribeTokens;
|
|
1345
|
+
exports.t = t;
|
|
1346
|
+
exports.tokenRef = tokenRef;
|
|
1347
|
+
exports.tokenVar = tokenVar;
|
|
1348
|
+
exports.tw = tw;
|
|
1349
|
+
exports.twMerge = twMerge4;
|
|
1350
|
+
exports.twVar = twVar;
|
|
1351
|
+
exports.v4Tokens = v4Tokens;
|
|
1352
|
+
//# sourceMappingURL=index.cjs.map
|
|
1353
|
+
//# sourceMappingURL=index.cjs.map
|