@csszyx/dynamic 0.6.2 → 0.8.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/index.d.mts +92 -0
- package/dist/index.mjs +2 -0
- package/dist/react.d.mts +86 -0
- package/dist/react.mjs +37 -0
- package/dist/shared/dynamic.BLXLKBNg.mjs +1149 -0
- package/package.json +22 -8
- package/src/css-generator.ts +0 -1003
- package/src/index.ts +0 -122
- package/src/injector.ts +0 -226
- package/src/manifest.ts +0 -119
- package/src/react.ts +0 -166
- package/src/ssr.ts +0 -5
- package/tests/css-generator.test.ts +0 -339
- package/tests/injector.test.ts +0 -222
- package/tests/manifest.test.ts +0 -177
- package/tests/react.test.ts +0 -221
- package/tsconfig.json +0 -10
- package/vitest.config.ts +0 -8
|
@@ -0,0 +1,1149 @@
|
|
|
1
|
+
import { transform } from '@csszyx/compiler/browser';
|
|
2
|
+
|
|
3
|
+
const BREAKPOINTS = {
|
|
4
|
+
sm: "40rem",
|
|
5
|
+
md: "48rem",
|
|
6
|
+
lg: "64rem",
|
|
7
|
+
xl: "80rem",
|
|
8
|
+
"2xl": "96rem",
|
|
9
|
+
"max-sm": "40rem",
|
|
10
|
+
"max-md": "48rem",
|
|
11
|
+
"max-lg": "64rem",
|
|
12
|
+
"max-xl": "80rem",
|
|
13
|
+
"max-2xl": "96rem"
|
|
14
|
+
};
|
|
15
|
+
const PSEUDO_CLASS_MAP = {
|
|
16
|
+
hover: ":hover",
|
|
17
|
+
focus: ":focus",
|
|
18
|
+
"focus-visible": ":focus-visible",
|
|
19
|
+
"focus-within": ":focus-within",
|
|
20
|
+
active: ":active",
|
|
21
|
+
visited: ":visited",
|
|
22
|
+
disabled: ":disabled",
|
|
23
|
+
checked: ":checked",
|
|
24
|
+
required: ":required",
|
|
25
|
+
optional: ":optional",
|
|
26
|
+
valid: ":valid",
|
|
27
|
+
invalid: ":invalid",
|
|
28
|
+
placeholder: "::placeholder",
|
|
29
|
+
before: "::before",
|
|
30
|
+
after: "::after",
|
|
31
|
+
first: ":first-child",
|
|
32
|
+
last: ":last-child",
|
|
33
|
+
odd: ":nth-child(odd)",
|
|
34
|
+
even: ":nth-child(even)",
|
|
35
|
+
empty: ":empty",
|
|
36
|
+
open: "[open]"
|
|
37
|
+
};
|
|
38
|
+
const SPACING_PROPS = {
|
|
39
|
+
// Padding
|
|
40
|
+
p: ["padding"],
|
|
41
|
+
pt: ["padding-top"],
|
|
42
|
+
pr: ["padding-right"],
|
|
43
|
+
pb: ["padding-bottom"],
|
|
44
|
+
pl: ["padding-left"],
|
|
45
|
+
px: ["padding-inline"],
|
|
46
|
+
py: ["padding-block"],
|
|
47
|
+
ps: ["padding-inline-start"],
|
|
48
|
+
pe: ["padding-inline-end"],
|
|
49
|
+
pbs: ["padding-block-start"],
|
|
50
|
+
pbe: ["padding-block-end"],
|
|
51
|
+
// Margin
|
|
52
|
+
m: ["margin"],
|
|
53
|
+
mt: ["margin-top"],
|
|
54
|
+
mr: ["margin-right"],
|
|
55
|
+
mb: ["margin-bottom"],
|
|
56
|
+
ml: ["margin-left"],
|
|
57
|
+
mx: ["margin-inline"],
|
|
58
|
+
my: ["margin-block"],
|
|
59
|
+
ms: ["margin-inline-start"],
|
|
60
|
+
me: ["margin-inline-end"],
|
|
61
|
+
mbs: ["margin-block-start"],
|
|
62
|
+
mbe: ["margin-block-end"],
|
|
63
|
+
// Gap
|
|
64
|
+
gap: ["gap"],
|
|
65
|
+
"gap-x": ["column-gap"],
|
|
66
|
+
"gap-y": ["row-gap"],
|
|
67
|
+
// Sizing
|
|
68
|
+
w: ["width"],
|
|
69
|
+
h: ["height"],
|
|
70
|
+
"min-w": ["min-width"],
|
|
71
|
+
"max-w": ["max-width"],
|
|
72
|
+
"min-h": ["min-height"],
|
|
73
|
+
"max-h": ["max-height"],
|
|
74
|
+
size: ["width", "height"],
|
|
75
|
+
// Position
|
|
76
|
+
top: ["top"],
|
|
77
|
+
right: ["right"],
|
|
78
|
+
bottom: ["bottom"],
|
|
79
|
+
left: ["left"],
|
|
80
|
+
inset: ["inset"],
|
|
81
|
+
"inset-x": ["inset-inline"],
|
|
82
|
+
"inset-y": ["inset-block"],
|
|
83
|
+
"inset-s": ["inset-inline-start"],
|
|
84
|
+
"inset-e": ["inset-inline-end"],
|
|
85
|
+
// Flex
|
|
86
|
+
basis: ["flex-basis"],
|
|
87
|
+
// Typography
|
|
88
|
+
indent: ["text-indent"],
|
|
89
|
+
"outline-offset": ["outline-offset"],
|
|
90
|
+
"underline-offset": ["text-underline-offset"],
|
|
91
|
+
// Scroll
|
|
92
|
+
"scroll-m": ["scroll-margin"],
|
|
93
|
+
"scroll-mt": ["scroll-margin-top"],
|
|
94
|
+
"scroll-mr": ["scroll-margin-right"],
|
|
95
|
+
"scroll-mb": ["scroll-margin-bottom"],
|
|
96
|
+
"scroll-ml": ["scroll-margin-left"],
|
|
97
|
+
"scroll-mx": ["scroll-margin-inline"],
|
|
98
|
+
"scroll-my": ["scroll-margin-block"],
|
|
99
|
+
"scroll-ms": ["scroll-margin-inline-start"],
|
|
100
|
+
"scroll-me": ["scroll-margin-inline-end"],
|
|
101
|
+
"scroll-p": ["scroll-padding"],
|
|
102
|
+
"scroll-pt": ["scroll-padding-top"],
|
|
103
|
+
"scroll-pr": ["scroll-padding-right"],
|
|
104
|
+
"scroll-pb": ["scroll-padding-bottom"],
|
|
105
|
+
"scroll-pl": ["scroll-padding-left"],
|
|
106
|
+
"scroll-px": ["scroll-padding-inline"],
|
|
107
|
+
"scroll-py": ["scroll-padding-block"],
|
|
108
|
+
"scroll-ps": ["scroll-padding-inline-start"],
|
|
109
|
+
"scroll-pe": ["scroll-padding-inline-end"],
|
|
110
|
+
// Border spacing (CSS custom properties in Tailwind v4)
|
|
111
|
+
"border-spacing-x": ["--tw-border-spacing-x"],
|
|
112
|
+
"border-spacing-y": ["--tw-border-spacing-y"],
|
|
113
|
+
// Ring offset (CSS custom property)
|
|
114
|
+
"ring-offset": ["--tw-ring-offset-width"]
|
|
115
|
+
};
|
|
116
|
+
const SIZE_KEYWORDS = {
|
|
117
|
+
auto: "auto",
|
|
118
|
+
full: "100%",
|
|
119
|
+
screen: "100vw",
|
|
120
|
+
// width context; height context uses 100vh — see below
|
|
121
|
+
svw: "100svw",
|
|
122
|
+
dvw: "100dvw",
|
|
123
|
+
lvw: "100lvw",
|
|
124
|
+
svh: "100svh",
|
|
125
|
+
dvh: "100dvh",
|
|
126
|
+
lvh: "100lvh",
|
|
127
|
+
fit: "fit-content",
|
|
128
|
+
min: "min-content",
|
|
129
|
+
max: "max-content",
|
|
130
|
+
none: "none",
|
|
131
|
+
px: "1px",
|
|
132
|
+
"0": "0",
|
|
133
|
+
xs: "var(--container-xs)",
|
|
134
|
+
sm: "var(--container-sm)",
|
|
135
|
+
md: "var(--container-md)",
|
|
136
|
+
lg: "var(--container-lg)",
|
|
137
|
+
xl: "var(--container-xl)",
|
|
138
|
+
"2xl": "var(--container-2xl)",
|
|
139
|
+
"3xl": "var(--container-3xl)",
|
|
140
|
+
"4xl": "var(--container-4xl)",
|
|
141
|
+
"5xl": "var(--container-5xl)",
|
|
142
|
+
"6xl": "var(--container-6xl)",
|
|
143
|
+
"7xl": "var(--container-7xl)",
|
|
144
|
+
prose: "var(--container-prose)"
|
|
145
|
+
};
|
|
146
|
+
function resolveSpacingValue(v, prop) {
|
|
147
|
+
if (v === "0") {
|
|
148
|
+
return "0";
|
|
149
|
+
}
|
|
150
|
+
if (v === "px") {
|
|
151
|
+
return "1px";
|
|
152
|
+
}
|
|
153
|
+
if (v === "screen") {
|
|
154
|
+
if (prop && (prop === "height" || prop === "min-height" || prop === "max-height")) {
|
|
155
|
+
return "100vh";
|
|
156
|
+
}
|
|
157
|
+
return "100vw";
|
|
158
|
+
}
|
|
159
|
+
if (v in SIZE_KEYWORDS) {
|
|
160
|
+
return SIZE_KEYWORDS[v];
|
|
161
|
+
}
|
|
162
|
+
if (v.startsWith("[") && v.endsWith("]")) {
|
|
163
|
+
return v.slice(1, -1).replace(/_/g, " ");
|
|
164
|
+
}
|
|
165
|
+
if (v.startsWith("(") && v.endsWith(")") && v.includes("--")) {
|
|
166
|
+
return `var(${v.slice(1, -1)})`;
|
|
167
|
+
}
|
|
168
|
+
if (v.includes("/")) {
|
|
169
|
+
const slash = v.indexOf("/");
|
|
170
|
+
const num = parseFloat(v.slice(0, slash));
|
|
171
|
+
const den = parseFloat(v.slice(slash + 1));
|
|
172
|
+
if (!Number.isNaN(num) && !Number.isNaN(den) && den !== 0) {
|
|
173
|
+
const pct = num / den * 100;
|
|
174
|
+
return `${parseFloat(pct.toFixed(6))}%`;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (v.startsWith("-") && !Number.isNaN(parseFloat(v.slice(1)))) {
|
|
178
|
+
return `calc(var(--spacing) * ${v})`;
|
|
179
|
+
}
|
|
180
|
+
if (!Number.isNaN(parseFloat(v))) {
|
|
181
|
+
return `calc(var(--spacing) * ${v})`;
|
|
182
|
+
}
|
|
183
|
+
return v;
|
|
184
|
+
}
|
|
185
|
+
const COLOR_PROPS = {
|
|
186
|
+
bg: "background-color",
|
|
187
|
+
text: "color",
|
|
188
|
+
border: "border-color",
|
|
189
|
+
"border-t": "border-top-color",
|
|
190
|
+
"border-r": "border-right-color",
|
|
191
|
+
"border-b": "border-bottom-color",
|
|
192
|
+
"border-l": "border-left-color",
|
|
193
|
+
"border-x": "border-inline-color",
|
|
194
|
+
"border-y": "border-block-color",
|
|
195
|
+
"border-s": "border-inline-start-color",
|
|
196
|
+
"border-e": "border-inline-end-color",
|
|
197
|
+
divide: "border-color",
|
|
198
|
+
outline: "outline-color",
|
|
199
|
+
fill: "fill",
|
|
200
|
+
stroke: "stroke",
|
|
201
|
+
from: "--tw-gradient-from",
|
|
202
|
+
via: "--tw-gradient-via",
|
|
203
|
+
to: "--tw-gradient-to",
|
|
204
|
+
decoration: "text-decoration-color",
|
|
205
|
+
accent: "accent-color",
|
|
206
|
+
caret: "caret-color",
|
|
207
|
+
shadow: "--tw-shadow-color",
|
|
208
|
+
"inset-shadow": "--tw-inset-shadow-color",
|
|
209
|
+
ring: "--tw-ring-color",
|
|
210
|
+
"ring-offset": "--tw-ring-offset-color",
|
|
211
|
+
"drop-shadow": "--tw-drop-shadow-color"
|
|
212
|
+
};
|
|
213
|
+
const DIRECT_COLOR_KEYWORDS = /* @__PURE__ */ new Set([
|
|
214
|
+
"white",
|
|
215
|
+
"black",
|
|
216
|
+
"transparent",
|
|
217
|
+
"inherit",
|
|
218
|
+
"current",
|
|
219
|
+
"currentColor"
|
|
220
|
+
]);
|
|
221
|
+
function resolveColorValue(v) {
|
|
222
|
+
if (DIRECT_COLOR_KEYWORDS.has(v)) {
|
|
223
|
+
if (v === "current") {
|
|
224
|
+
return "currentColor";
|
|
225
|
+
}
|
|
226
|
+
return v;
|
|
227
|
+
}
|
|
228
|
+
if (v.startsWith("[") && v.endsWith("]")) {
|
|
229
|
+
const inner = v.slice(1, -1).replace(/_/g, " ");
|
|
230
|
+
if (inner.startsWith("color:")) {
|
|
231
|
+
return inner.slice(6);
|
|
232
|
+
}
|
|
233
|
+
return inner;
|
|
234
|
+
}
|
|
235
|
+
if (v.startsWith("(") && v.endsWith(")") && v.includes("--")) {
|
|
236
|
+
return `var(${v.slice(1, -1)})`;
|
|
237
|
+
}
|
|
238
|
+
const slashIdx = v.lastIndexOf("/");
|
|
239
|
+
if (slashIdx > 0) {
|
|
240
|
+
const colorPart = v.slice(0, slashIdx);
|
|
241
|
+
const opacity = v.slice(slashIdx + 1);
|
|
242
|
+
const colorVar = DIRECT_COLOR_KEYWORDS.has(colorPart) ? colorPart : `var(--color-${colorPart})`;
|
|
243
|
+
const opacityPct = v.includes(".") ? `${parseFloat(opacity) * 100}%` : `${opacity}%`;
|
|
244
|
+
return `color-mix(in srgb, ${colorVar} ${opacityPct}, transparent)`;
|
|
245
|
+
}
|
|
246
|
+
return `var(--color-${v})`;
|
|
247
|
+
}
|
|
248
|
+
const TEXT_SIZES = /* @__PURE__ */ new Set([
|
|
249
|
+
"xs",
|
|
250
|
+
"sm",
|
|
251
|
+
"base",
|
|
252
|
+
"lg",
|
|
253
|
+
"xl",
|
|
254
|
+
"2xl",
|
|
255
|
+
"3xl",
|
|
256
|
+
"4xl",
|
|
257
|
+
"5xl",
|
|
258
|
+
"6xl",
|
|
259
|
+
"7xl",
|
|
260
|
+
"8xl",
|
|
261
|
+
"9xl"
|
|
262
|
+
]);
|
|
263
|
+
const KEYWORD_RULES = {
|
|
264
|
+
// Display
|
|
265
|
+
flex: "display: flex",
|
|
266
|
+
"inline-flex": "display: inline-flex",
|
|
267
|
+
block: "display: block",
|
|
268
|
+
"inline-block": "display: inline-block",
|
|
269
|
+
inline: "display: inline",
|
|
270
|
+
grid: "display: grid",
|
|
271
|
+
"inline-grid": "display: inline-grid",
|
|
272
|
+
hidden: "display: none",
|
|
273
|
+
contents: "display: contents",
|
|
274
|
+
"flow-root": "display: flow-root",
|
|
275
|
+
table: "display: table",
|
|
276
|
+
"table-row": "display: table-row",
|
|
277
|
+
"table-cell": "display: table-cell",
|
|
278
|
+
"list-item": "display: list-item",
|
|
279
|
+
// Position
|
|
280
|
+
static: "position: static",
|
|
281
|
+
fixed: "position: fixed",
|
|
282
|
+
absolute: "position: absolute",
|
|
283
|
+
relative: "position: relative",
|
|
284
|
+
sticky: "position: sticky",
|
|
285
|
+
// Visibility
|
|
286
|
+
visible: "visibility: visible",
|
|
287
|
+
invisible: "visibility: hidden",
|
|
288
|
+
collapse: "visibility: collapse",
|
|
289
|
+
// Overflow
|
|
290
|
+
"overflow-auto": "overflow: auto",
|
|
291
|
+
"overflow-hidden": "overflow: hidden",
|
|
292
|
+
"overflow-visible": "overflow: visible",
|
|
293
|
+
"overflow-scroll": "overflow: scroll",
|
|
294
|
+
"overflow-clip": "overflow: clip",
|
|
295
|
+
"overflow-x-auto": "overflow-x: auto",
|
|
296
|
+
"overflow-x-hidden": "overflow-x: hidden",
|
|
297
|
+
"overflow-y-auto": "overflow-y: auto",
|
|
298
|
+
"overflow-y-hidden": "overflow-y: hidden",
|
|
299
|
+
"overflow-y-scroll": "overflow-y: scroll",
|
|
300
|
+
"overflow-x-scroll": "overflow-x: scroll",
|
|
301
|
+
// Flex direction
|
|
302
|
+
"flex-row": "flex-direction: row",
|
|
303
|
+
"flex-col": "flex-direction: column",
|
|
304
|
+
"flex-row-reverse": "flex-direction: row-reverse",
|
|
305
|
+
"flex-col-reverse": "flex-direction: column-reverse",
|
|
306
|
+
// Flex wrap
|
|
307
|
+
"flex-wrap": "flex-wrap: wrap",
|
|
308
|
+
"flex-nowrap": "flex-wrap: nowrap",
|
|
309
|
+
"flex-wrap-reverse": "flex-wrap: wrap-reverse",
|
|
310
|
+
// Flex sizing
|
|
311
|
+
"flex-1": "flex: 1 1 0%",
|
|
312
|
+
"flex-auto": "flex: 1 1 auto",
|
|
313
|
+
"flex-none": "flex: none",
|
|
314
|
+
// Align
|
|
315
|
+
"items-start": "align-items: flex-start",
|
|
316
|
+
"items-center": "align-items: center",
|
|
317
|
+
"items-end": "align-items: flex-end",
|
|
318
|
+
"items-stretch": "align-items: stretch",
|
|
319
|
+
"items-baseline": "align-items: baseline",
|
|
320
|
+
"self-start": "align-self: flex-start",
|
|
321
|
+
"self-center": "align-self: center",
|
|
322
|
+
"self-end": "align-self: flex-end",
|
|
323
|
+
"self-stretch": "align-self: stretch",
|
|
324
|
+
"self-auto": "align-self: auto",
|
|
325
|
+
// Justify
|
|
326
|
+
"justify-start": "justify-content: flex-start",
|
|
327
|
+
"justify-center": "justify-content: center",
|
|
328
|
+
"justify-end": "justify-content: flex-end",
|
|
329
|
+
"justify-between": "justify-content: space-between",
|
|
330
|
+
"justify-around": "justify-content: space-around",
|
|
331
|
+
"justify-evenly": "justify-content: space-evenly",
|
|
332
|
+
"justify-stretch": "justify-content: stretch",
|
|
333
|
+
"justify-items-start": "justify-items: start",
|
|
334
|
+
"justify-items-center": "justify-items: center",
|
|
335
|
+
"justify-items-end": "justify-items: end",
|
|
336
|
+
"justify-items-stretch": "justify-items: stretch",
|
|
337
|
+
// Place
|
|
338
|
+
"place-content-center": "place-content: center",
|
|
339
|
+
"place-content-start": "place-content: start",
|
|
340
|
+
"place-content-end": "place-content: end",
|
|
341
|
+
"place-content-between": "place-content: space-between",
|
|
342
|
+
"place-content-around": "place-content: space-around",
|
|
343
|
+
"place-content-evenly": "place-content: space-evenly",
|
|
344
|
+
"place-items-center": "place-items: center",
|
|
345
|
+
"place-items-start": "place-items: start",
|
|
346
|
+
"place-items-end": "place-items: end",
|
|
347
|
+
"place-items-stretch": "place-items: stretch",
|
|
348
|
+
// Width / Height special
|
|
349
|
+
"w-auto": "width: auto",
|
|
350
|
+
"w-full": "width: 100%",
|
|
351
|
+
"w-screen": "width: 100vw",
|
|
352
|
+
"w-svw": "width: 100svw",
|
|
353
|
+
"w-dvw": "width: 100dvw",
|
|
354
|
+
"w-min": "width: min-content",
|
|
355
|
+
"w-max": "width: max-content",
|
|
356
|
+
"w-fit": "width: fit-content",
|
|
357
|
+
"h-auto": "height: auto",
|
|
358
|
+
"h-full": "height: 100%",
|
|
359
|
+
"h-screen": "height: 100vh",
|
|
360
|
+
"h-svh": "height: 100svh",
|
|
361
|
+
"h-dvh": "height: 100dvh",
|
|
362
|
+
"h-min": "height: min-content",
|
|
363
|
+
"h-max": "height: max-content",
|
|
364
|
+
"h-fit": "height: fit-content",
|
|
365
|
+
"min-h-0": "min-height: 0",
|
|
366
|
+
"min-h-full": "min-height: 100%",
|
|
367
|
+
"min-h-screen": "min-height: 100vh",
|
|
368
|
+
"max-h-full": "max-height: 100%",
|
|
369
|
+
"max-h-screen": "max-height: 100vh",
|
|
370
|
+
"max-h-none": "max-height: none",
|
|
371
|
+
"min-w-0": "min-width: 0",
|
|
372
|
+
"min-w-full": "min-width: 100%",
|
|
373
|
+
"max-w-full": "max-width: 100%",
|
|
374
|
+
"max-w-none": "max-width: none",
|
|
375
|
+
"max-w-screen": "max-width: 100vw",
|
|
376
|
+
// Font weight keywords
|
|
377
|
+
"font-thin": "font-weight: 100",
|
|
378
|
+
"font-extralight": "font-weight: 200",
|
|
379
|
+
"font-light": "font-weight: 300",
|
|
380
|
+
"font-normal": "font-weight: 400",
|
|
381
|
+
"font-medium": "font-weight: 500",
|
|
382
|
+
"font-semibold": "font-weight: 600",
|
|
383
|
+
"font-bold": "font-weight: 700",
|
|
384
|
+
"font-extrabold": "font-weight: 800",
|
|
385
|
+
"font-black": "font-weight: 900",
|
|
386
|
+
// Font style
|
|
387
|
+
italic: "font-style: italic",
|
|
388
|
+
"not-italic": "font-style: normal",
|
|
389
|
+
// Text align
|
|
390
|
+
"text-left": "text-align: left",
|
|
391
|
+
"text-center": "text-align: center",
|
|
392
|
+
"text-right": "text-align: right",
|
|
393
|
+
"text-justify": "text-align: justify",
|
|
394
|
+
"text-start": "text-align: start",
|
|
395
|
+
"text-end": "text-align: end",
|
|
396
|
+
// Text transform
|
|
397
|
+
uppercase: "text-transform: uppercase",
|
|
398
|
+
lowercase: "text-transform: lowercase",
|
|
399
|
+
capitalize: "text-transform: capitalize",
|
|
400
|
+
"normal-case": "text-transform: none",
|
|
401
|
+
// Text decoration
|
|
402
|
+
underline: "text-decoration-line: underline",
|
|
403
|
+
overline: "text-decoration-line: overline",
|
|
404
|
+
"line-through": "text-decoration-line: line-through",
|
|
405
|
+
"no-underline": "text-decoration-line: none",
|
|
406
|
+
// Text wrap
|
|
407
|
+
"text-wrap": "text-wrap: wrap",
|
|
408
|
+
"text-nowrap": "text-wrap: nowrap",
|
|
409
|
+
"text-balance": "text-wrap: balance",
|
|
410
|
+
"text-pretty": "text-wrap: pretty",
|
|
411
|
+
// Whitespace
|
|
412
|
+
"whitespace-normal": "white-space: normal",
|
|
413
|
+
"whitespace-nowrap": "white-space: nowrap",
|
|
414
|
+
"whitespace-pre": "white-space: pre",
|
|
415
|
+
"whitespace-pre-line": "white-space: pre-line",
|
|
416
|
+
"whitespace-pre-wrap": "white-space: pre-wrap",
|
|
417
|
+
"whitespace-break-spaces": "white-space: break-spaces",
|
|
418
|
+
// Border style
|
|
419
|
+
"border-solid": "border-style: solid",
|
|
420
|
+
"border-dashed": "border-style: dashed",
|
|
421
|
+
"border-dotted": "border-style: dotted",
|
|
422
|
+
"border-double": "border-style: double",
|
|
423
|
+
"border-none": "border-style: none",
|
|
424
|
+
// Rounded special values
|
|
425
|
+
"rounded-none": "border-radius: 0",
|
|
426
|
+
"rounded-full": "border-radius: calc(infinity * 1px)",
|
|
427
|
+
// Cursor
|
|
428
|
+
"cursor-auto": "cursor: auto",
|
|
429
|
+
"cursor-default": "cursor: default",
|
|
430
|
+
"cursor-pointer": "cursor: pointer",
|
|
431
|
+
"cursor-wait": "cursor: wait",
|
|
432
|
+
"cursor-text": "cursor: text",
|
|
433
|
+
"cursor-move": "cursor: move",
|
|
434
|
+
"cursor-not-allowed": "cursor: not-allowed",
|
|
435
|
+
"cursor-crosshair": "cursor: crosshair",
|
|
436
|
+
"cursor-grab": "cursor: grab",
|
|
437
|
+
"cursor-grabbing": "cursor: grabbing",
|
|
438
|
+
// Pointer events
|
|
439
|
+
"pointer-events-none": "pointer-events: none",
|
|
440
|
+
"pointer-events-auto": "pointer-events: auto",
|
|
441
|
+
// User select
|
|
442
|
+
"select-none": "user-select: none",
|
|
443
|
+
"select-text": "user-select: text",
|
|
444
|
+
"select-all": "user-select: all",
|
|
445
|
+
"select-auto": "user-select: auto",
|
|
446
|
+
// Object fit
|
|
447
|
+
"object-contain": "object-fit: contain",
|
|
448
|
+
"object-cover": "object-fit: cover",
|
|
449
|
+
"object-fill": "object-fit: fill",
|
|
450
|
+
"object-none": "object-fit: none",
|
|
451
|
+
"object-scale-down": "object-fit: scale-down",
|
|
452
|
+
// Truncate
|
|
453
|
+
truncate: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap",
|
|
454
|
+
"text-ellipsis": "text-overflow: ellipsis",
|
|
455
|
+
"text-clip": "text-overflow: clip",
|
|
456
|
+
// Grow / shrink
|
|
457
|
+
grow: "flex-grow: 1",
|
|
458
|
+
"grow-0": "flex-grow: 0",
|
|
459
|
+
shrink: "flex-shrink: 1",
|
|
460
|
+
"shrink-0": "flex-shrink: 0",
|
|
461
|
+
// Appearance
|
|
462
|
+
"appearance-none": "appearance: none",
|
|
463
|
+
"appearance-auto": "appearance: auto",
|
|
464
|
+
// Isolate
|
|
465
|
+
isolate: "isolation: isolate",
|
|
466
|
+
"isolation-auto": "isolation: auto",
|
|
467
|
+
// List style
|
|
468
|
+
"list-none": "list-style-type: none",
|
|
469
|
+
"list-disc": "list-style-type: disc",
|
|
470
|
+
"list-decimal": "list-style-type: decimal",
|
|
471
|
+
// Box sizing
|
|
472
|
+
"box-border": "box-sizing: border-box",
|
|
473
|
+
"box-content": "box-sizing: content-box",
|
|
474
|
+
// Float
|
|
475
|
+
"float-left": "float: left",
|
|
476
|
+
"float-right": "float: right",
|
|
477
|
+
"float-none": "float: none",
|
|
478
|
+
"float-start": "float: inline-start",
|
|
479
|
+
"float-end": "float: inline-end",
|
|
480
|
+
"clear-left": "clear: left",
|
|
481
|
+
"clear-right": "clear: right",
|
|
482
|
+
"clear-both": "clear: both",
|
|
483
|
+
"clear-none": "clear: none",
|
|
484
|
+
// SR only
|
|
485
|
+
"sr-only": "position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0",
|
|
486
|
+
"not-sr-only": "position: static; width: auto; height: auto; padding: 0; margin: 0; overflow: visible; clip: auto; white-space: normal"
|
|
487
|
+
};
|
|
488
|
+
const OPACITY_NAMED = {
|
|
489
|
+
0: "0",
|
|
490
|
+
5: "0.05",
|
|
491
|
+
10: "0.1",
|
|
492
|
+
15: "0.15",
|
|
493
|
+
20: "0.2",
|
|
494
|
+
25: "0.25",
|
|
495
|
+
30: "0.3",
|
|
496
|
+
35: "0.35",
|
|
497
|
+
40: "0.4",
|
|
498
|
+
45: "0.45",
|
|
499
|
+
50: "0.5",
|
|
500
|
+
55: "0.55",
|
|
501
|
+
60: "0.6",
|
|
502
|
+
65: "0.65",
|
|
503
|
+
70: "0.7",
|
|
504
|
+
75: "0.75",
|
|
505
|
+
80: "0.8",
|
|
506
|
+
85: "0.85",
|
|
507
|
+
90: "0.9",
|
|
508
|
+
95: "0.95",
|
|
509
|
+
100: "1"
|
|
510
|
+
};
|
|
511
|
+
const RADIUS_SIZES = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl", "3xl", "4xl"]);
|
|
512
|
+
function escapeCSSSelector(cls) {
|
|
513
|
+
return cls.replace(/[^a-zA-Z0-9\-_]/g, (c) => `\\${c}`);
|
|
514
|
+
}
|
|
515
|
+
const MIN_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
516
|
+
const MAX_BREAKPOINTS = /* @__PURE__ */ new Set(["max-sm", "max-md", "max-lg", "max-xl", "max-2xl"]);
|
|
517
|
+
const CONTAINER_MIN = /* @__PURE__ */ new Set(["@sm", "@md", "@lg", "@xl", "@2xl"]);
|
|
518
|
+
const CONTAINER_MAX = /* @__PURE__ */ new Set(["@max-sm", "@max-md", "@max-lg", "@max-xl", "@max-2xl"]);
|
|
519
|
+
function parseVariants(cls) {
|
|
520
|
+
const parts = cls.split(":");
|
|
521
|
+
let tier = "base";
|
|
522
|
+
let pseudoSuffix = "";
|
|
523
|
+
let selectorPrefix = "";
|
|
524
|
+
let utilityIdx = 0;
|
|
525
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
526
|
+
const variant = parts[i];
|
|
527
|
+
if (MIN_BREAKPOINTS.has(variant)) {
|
|
528
|
+
tier = variant;
|
|
529
|
+
utilityIdx = i + 1;
|
|
530
|
+
} else if (MAX_BREAKPOINTS.has(variant)) {
|
|
531
|
+
tier = variant;
|
|
532
|
+
utilityIdx = i + 1;
|
|
533
|
+
} else if (CONTAINER_MIN.has(variant)) {
|
|
534
|
+
tier = variant;
|
|
535
|
+
utilityIdx = i + 1;
|
|
536
|
+
} else if (CONTAINER_MAX.has(variant)) {
|
|
537
|
+
tier = variant;
|
|
538
|
+
utilityIdx = i + 1;
|
|
539
|
+
} else if (variant === "dark") {
|
|
540
|
+
selectorPrefix = ".dark ";
|
|
541
|
+
utilityIdx = i + 1;
|
|
542
|
+
} else if (variant === "light") {
|
|
543
|
+
selectorPrefix = ".light ";
|
|
544
|
+
utilityIdx = i + 1;
|
|
545
|
+
} else if (variant in PSEUDO_CLASS_MAP) {
|
|
546
|
+
pseudoSuffix += PSEUDO_CLASS_MAP[variant];
|
|
547
|
+
utilityIdx = i + 1;
|
|
548
|
+
} else {
|
|
549
|
+
utilityIdx = i + 1;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
const utility = parts.slice(utilityIdx).join(":");
|
|
553
|
+
return { tier, pseudoSuffix, selectorPrefix, utility };
|
|
554
|
+
}
|
|
555
|
+
function generateDeclarations(utility) {
|
|
556
|
+
if (utility in KEYWORD_RULES) {
|
|
557
|
+
return KEYWORD_RULES[utility];
|
|
558
|
+
}
|
|
559
|
+
if (utility.startsWith("opacity-")) {
|
|
560
|
+
const val = utility.slice(8);
|
|
561
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
562
|
+
return `opacity: ${val.slice(1, -1)}`;
|
|
563
|
+
}
|
|
564
|
+
const n = parseInt(val, 10);
|
|
565
|
+
if (!Number.isNaN(n)) {
|
|
566
|
+
const v = OPACITY_NAMED[n] ?? String(n / 100);
|
|
567
|
+
return `opacity: ${v}`;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
if (utility.startsWith("z-")) {
|
|
571
|
+
const val = utility.slice(2);
|
|
572
|
+
if (val === "auto") {
|
|
573
|
+
return "z-index: auto";
|
|
574
|
+
}
|
|
575
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
576
|
+
return `z-index: ${val.slice(1, -1)}`;
|
|
577
|
+
}
|
|
578
|
+
if (!Number.isNaN(parseInt(val, 10))) {
|
|
579
|
+
return `z-index: ${val}`;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (utility === "border") {
|
|
583
|
+
return "border-width: 1px";
|
|
584
|
+
}
|
|
585
|
+
if (/^border-[trblxyse]$/.test(utility)) {
|
|
586
|
+
const side = utility.slice(7);
|
|
587
|
+
const cssSide = {
|
|
588
|
+
t: "border-top-width",
|
|
589
|
+
r: "border-right-width",
|
|
590
|
+
b: "border-bottom-width",
|
|
591
|
+
l: "border-left-width",
|
|
592
|
+
x: "border-inline-width",
|
|
593
|
+
y: "border-block-width",
|
|
594
|
+
s: "border-inline-start-width",
|
|
595
|
+
e: "border-inline-end-width"
|
|
596
|
+
};
|
|
597
|
+
if (side in cssSide) {
|
|
598
|
+
return `${cssSide[side]}: 1px`;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
if (/^border-\d+$/.test(utility)) {
|
|
602
|
+
const n = utility.slice(7);
|
|
603
|
+
return `border-width: ${n}px`;
|
|
604
|
+
}
|
|
605
|
+
const borderSideWidth = utility.match(/^border-([trblxse])-(\d+)$/);
|
|
606
|
+
if (borderSideWidth) {
|
|
607
|
+
const [, side, n] = borderSideWidth;
|
|
608
|
+
const cssSide = {
|
|
609
|
+
t: "border-top-width",
|
|
610
|
+
r: "border-right-width",
|
|
611
|
+
b: "border-bottom-width",
|
|
612
|
+
l: "border-left-width",
|
|
613
|
+
x: "border-inline-width",
|
|
614
|
+
y: "border-block-width",
|
|
615
|
+
s: "border-inline-start-width",
|
|
616
|
+
e: "border-inline-end-width"
|
|
617
|
+
};
|
|
618
|
+
if (side in cssSide) {
|
|
619
|
+
return `${cssSide[side]}: ${n}px`;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (utility === "rounded") {
|
|
623
|
+
return "border-radius: var(--radius)";
|
|
624
|
+
}
|
|
625
|
+
if (utility.startsWith("rounded-")) {
|
|
626
|
+
const val = utility.slice(8);
|
|
627
|
+
if (val === "none") {
|
|
628
|
+
return "border-radius: 0";
|
|
629
|
+
}
|
|
630
|
+
if (val === "full") {
|
|
631
|
+
return "border-radius: calc(infinity * 1px)";
|
|
632
|
+
}
|
|
633
|
+
if (RADIUS_SIZES.has(val)) {
|
|
634
|
+
return `border-radius: var(--radius-${val})`;
|
|
635
|
+
}
|
|
636
|
+
const roundedDir = {
|
|
637
|
+
t: "border-top-left-radius: var(--radius); border-top-right-radius: var(--radius)",
|
|
638
|
+
r: "border-top-right-radius: var(--radius); border-bottom-right-radius: var(--radius)",
|
|
639
|
+
b: "border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius)",
|
|
640
|
+
l: "border-top-left-radius: var(--radius); border-bottom-left-radius: var(--radius)",
|
|
641
|
+
tl: "border-top-left-radius: var(--radius)",
|
|
642
|
+
tr: "border-top-right-radius: var(--radius)",
|
|
643
|
+
bl: "border-bottom-left-radius: var(--radius)",
|
|
644
|
+
br: "border-bottom-right-radius: var(--radius)"
|
|
645
|
+
};
|
|
646
|
+
if (val in roundedDir) {
|
|
647
|
+
return roundedDir[val];
|
|
648
|
+
}
|
|
649
|
+
const m = val.match(/^([trblse]+)-(.+)$/);
|
|
650
|
+
if (m) {
|
|
651
|
+
const [, dir, size] = m;
|
|
652
|
+
const sizeVal = RADIUS_SIZES.has(size) ? `var(--radius-${size})` : size === "full" ? "calc(infinity * 1px)" : size === "none" ? "0" : size;
|
|
653
|
+
if (dir in roundedDir) {
|
|
654
|
+
return roundedDir[dir].replace(/var\(--radius\)/g, sizeVal);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
658
|
+
return `border-radius: ${val.slice(1, -1)}`;
|
|
659
|
+
}
|
|
660
|
+
if (RADIUS_SIZES.has(val)) {
|
|
661
|
+
return `border-radius: var(--radius-${val})`;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
if (utility.startsWith("text-") && !utility.startsWith("text-opacity")) {
|
|
665
|
+
const val = utility.slice(5);
|
|
666
|
+
if (TEXT_SIZES.has(val)) {
|
|
667
|
+
return `font-size: var(--text-${val}); line-height: var(--tw-leading, var(--text-${val}--line-height))`;
|
|
668
|
+
}
|
|
669
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
670
|
+
return `font-size: ${val.slice(1, -1).replace(/_/g, " ")}`;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (utility.startsWith("leading-")) {
|
|
674
|
+
const val = utility.slice(8);
|
|
675
|
+
const named = {
|
|
676
|
+
none: "1",
|
|
677
|
+
tight: "1.25",
|
|
678
|
+
snug: "1.375",
|
|
679
|
+
normal: "1.5",
|
|
680
|
+
relaxed: "1.625",
|
|
681
|
+
loose: "2"
|
|
682
|
+
};
|
|
683
|
+
if (val in named) {
|
|
684
|
+
return `line-height: ${named[val]}`;
|
|
685
|
+
}
|
|
686
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
687
|
+
return `line-height: ${val.slice(1, -1)}`;
|
|
688
|
+
}
|
|
689
|
+
if (!Number.isNaN(parseFloat(val))) {
|
|
690
|
+
return `line-height: calc(var(--spacing) * ${val})`;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if (utility.startsWith("tracking-")) {
|
|
694
|
+
const val = utility.slice(9);
|
|
695
|
+
const named = {
|
|
696
|
+
tighter: "var(--tracking-tighter)",
|
|
697
|
+
tight: "var(--tracking-tight)",
|
|
698
|
+
normal: "var(--tracking-normal)",
|
|
699
|
+
wide: "var(--tracking-wide)",
|
|
700
|
+
wider: "var(--tracking-wider)",
|
|
701
|
+
widest: "var(--tracking-widest)"
|
|
702
|
+
};
|
|
703
|
+
if (val in named) {
|
|
704
|
+
return `letter-spacing: ${named[val]}`;
|
|
705
|
+
}
|
|
706
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
707
|
+
return `letter-spacing: ${val.slice(1, -1)}`;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
if (utility.startsWith("font-") && !KEYWORD_RULES[utility]) {
|
|
711
|
+
const val = utility.slice(5);
|
|
712
|
+
const familyNames = {
|
|
713
|
+
sans: "var(--font-sans, ui-sans-serif, system-ui, sans-serif)",
|
|
714
|
+
serif: "var(--font-serif, ui-serif, Georgia, serif)",
|
|
715
|
+
mono: "var(--font-mono, ui-monospace, SFMono-Regular, monospace)"
|
|
716
|
+
};
|
|
717
|
+
if (val in familyNames) {
|
|
718
|
+
return `font-family: ${familyNames[val]}`;
|
|
719
|
+
}
|
|
720
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
721
|
+
return `font-family: ${val.slice(1, -1).replace(/_/g, " ")}`;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
if (utility === "shadow") {
|
|
725
|
+
return "box-shadow: var(--shadow)";
|
|
726
|
+
}
|
|
727
|
+
if (utility.startsWith("shadow-")) {
|
|
728
|
+
const val = utility.slice(7);
|
|
729
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
730
|
+
return `box-shadow: ${val.slice(1, -1).replace(/_/g, " ")}`;
|
|
731
|
+
}
|
|
732
|
+
const shadows = /* @__PURE__ */ new Set(["xs", "sm", "md", "lg", "xl", "2xl", "none", "inner"]);
|
|
733
|
+
if (shadows.has(val)) {
|
|
734
|
+
return val === "none" ? "box-shadow: none" : `box-shadow: var(--shadow-${val})`;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
if (utility === "outline-none") {
|
|
738
|
+
return "outline: 2px solid transparent; outline-offset: 2px";
|
|
739
|
+
}
|
|
740
|
+
if (utility.startsWith("outline-")) {
|
|
741
|
+
const val = utility.slice(8);
|
|
742
|
+
if (/^\d+$/.test(val)) {
|
|
743
|
+
return `outline-width: ${val}px`;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
if (utility === "ring") {
|
|
747
|
+
return "--tw-ring-shadow: 0 0 0 3px var(--tw-ring-color, #3b82f680)";
|
|
748
|
+
}
|
|
749
|
+
if (utility.startsWith("ring-")) {
|
|
750
|
+
const val = utility.slice(5);
|
|
751
|
+
if (/^\d+$/.test(val)) {
|
|
752
|
+
return `--tw-ring-shadow: 0 0 0 ${val}px var(--tw-ring-color, #3b82f680)`;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (utility.startsWith("grow-")) {
|
|
756
|
+
return `flex-grow: ${utility.slice(5)}`;
|
|
757
|
+
}
|
|
758
|
+
if (utility.startsWith("shrink-")) {
|
|
759
|
+
return `flex-shrink: ${utility.slice(7)}`;
|
|
760
|
+
}
|
|
761
|
+
if (utility.startsWith("order-")) {
|
|
762
|
+
const val = utility.slice(6);
|
|
763
|
+
if (val === "first") {
|
|
764
|
+
return "order: -9999";
|
|
765
|
+
}
|
|
766
|
+
if (val === "last") {
|
|
767
|
+
return "order: 9999";
|
|
768
|
+
}
|
|
769
|
+
if (val === "none") {
|
|
770
|
+
return "order: 0";
|
|
771
|
+
}
|
|
772
|
+
return `order: ${val}`;
|
|
773
|
+
}
|
|
774
|
+
if (utility.startsWith("columns-")) {
|
|
775
|
+
const val = utility.slice(8);
|
|
776
|
+
if (!Number.isNaN(parseInt(val, 10))) {
|
|
777
|
+
return `columns: ${val}`;
|
|
778
|
+
}
|
|
779
|
+
return `columns: var(--container-${val})`;
|
|
780
|
+
}
|
|
781
|
+
if (utility.startsWith("grid-cols-")) {
|
|
782
|
+
const val = utility.slice(10);
|
|
783
|
+
if (val === "none") {
|
|
784
|
+
return "grid-template-columns: none";
|
|
785
|
+
}
|
|
786
|
+
if (val === "subgrid") {
|
|
787
|
+
return "grid-template-columns: subgrid";
|
|
788
|
+
}
|
|
789
|
+
if (val.startsWith("[")) {
|
|
790
|
+
return `grid-template-columns: ${val.slice(1, -1).replace(/_/g, " ")}`;
|
|
791
|
+
}
|
|
792
|
+
return `grid-template-columns: repeat(${val}, minmax(0, 1fr))`;
|
|
793
|
+
}
|
|
794
|
+
if (utility.startsWith("grid-rows-")) {
|
|
795
|
+
const val = utility.slice(10);
|
|
796
|
+
if (val === "none") {
|
|
797
|
+
return "grid-template-rows: none";
|
|
798
|
+
}
|
|
799
|
+
if (val === "subgrid") {
|
|
800
|
+
return "grid-template-rows: subgrid";
|
|
801
|
+
}
|
|
802
|
+
if (val.startsWith("[")) {
|
|
803
|
+
return `grid-template-rows: ${val.slice(1, -1).replace(/_/g, " ")}`;
|
|
804
|
+
}
|
|
805
|
+
return `grid-template-rows: repeat(${val}, minmax(0, 1fr))`;
|
|
806
|
+
}
|
|
807
|
+
if (utility.startsWith("col-span-")) {
|
|
808
|
+
const val = utility.slice(9);
|
|
809
|
+
return val === "full" ? "grid-column: 1 / -1" : `grid-column: span ${val} / span ${val}`;
|
|
810
|
+
}
|
|
811
|
+
if (utility.startsWith("row-span-")) {
|
|
812
|
+
const val = utility.slice(9);
|
|
813
|
+
return val === "full" ? "grid-row: 1 / -1" : `grid-row: span ${val} / span ${val}`;
|
|
814
|
+
}
|
|
815
|
+
if (utility.startsWith("scale-x-")) {
|
|
816
|
+
const val = utility.slice(8);
|
|
817
|
+
return `--tw-scale-x: ${parseFloat(val) / 100}; scale: var(--tw-scale-x) var(--tw-scale-y, 1)`;
|
|
818
|
+
}
|
|
819
|
+
if (utility.startsWith("scale-y-")) {
|
|
820
|
+
const val = utility.slice(8);
|
|
821
|
+
return `--tw-scale-y: ${parseFloat(val) / 100}; scale: var(--tw-scale-x, 1) var(--tw-scale-y)`;
|
|
822
|
+
}
|
|
823
|
+
if (utility.startsWith("scale-")) {
|
|
824
|
+
const val = utility.slice(6);
|
|
825
|
+
const n = parseFloat(val) / 100;
|
|
826
|
+
return `scale: ${n}`;
|
|
827
|
+
}
|
|
828
|
+
if (utility.startsWith("rotate-")) {
|
|
829
|
+
const val = utility.slice(7);
|
|
830
|
+
if (val.startsWith("[")) {
|
|
831
|
+
return `rotate: ${val.slice(1, -1)}`;
|
|
832
|
+
}
|
|
833
|
+
return `rotate: ${val}deg`;
|
|
834
|
+
}
|
|
835
|
+
if (utility.startsWith("translate-x-")) {
|
|
836
|
+
const val = utility.slice(12);
|
|
837
|
+
const v = resolveSpacingValue(val, "width");
|
|
838
|
+
return `translate: ${v} var(--tw-translate-y, 0)`;
|
|
839
|
+
}
|
|
840
|
+
if (utility.startsWith("translate-y-")) {
|
|
841
|
+
const val = utility.slice(12);
|
|
842
|
+
const v = resolveSpacingValue(val, "height");
|
|
843
|
+
return `translate: var(--tw-translate-x, 0) ${v}`;
|
|
844
|
+
}
|
|
845
|
+
if (utility === "transition") {
|
|
846
|
+
return "transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; transition-timing-function: var(--tw-ease, ease); transition-duration: var(--tw-duration, 150ms)";
|
|
847
|
+
}
|
|
848
|
+
if (utility === "transition-all") {
|
|
849
|
+
return "transition-property: all; transition-timing-function: var(--tw-ease, ease); transition-duration: var(--tw-duration, 150ms)";
|
|
850
|
+
}
|
|
851
|
+
if (utility === "transition-none") {
|
|
852
|
+
return "transition-property: none";
|
|
853
|
+
}
|
|
854
|
+
if (utility.startsWith("duration-")) {
|
|
855
|
+
const val = utility.slice(9);
|
|
856
|
+
if (val.startsWith("[")) {
|
|
857
|
+
return `transition-duration: ${val.slice(1, -1)}`;
|
|
858
|
+
}
|
|
859
|
+
return `transition-duration: ${val}ms`;
|
|
860
|
+
}
|
|
861
|
+
if (utility.startsWith("ease-")) {
|
|
862
|
+
const eases = {
|
|
863
|
+
linear: "linear",
|
|
864
|
+
in: "cubic-bezier(0.4, 0, 1, 1)",
|
|
865
|
+
out: "cubic-bezier(0, 0, 0.2, 1)",
|
|
866
|
+
"in-out": "cubic-bezier(0.4, 0, 0.2, 1)"
|
|
867
|
+
};
|
|
868
|
+
const val = utility.slice(5);
|
|
869
|
+
if (val in eases) {
|
|
870
|
+
return `transition-timing-function: ${eases[val]}`;
|
|
871
|
+
}
|
|
872
|
+
return `transition-timing-function: var(--ease-${val})`;
|
|
873
|
+
}
|
|
874
|
+
if (utility.startsWith("delay-")) {
|
|
875
|
+
const val = utility.slice(6);
|
|
876
|
+
if (val.startsWith("[")) {
|
|
877
|
+
return `transition-delay: ${val.slice(1, -1)}`;
|
|
878
|
+
}
|
|
879
|
+
return `transition-delay: ${val}ms`;
|
|
880
|
+
}
|
|
881
|
+
const colorPrefixes = Object.keys(COLOR_PROPS).sort((a, b) => b.length - a.length);
|
|
882
|
+
for (const prefix of colorPrefixes) {
|
|
883
|
+
if (utility === prefix || utility.startsWith(`${prefix}-`)) {
|
|
884
|
+
const rest = utility.slice(prefix.length + 1);
|
|
885
|
+
if (!rest && utility !== prefix) {
|
|
886
|
+
continue;
|
|
887
|
+
}
|
|
888
|
+
if (!rest && utility === prefix) {
|
|
889
|
+
continue;
|
|
890
|
+
}
|
|
891
|
+
const cssProp = COLOR_PROPS[prefix];
|
|
892
|
+
const colorVal = resolveColorValue(rest);
|
|
893
|
+
return `${cssProp}: ${colorVal}`;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
const spacingPrefixes = Object.keys(SPACING_PROPS).sort((a, b) => b.length - a.length);
|
|
897
|
+
for (const prefix of spacingPrefixes) {
|
|
898
|
+
const dashPrefix = `${prefix}-`;
|
|
899
|
+
if (utility.startsWith(dashPrefix)) {
|
|
900
|
+
const val = utility.slice(dashPrefix.length);
|
|
901
|
+
const negative = val.startsWith("-");
|
|
902
|
+
const rawVal = negative ? val.slice(1) : val;
|
|
903
|
+
const props = SPACING_PROPS[prefix];
|
|
904
|
+
const resolved = resolveSpacingValue(negative ? `-${rawVal}` : rawVal, props[0]);
|
|
905
|
+
if (!resolved) {
|
|
906
|
+
continue;
|
|
907
|
+
}
|
|
908
|
+
return props.map((p) => `${p}: ${resolved}`).join("; ");
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
if (utility.startsWith("[") && utility.endsWith("]") && utility.includes(":")) {
|
|
912
|
+
const inner = utility.slice(1, -1).replace(/_/g, " ");
|
|
913
|
+
const colonIdx = inner.indexOf(":");
|
|
914
|
+
const prop = inner.slice(0, colonIdx);
|
|
915
|
+
const val = inner.slice(colonIdx + 1);
|
|
916
|
+
return `${prop}: ${val}`;
|
|
917
|
+
}
|
|
918
|
+
return "";
|
|
919
|
+
}
|
|
920
|
+
function generateCSSRule(className) {
|
|
921
|
+
const { utility, pseudoSuffix, selectorPrefix } = parseVariants(className);
|
|
922
|
+
const declarations = generateDeclarations(utility);
|
|
923
|
+
if (!declarations) {
|
|
924
|
+
return "";
|
|
925
|
+
}
|
|
926
|
+
const escapedClass = escapeCSSSelector(className);
|
|
927
|
+
const selector = `${selectorPrefix}.${escapedClass}${pseudoSuffix}`;
|
|
928
|
+
return `${selector} { ${declarations} }`;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
const TIER_ORDER = [
|
|
932
|
+
"base",
|
|
933
|
+
// viewport min-width (ascending — sm wins over base, lg wins over md)
|
|
934
|
+
"sm",
|
|
935
|
+
"md",
|
|
936
|
+
"lg",
|
|
937
|
+
"xl",
|
|
938
|
+
"2xl",
|
|
939
|
+
// viewport max-width (descending size — max-sm is most restrictive, must win)
|
|
940
|
+
"max-2xl",
|
|
941
|
+
"max-xl",
|
|
942
|
+
"max-lg",
|
|
943
|
+
"max-md",
|
|
944
|
+
"max-sm",
|
|
945
|
+
// container query min (ascending)
|
|
946
|
+
"@sm",
|
|
947
|
+
"@md",
|
|
948
|
+
"@lg",
|
|
949
|
+
"@xl",
|
|
950
|
+
"@2xl",
|
|
951
|
+
// container query max (descending)
|
|
952
|
+
"@max-2xl",
|
|
953
|
+
"@max-xl",
|
|
954
|
+
"@max-lg",
|
|
955
|
+
"@max-md",
|
|
956
|
+
"@max-sm"
|
|
957
|
+
];
|
|
958
|
+
const TIER_SET = new Set(TIER_ORDER);
|
|
959
|
+
function supportsConstructableSheets() {
|
|
960
|
+
return typeof document !== "undefined" && typeof CSSStyleSheet !== "undefined" && "adoptedStyleSheets" in document;
|
|
961
|
+
}
|
|
962
|
+
let sheets = null;
|
|
963
|
+
let fallbackStyle = null;
|
|
964
|
+
const injected = /* @__PURE__ */ new Set();
|
|
965
|
+
function wrapForTier(cssRule, tier) {
|
|
966
|
+
if (tier === "base") {
|
|
967
|
+
return cssRule;
|
|
968
|
+
}
|
|
969
|
+
if (tier.startsWith("@")) {
|
|
970
|
+
const bp = tier.slice(1);
|
|
971
|
+
const bpValue2 = BREAKPOINTS[bp];
|
|
972
|
+
if (!bpValue2) {
|
|
973
|
+
return cssRule;
|
|
974
|
+
}
|
|
975
|
+
const query2 = bp.startsWith("max-") ? `(width <= ${bpValue2})` : `(width >= ${bpValue2})`;
|
|
976
|
+
return `@container ${query2} { ${cssRule} }`;
|
|
977
|
+
}
|
|
978
|
+
const bpValue = BREAKPOINTS[tier];
|
|
979
|
+
if (!bpValue) {
|
|
980
|
+
return cssRule;
|
|
981
|
+
}
|
|
982
|
+
const query = tier.startsWith("max-") ? `(max-width: ${bpValue})` : `(min-width: ${bpValue})`;
|
|
983
|
+
return `@media ${query} { ${cssRule} }`;
|
|
984
|
+
}
|
|
985
|
+
function initSheets() {
|
|
986
|
+
const map = /* @__PURE__ */ new Map();
|
|
987
|
+
const adopted = [];
|
|
988
|
+
for (const tier of TIER_ORDER) {
|
|
989
|
+
const sheet = new CSSStyleSheet();
|
|
990
|
+
map.set(tier, sheet);
|
|
991
|
+
adopted.push(sheet);
|
|
992
|
+
}
|
|
993
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, ...adopted];
|
|
994
|
+
return map;
|
|
995
|
+
}
|
|
996
|
+
function initFallbackStyle() {
|
|
997
|
+
const el = document.createElement("style");
|
|
998
|
+
el.id = "__csszyx_dynamic__";
|
|
999
|
+
document.head.appendChild(el);
|
|
1000
|
+
return el;
|
|
1001
|
+
}
|
|
1002
|
+
function resolveTier(className) {
|
|
1003
|
+
const colonIdx = className.indexOf(":");
|
|
1004
|
+
if (colonIdx === -1) {
|
|
1005
|
+
return "base";
|
|
1006
|
+
}
|
|
1007
|
+
const prefix = className.slice(0, colonIdx);
|
|
1008
|
+
const normalizedPrefix = prefix.startsWith("@") ? prefix : prefix;
|
|
1009
|
+
if (TIER_SET.has(normalizedPrefix)) {
|
|
1010
|
+
return normalizedPrefix;
|
|
1011
|
+
}
|
|
1012
|
+
return "base";
|
|
1013
|
+
}
|
|
1014
|
+
function injectRule(className, cssRule, tier = "base") {
|
|
1015
|
+
if (injected.has(className)) {
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
injected.add(className);
|
|
1019
|
+
if (!cssRule) {
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
if (supportsConstructableSheets()) {
|
|
1023
|
+
if (!sheets) {
|
|
1024
|
+
sheets = initSheets();
|
|
1025
|
+
}
|
|
1026
|
+
const resolved = sheets.get(tier) ?? sheets.get("base");
|
|
1027
|
+
if (!resolved) {
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
1030
|
+
const sheet = resolved;
|
|
1031
|
+
const rule = wrapForTier(cssRule, tier);
|
|
1032
|
+
try {
|
|
1033
|
+
sheet.insertRule(rule, sheet.cssRules.length);
|
|
1034
|
+
} catch {
|
|
1035
|
+
}
|
|
1036
|
+
} else {
|
|
1037
|
+
if (!fallbackStyle) {
|
|
1038
|
+
fallbackStyle = initFallbackStyle();
|
|
1039
|
+
}
|
|
1040
|
+
const rule = wrapForTier(cssRule, tier);
|
|
1041
|
+
fallbackStyle.sheet?.insertRule(rule, fallbackStyle.sheet.cssRules.length);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
function cleanup$1() {
|
|
1045
|
+
if (sheets) {
|
|
1046
|
+
const tierSheets = new Set(sheets.values());
|
|
1047
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.filter((s) => !tierSheets.has(s));
|
|
1048
|
+
sheets = null;
|
|
1049
|
+
}
|
|
1050
|
+
if (fallbackStyle) {
|
|
1051
|
+
fallbackStyle.remove();
|
|
1052
|
+
fallbackStyle = null;
|
|
1053
|
+
}
|
|
1054
|
+
injected.clear();
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
let manifestClasses = null;
|
|
1058
|
+
let mangleMap = null;
|
|
1059
|
+
let manifestUrl = "/csszyx-manifest.json";
|
|
1060
|
+
let fetchPromise = null;
|
|
1061
|
+
function setManifestUrl(url) {
|
|
1062
|
+
manifestUrl = url;
|
|
1063
|
+
}
|
|
1064
|
+
function ensureManifest() {
|
|
1065
|
+
if (manifestClasses !== null) {
|
|
1066
|
+
return Promise.resolve();
|
|
1067
|
+
}
|
|
1068
|
+
if (fetchPromise) {
|
|
1069
|
+
return fetchPromise;
|
|
1070
|
+
}
|
|
1071
|
+
fetchPromise = fetch(manifestUrl).then((r) => {
|
|
1072
|
+
if (!r.ok) {
|
|
1073
|
+
throw new Error(`csszyx: manifest fetch failed ${r.status}`);
|
|
1074
|
+
}
|
|
1075
|
+
return r.json();
|
|
1076
|
+
}).then((data) => {
|
|
1077
|
+
manifestClasses = new Set(data.classes);
|
|
1078
|
+
mangleMap = data.mangleMap ?? null;
|
|
1079
|
+
}).catch(() => {
|
|
1080
|
+
manifestClasses = /* @__PURE__ */ new Set();
|
|
1081
|
+
mangleMap = null;
|
|
1082
|
+
fetchPromise = null;
|
|
1083
|
+
});
|
|
1084
|
+
return fetchPromise;
|
|
1085
|
+
}
|
|
1086
|
+
async function preloadManifest$1(url) {
|
|
1087
|
+
if (url) {
|
|
1088
|
+
setManifestUrl(url);
|
|
1089
|
+
}
|
|
1090
|
+
return ensureManifest();
|
|
1091
|
+
}
|
|
1092
|
+
function lookupManifest(originalClass) {
|
|
1093
|
+
if (manifestClasses === null) {
|
|
1094
|
+
return null;
|
|
1095
|
+
}
|
|
1096
|
+
if (!manifestClasses.has(originalClass)) {
|
|
1097
|
+
return null;
|
|
1098
|
+
}
|
|
1099
|
+
if (mangleMap && originalClass in mangleMap) {
|
|
1100
|
+
return mangleMap[originalClass];
|
|
1101
|
+
}
|
|
1102
|
+
return originalClass;
|
|
1103
|
+
}
|
|
1104
|
+
function resetManifest() {
|
|
1105
|
+
manifestClasses = null;
|
|
1106
|
+
mangleMap = null;
|
|
1107
|
+
fetchPromise = null;
|
|
1108
|
+
manifestUrl = "/csszyx-manifest.json";
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
const isServer = typeof document === "undefined";
|
|
1112
|
+
|
|
1113
|
+
function dynamic(szProps) {
|
|
1114
|
+
const { className } = transform(szProps);
|
|
1115
|
+
if (!className) {
|
|
1116
|
+
return "";
|
|
1117
|
+
}
|
|
1118
|
+
if (isServer) {
|
|
1119
|
+
const ssrMangleMap = globalThis.__csszyx_ssr_mangle_map;
|
|
1120
|
+
if (ssrMangleMap) {
|
|
1121
|
+
return className.split(" ").filter(Boolean).map((c) => ssrMangleMap[c] ?? c).join(" ");
|
|
1122
|
+
}
|
|
1123
|
+
return className;
|
|
1124
|
+
}
|
|
1125
|
+
ensureManifest();
|
|
1126
|
+
const classes = className.split(" ").filter(Boolean);
|
|
1127
|
+
const outputClasses = [];
|
|
1128
|
+
for (const cls of classes) {
|
|
1129
|
+
const manifestResult = lookupManifest(cls);
|
|
1130
|
+
if (manifestResult !== null) {
|
|
1131
|
+
outputClasses.push(manifestResult);
|
|
1132
|
+
} else {
|
|
1133
|
+
const tier = resolveTier(cls);
|
|
1134
|
+
const rule = generateCSSRule(cls);
|
|
1135
|
+
injectRule(cls, rule, tier);
|
|
1136
|
+
outputClasses.push(cls);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
return outputClasses.join(" ");
|
|
1140
|
+
}
|
|
1141
|
+
async function preloadManifest(url) {
|
|
1142
|
+
return preloadManifest$1(url);
|
|
1143
|
+
}
|
|
1144
|
+
function cleanup() {
|
|
1145
|
+
cleanup$1();
|
|
1146
|
+
resetManifest();
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
export { cleanup as a, preloadManifest as b, cleanup$1 as c, dynamic as d, preloadManifest$1 as p, resetManifest as r, setManifestUrl as s };
|