regexcss 0.1.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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/generator-D6K3x9Hv.mjs +174 -0
- package/dist/generator-D6K3x9Hv.mjs.map +1 -0
- package/dist/helpers.d.mts +34 -0
- package/dist/helpers.mjs +50 -0
- package/dist/helpers.mjs.map +1 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -0
- package/dist/preset.d.mts +118 -0
- package/dist/preset.mjs +379 -0
- package/dist/preset.mjs.map +1 -0
- package/dist/types-jVjPo8bk.d.mts +137 -0
- package/dist/vite.d.mts +11 -0
- package/dist/vite.mjs +185 -0
- package/dist/vite.mjs.map +1 -0
- package/package.json +72 -0
package/dist/preset.mjs
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { rem } from "./helpers.mjs";
|
|
2
|
+
//#region src/preset/rules/color/background-color.ts
|
|
3
|
+
const backgroundColorRules = [[/^bg-(\w+)$/, ([, color]) => ({ backgroundColor: color ?? "" })]];
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/preset/rules/color/index.ts
|
|
6
|
+
const colorRules = [...backgroundColorRules];
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/preset/rules/flexbox-grid/align-content.ts
|
|
9
|
+
const ALIGN_CONTENT = {
|
|
10
|
+
normal: "normal",
|
|
11
|
+
center: "center",
|
|
12
|
+
start: "flex-start",
|
|
13
|
+
end: "flex-end",
|
|
14
|
+
between: "space-between",
|
|
15
|
+
around: "space-around",
|
|
16
|
+
evenly: "space-evenly",
|
|
17
|
+
baseline: "baseline",
|
|
18
|
+
stretch: "stretch"
|
|
19
|
+
};
|
|
20
|
+
const alignContentRules = [[/^content-(normal|center|start|end|between|around|evenly|baseline|stretch)$/, ([, k]) => ({ "align-content": ALIGN_CONTENT[k ?? ""] ?? "" })]];
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/preset/rules/flexbox-grid/align-items.ts
|
|
23
|
+
const ALIGN_ITEMS = {
|
|
24
|
+
start: "flex-start",
|
|
25
|
+
end: "flex-end",
|
|
26
|
+
center: "center",
|
|
27
|
+
baseline: "baseline",
|
|
28
|
+
stretch: "stretch"
|
|
29
|
+
};
|
|
30
|
+
const alignItemsRules = [[/^items-(start|end|center|baseline|stretch)$/, ([, k]) => ({ "align-items": ALIGN_ITEMS[k ?? ""] ?? "" })]];
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/preset/rules/flexbox-grid/align-self.ts
|
|
33
|
+
const ALIGN_SELF = {
|
|
34
|
+
auto: "auto",
|
|
35
|
+
start: "flex-start",
|
|
36
|
+
end: "flex-end",
|
|
37
|
+
center: "center",
|
|
38
|
+
stretch: "stretch",
|
|
39
|
+
baseline: "baseline"
|
|
40
|
+
};
|
|
41
|
+
const alignSelfRules = [[/^self-(auto|start|end|center|stretch|baseline)$/, ([, k]) => ({ "align-self": ALIGN_SELF[k ?? ""] ?? "" })]];
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/preset/rules/flexbox-grid/gap.ts
|
|
44
|
+
const props$4 = {
|
|
45
|
+
"": "gap",
|
|
46
|
+
x: "column-gap",
|
|
47
|
+
y: "row-gap"
|
|
48
|
+
};
|
|
49
|
+
const gapRules = [[/^gap(?:-([xy]))?-(\d+(?:\.\d+)?|\.\d+)$/, ([, dir, num]) => {
|
|
50
|
+
const prop = props$4[dir ?? ""];
|
|
51
|
+
return prop && num ? { [prop]: rem(num) } : void 0;
|
|
52
|
+
}]];
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/preset/rules/flexbox-grid/grid-template-columns.ts
|
|
55
|
+
const KEYWORDS$2 = {
|
|
56
|
+
none: "none",
|
|
57
|
+
subgrid: "subgrid"
|
|
58
|
+
};
|
|
59
|
+
const gridTemplateColumnsRules = [[/^grid-cols-(none|subgrid)$/, ([, k]) => ({ "grid-template-columns": KEYWORDS$2[k ?? ""] ?? "" })], [/^grid-cols-(\d+)$/, ([, n]) => ({ "grid-template-columns": `repeat(${n}, minmax(0, 1fr))` })]];
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/preset/rules/flexbox-grid/grid-template-rows.ts
|
|
62
|
+
const KEYWORDS$1 = {
|
|
63
|
+
none: "none",
|
|
64
|
+
subgrid: "subgrid"
|
|
65
|
+
};
|
|
66
|
+
const gridTemplateRowsRules = [[/^grid-rows-(none|subgrid)$/, ([, k]) => ({ "grid-template-rows": KEYWORDS$1[k ?? ""] ?? "" })], [/^grid-rows-(\d+)$/, ([, n]) => ({ "grid-template-rows": `repeat(${n}, minmax(0, 1fr))` })]];
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/preset/rules/flexbox-grid/justify-content.ts
|
|
69
|
+
const JUSTIFY_CONTENT = {
|
|
70
|
+
normal: "normal",
|
|
71
|
+
start: "flex-start",
|
|
72
|
+
end: "flex-end",
|
|
73
|
+
center: "center",
|
|
74
|
+
between: "space-between",
|
|
75
|
+
around: "space-around",
|
|
76
|
+
evenly: "space-evenly",
|
|
77
|
+
stretch: "stretch"
|
|
78
|
+
};
|
|
79
|
+
const justifyContentRules = [[/^justify-(normal|start|end|center|between|around|evenly|stretch)$/, ([, k]) => ({ "justify-content": JUSTIFY_CONTENT[k ?? ""] ?? "" })]];
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/preset/rules/flexbox-grid/justify-items.ts
|
|
82
|
+
const justifyItemsRules = [[/^justify-items-(normal|start|end|center|stretch)$/, ([, v]) => ({ "justify-items": v ?? "" })]];
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/preset/rules/flexbox-grid/justify-self.ts
|
|
85
|
+
const justifySelfRules = [[/^justify-self-(auto|start|end|center|stretch)$/, ([, v]) => ({ "justify-self": v ?? "" })]];
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/preset/rules/flexbox-grid/order.ts
|
|
88
|
+
const KEYWORDS = {
|
|
89
|
+
first: "calc(-infinity)",
|
|
90
|
+
last: "calc(infinity)",
|
|
91
|
+
none: "0"
|
|
92
|
+
};
|
|
93
|
+
const orderRules = [[/^order-(first|last|none)$/, ([, k]) => ({ order: KEYWORDS[k ?? ""] ?? "" })], [/^(-?)order-(\d+)$/, ([, neg, n]) => n ? { order: `${neg ?? ""}${n}` } : void 0]];
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/preset/rules/flexbox-grid/index.ts
|
|
96
|
+
const flexboxGridRules = [
|
|
97
|
+
...alignContentRules,
|
|
98
|
+
...alignItemsRules,
|
|
99
|
+
...alignSelfRules,
|
|
100
|
+
...gapRules,
|
|
101
|
+
...gridTemplateColumnsRules,
|
|
102
|
+
...gridTemplateRowsRules,
|
|
103
|
+
...justifyContentRules,
|
|
104
|
+
...justifyItemsRules,
|
|
105
|
+
...justifySelfRules,
|
|
106
|
+
...orderRules
|
|
107
|
+
];
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/preset/rules/layout/display.ts
|
|
110
|
+
const DISPLAY = {
|
|
111
|
+
inline: "inline",
|
|
112
|
+
block: "block",
|
|
113
|
+
"inline-block": "inline-block",
|
|
114
|
+
"flow-root": "flow-root",
|
|
115
|
+
flex: "flex",
|
|
116
|
+
"inline-flex": "inline-flex",
|
|
117
|
+
grid: "grid",
|
|
118
|
+
"inline-grid": "inline-grid",
|
|
119
|
+
contents: "contents",
|
|
120
|
+
table: "table",
|
|
121
|
+
"inline-table": "inline-table",
|
|
122
|
+
"table-caption": "table-caption",
|
|
123
|
+
"table-cell": "table-cell",
|
|
124
|
+
"table-column": "table-column",
|
|
125
|
+
"table-column-group": "table-column-group",
|
|
126
|
+
"table-footer-group": "table-footer-group",
|
|
127
|
+
"table-header-group": "table-header-group",
|
|
128
|
+
"table-row-group": "table-row-group",
|
|
129
|
+
"table-row": "table-row",
|
|
130
|
+
"list-item": "list-item",
|
|
131
|
+
hidden: "none"
|
|
132
|
+
};
|
|
133
|
+
const srOnly = {
|
|
134
|
+
position: "absolute",
|
|
135
|
+
width: "1px",
|
|
136
|
+
height: "1px",
|
|
137
|
+
padding: "0",
|
|
138
|
+
margin: "-1px",
|
|
139
|
+
overflow: "hidden",
|
|
140
|
+
clip: "rect(0, 0, 0, 0)",
|
|
141
|
+
"white-space": "nowrap",
|
|
142
|
+
"border-width": "0"
|
|
143
|
+
};
|
|
144
|
+
const notSrOnly = {
|
|
145
|
+
position: "static",
|
|
146
|
+
width: "auto",
|
|
147
|
+
height: "auto",
|
|
148
|
+
padding: "0",
|
|
149
|
+
margin: "0",
|
|
150
|
+
overflow: "visible",
|
|
151
|
+
clip: "auto",
|
|
152
|
+
"white-space": "normal"
|
|
153
|
+
};
|
|
154
|
+
const displayRules = [
|
|
155
|
+
...Object.entries(DISPLAY).map(([name, value]) => [new RegExp(`^${name}$`), () => ({ display: value })]),
|
|
156
|
+
[/^sr-only$/, () => srOnly],
|
|
157
|
+
[/^not-sr-only$/, () => notSrOnly]
|
|
158
|
+
];
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/preset/rules/layout/object-fit.ts
|
|
161
|
+
const objectFitRules = [[/^object-(contain|cover|fill|none|scale-down)$/, ([, v]) => ({ "object-fit": v ?? "" })]];
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/preset/rules/layout/object-position.ts
|
|
164
|
+
const POSITIONS = {
|
|
165
|
+
bottom: "bottom",
|
|
166
|
+
center: "center",
|
|
167
|
+
left: "left",
|
|
168
|
+
"left-bottom": "left bottom",
|
|
169
|
+
"left-top": "left top",
|
|
170
|
+
right: "right",
|
|
171
|
+
"right-bottom": "right bottom",
|
|
172
|
+
"right-top": "right top",
|
|
173
|
+
top: "top"
|
|
174
|
+
};
|
|
175
|
+
const objectPositionRules = [[/^object-(left-bottom|left-top|right-bottom|right-top|bottom|center|left|right|top)$/, ([, k]) => ({ "object-position": POSITIONS[k ?? ""] ?? "" })]];
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/preset/rules/layout/overflow.ts
|
|
178
|
+
const props$3 = {
|
|
179
|
+
"": "overflow",
|
|
180
|
+
x: "overflow-x",
|
|
181
|
+
y: "overflow-y"
|
|
182
|
+
};
|
|
183
|
+
const overflowRules = [[/^overflow(?:-([xy]))?-(auto|hidden|clip|visible|scroll)$/, ([, dir, v]) => {
|
|
184
|
+
const prop = props$3[dir ?? ""];
|
|
185
|
+
return prop && v ? { [prop]: v } : void 0;
|
|
186
|
+
}]];
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/preset/rules/layout/overscroll.ts
|
|
189
|
+
const props$2 = {
|
|
190
|
+
"": "overscroll-behavior",
|
|
191
|
+
x: "overscroll-behavior-x",
|
|
192
|
+
y: "overscroll-behavior-y"
|
|
193
|
+
};
|
|
194
|
+
const overscrollRules = [[/^overscroll(?:-([xy]))?-(auto|contain|none)$/, ([, dir, v]) => {
|
|
195
|
+
const prop = props$2[dir ?? ""];
|
|
196
|
+
return prop && v ? { [prop]: v } : void 0;
|
|
197
|
+
}]];
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/preset/rules/layout/position.ts
|
|
200
|
+
const positionRules = [[/^(static|fixed|absolute|relative|sticky)$/, ([, v]) => ({ position: v ?? "" })]];
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/preset/rules/layout/z-index.ts
|
|
203
|
+
const zIndexRules = [[/^z-auto$/, () => ({ "z-index": "auto" })], [/^(-?)z-(\d+)$/, ([, neg, n]) => n ? { "z-index": `${neg ?? ""}${n}` } : void 0]];
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/preset/rules/layout/index.ts
|
|
206
|
+
const layoutRules = [
|
|
207
|
+
...displayRules,
|
|
208
|
+
...objectFitRules,
|
|
209
|
+
...objectPositionRules,
|
|
210
|
+
...overflowRules,
|
|
211
|
+
...overscrollRules,
|
|
212
|
+
...positionRules,
|
|
213
|
+
...zIndexRules
|
|
214
|
+
];
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/preset/rules/spacing/margin.ts
|
|
217
|
+
const props$1 = {
|
|
218
|
+
m: "margin",
|
|
219
|
+
mx: "margin-inline",
|
|
220
|
+
my: "margin-block",
|
|
221
|
+
ml: "margin-left",
|
|
222
|
+
mr: "margin-right",
|
|
223
|
+
mt: "margin-top",
|
|
224
|
+
mb: "margin-bottom"
|
|
225
|
+
};
|
|
226
|
+
const marginRules = [
|
|
227
|
+
[/^(m[xylrtb]?)-(\d+(?:\.\d+)?|\.\d+)$/, ([, key, num]) => {
|
|
228
|
+
const prop = props$1[key ?? ""];
|
|
229
|
+
return prop && num ? { [prop]: rem(num) } : void 0;
|
|
230
|
+
}],
|
|
231
|
+
[/^-(m[xylrtb]?)-(\d+(?:\.\d+)?|\.\d+)$/, ([, key, num]) => {
|
|
232
|
+
const prop = props$1[key ?? ""];
|
|
233
|
+
return prop && num ? { [prop]: `-${rem(num)}` } : void 0;
|
|
234
|
+
}],
|
|
235
|
+
[/^(m[xylrtb]?)-auto$/, ([, key]) => {
|
|
236
|
+
const prop = props$1[key ?? ""];
|
|
237
|
+
return prop ? { [prop]: "auto" } : void 0;
|
|
238
|
+
}]
|
|
239
|
+
];
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/preset/rules/spacing/padding.ts
|
|
242
|
+
const props = {
|
|
243
|
+
p: "padding",
|
|
244
|
+
px: "padding-inline",
|
|
245
|
+
py: "padding-block",
|
|
246
|
+
pl: "padding-left",
|
|
247
|
+
pr: "padding-right",
|
|
248
|
+
pt: "padding-top",
|
|
249
|
+
pb: "padding-bottom"
|
|
250
|
+
};
|
|
251
|
+
const paddingRules = [[/^(p[xylrtb]?)-(\d+(?:\.\d+)?|\.\d+)$/, ([, key, num]) => {
|
|
252
|
+
const prop = props[key ?? ""];
|
|
253
|
+
return prop && num ? { [prop]: rem(num) } : void 0;
|
|
254
|
+
}]];
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/preset/rules/spacing/index.ts
|
|
257
|
+
const spacingRules = [...marginRules, ...paddingRules];
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/preset/rules/typography/font-family.ts
|
|
260
|
+
const FONT_FAMILY = {
|
|
261
|
+
sans: "ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"",
|
|
262
|
+
serif: "ui-serif, Georgia, Cambria, \"Times New Roman\", Times, serif",
|
|
263
|
+
mono: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace"
|
|
264
|
+
};
|
|
265
|
+
const fontFamilyRules = [[/^font-(sans|serif|mono)$/, ([, k]) => ({ "font-family": FONT_FAMILY[k ?? ""] ?? "" })]];
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/preset/rules/typography/font-style.ts
|
|
268
|
+
const VALUES$3 = {
|
|
269
|
+
italic: "italic",
|
|
270
|
+
"not-italic": "normal"
|
|
271
|
+
};
|
|
272
|
+
const fontStyleRules = [[/^(not-italic|italic)$/, ([, k]) => ({ "font-style": VALUES$3[k ?? ""] ?? "" })]];
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/preset/rules/typography/font-variant-numeric.ts
|
|
275
|
+
const VALUES$2 = {
|
|
276
|
+
"normal-nums": "normal",
|
|
277
|
+
ordinal: "ordinal",
|
|
278
|
+
"slashed-zero": "slashed-zero",
|
|
279
|
+
"lining-nums": "lining-nums",
|
|
280
|
+
"oldstyle-nums": "oldstyle-nums",
|
|
281
|
+
"proportional-nums": "proportional-nums",
|
|
282
|
+
"tabular-nums": "tabular-nums",
|
|
283
|
+
"diagonal-fractions": "diagonal-fractions",
|
|
284
|
+
"stacked-fractions": "stacked-fractions"
|
|
285
|
+
};
|
|
286
|
+
const fontVariantNumericRules = [[/^(normal-nums|ordinal|slashed-zero|lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions)$/, ([, k]) => ({ "font-variant-numeric": VALUES$2[k ?? ""] ?? "" })]];
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/preset/rules/typography/font-weight.ts
|
|
289
|
+
const FONT_WEIGHT = {
|
|
290
|
+
thin: "100",
|
|
291
|
+
extralight: "200",
|
|
292
|
+
light: "300",
|
|
293
|
+
normal: "400",
|
|
294
|
+
medium: "500",
|
|
295
|
+
semibold: "600",
|
|
296
|
+
bold: "700",
|
|
297
|
+
extrabold: "800",
|
|
298
|
+
black: "900"
|
|
299
|
+
};
|
|
300
|
+
const fontWeightRules = [[/^font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)$/, ([, k]) => ({ "font-weight": FONT_WEIGHT[k ?? ""] ?? "" })]];
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/preset/rules/typography/line-clamp.ts
|
|
303
|
+
const lineClampRules = [[/^line-clamp-(\d+)$/, ([, n]) => ({
|
|
304
|
+
overflow: "hidden",
|
|
305
|
+
display: "-webkit-box",
|
|
306
|
+
"-webkit-box-orient": "vertical",
|
|
307
|
+
"-webkit-line-clamp": n ?? ""
|
|
308
|
+
})], [/^line-clamp-none$/, () => ({
|
|
309
|
+
overflow: "visible",
|
|
310
|
+
display: "block",
|
|
311
|
+
"-webkit-box-orient": "horizontal",
|
|
312
|
+
"-webkit-line-clamp": "none"
|
|
313
|
+
})]];
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/preset/rules/typography/text-align.ts
|
|
316
|
+
const textAlignRules = [[/^text-(left|center|right|justify)$/, ([, align]) => ({ "text-align": align ?? "" })]];
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/preset/rules/typography/text-decoration-line.ts
|
|
319
|
+
const VALUES$1 = {
|
|
320
|
+
underline: "underline",
|
|
321
|
+
overline: "overline",
|
|
322
|
+
"line-through": "line-through",
|
|
323
|
+
"no-underline": "none"
|
|
324
|
+
};
|
|
325
|
+
const textDecorationLineRules = [[/^(line-through|no-underline|underline|overline)$/, ([, k]) => ({ "text-decoration-line": VALUES$1[k ?? ""] ?? "" })]];
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/preset/rules/typography/text-overflow.ts
|
|
328
|
+
const textOverflowRules = [[/^truncate$/, () => ({
|
|
329
|
+
overflow: "hidden",
|
|
330
|
+
"text-overflow": "ellipsis",
|
|
331
|
+
"white-space": "nowrap"
|
|
332
|
+
})], [/^text-(ellipsis|clip)$/, ([, v]) => ({ "text-overflow": v ?? "" })]];
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/preset/rules/typography/text-transform.ts
|
|
335
|
+
const VALUES = {
|
|
336
|
+
uppercase: "uppercase",
|
|
337
|
+
lowercase: "lowercase",
|
|
338
|
+
capitalize: "capitalize",
|
|
339
|
+
"normal-case": "none"
|
|
340
|
+
};
|
|
341
|
+
const textTransformRules = [[/^(uppercase|lowercase|capitalize|normal-case)$/, ([, k]) => ({ "text-transform": VALUES[k ?? ""] ?? "" })]];
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/preset/rules/typography/text-wrap.ts
|
|
344
|
+
const textWrapRules = [[/^text-(wrap|nowrap|balance|pretty)$/, ([, v]) => ({ "text-wrap": v ?? "" })]];
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/preset/rules/typography/vertical-align.ts
|
|
347
|
+
const verticalAlignRules = [[/^align-(baseline|text-top|text-bottom|top|middle|bottom|sub|super)$/, ([, v]) => ({ "vertical-align": v ?? "" })]];
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/preset/rules/typography/white-space.ts
|
|
350
|
+
const whiteSpaceRules = [[/^whitespace-(normal|nowrap|pre-line|pre-wrap|pre|break-spaces)$/, ([, v]) => ({ "white-space": v ?? "" })]];
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/preset/rules/typography/word-break.ts
|
|
353
|
+
const WORD_BREAK = {
|
|
354
|
+
normal: "normal",
|
|
355
|
+
all: "break-all",
|
|
356
|
+
keep: "keep-all"
|
|
357
|
+
};
|
|
358
|
+
const wordBreakRules = [[/^break-(normal|all|keep)$/, ([, k]) => ({ "word-break": WORD_BREAK[k ?? ""] ?? "" })]];
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/preset/rules/typography/index.ts
|
|
361
|
+
const typographyRules = [
|
|
362
|
+
...fontFamilyRules,
|
|
363
|
+
...fontStyleRules,
|
|
364
|
+
...fontVariantNumericRules,
|
|
365
|
+
...fontWeightRules,
|
|
366
|
+
...lineClampRules,
|
|
367
|
+
...textAlignRules,
|
|
368
|
+
...textDecorationLineRules,
|
|
369
|
+
...textOverflowRules,
|
|
370
|
+
...textTransformRules,
|
|
371
|
+
...textWrapRules,
|
|
372
|
+
...verticalAlignRules,
|
|
373
|
+
...whiteSpaceRules,
|
|
374
|
+
...wordBreakRules
|
|
375
|
+
];
|
|
376
|
+
//#endregion
|
|
377
|
+
export { alignContentRules, alignItemsRules, alignSelfRules, backgroundColorRules, colorRules, displayRules, flexboxGridRules, fontFamilyRules, fontStyleRules, fontVariantNumericRules, fontWeightRules, gapRules, gridTemplateColumnsRules, gridTemplateRowsRules, justifyContentRules, justifyItemsRules, justifySelfRules, layoutRules, lineClampRules, marginRules, objectFitRules, objectPositionRules, orderRules, overflowRules, overscrollRules, paddingRules, positionRules, spacingRules, textAlignRules, textDecorationLineRules, textOverflowRules, textTransformRules, textWrapRules, typographyRules, verticalAlignRules, whiteSpaceRules, wordBreakRules, zIndexRules };
|
|
378
|
+
|
|
379
|
+
//# sourceMappingURL=preset.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.mjs","names":["props","KEYWORDS","KEYWORDS","props","props","props","VALUES","VALUES","VALUES"],"sources":["../src/preset/rules/color/background-color.ts","../src/preset/rules/color/index.ts","../src/preset/rules/flexbox-grid/align-content.ts","../src/preset/rules/flexbox-grid/align-items.ts","../src/preset/rules/flexbox-grid/align-self.ts","../src/preset/rules/flexbox-grid/gap.ts","../src/preset/rules/flexbox-grid/grid-template-columns.ts","../src/preset/rules/flexbox-grid/grid-template-rows.ts","../src/preset/rules/flexbox-grid/justify-content.ts","../src/preset/rules/flexbox-grid/justify-items.ts","../src/preset/rules/flexbox-grid/justify-self.ts","../src/preset/rules/flexbox-grid/order.ts","../src/preset/rules/flexbox-grid/index.ts","../src/preset/rules/layout/display.ts","../src/preset/rules/layout/object-fit.ts","../src/preset/rules/layout/object-position.ts","../src/preset/rules/layout/overflow.ts","../src/preset/rules/layout/overscroll.ts","../src/preset/rules/layout/position.ts","../src/preset/rules/layout/z-index.ts","../src/preset/rules/layout/index.ts","../src/preset/rules/spacing/margin.ts","../src/preset/rules/spacing/padding.ts","../src/preset/rules/spacing/index.ts","../src/preset/rules/typography/font-family.ts","../src/preset/rules/typography/font-style.ts","../src/preset/rules/typography/font-variant-numeric.ts","../src/preset/rules/typography/font-weight.ts","../src/preset/rules/typography/line-clamp.ts","../src/preset/rules/typography/text-align.ts","../src/preset/rules/typography/text-decoration-line.ts","../src/preset/rules/typography/text-overflow.ts","../src/preset/rules/typography/text-transform.ts","../src/preset/rules/typography/text-wrap.ts","../src/preset/rules/typography/vertical-align.ts","../src/preset/rules/typography/white-space.ts","../src/preset/rules/typography/word-break.ts","../src/preset/rules/typography/index.ts"],"sourcesContent":["import type { Rule } from \"../../../types.ts\";\n\n// background-color — https://tailwindcss.com/docs/background-color\nexport const backgroundColorRules: Rule[] = [[/^bg-(\\w+)$/, ([, color]) => ({ backgroundColor: color ?? \"\" })]];\n","import type { Rule } from \"../../../types.ts\";\nimport { backgroundColorRules } from \"./background-color.ts\";\n\n// re-export individual presets for granular use\nexport { backgroundColorRules };\n\n// aggregate — every preset in this category combined.\nexport const colorRules: Rule[] = [...backgroundColorRules];\n","import type { Rule } from \"../../../types.ts\";\n\n// align-content — https://tailwindcss.com/docs/align-content\nconst ALIGN_CONTENT: Record<string, string> = {\n normal: \"normal\",\n center: \"center\",\n start: \"flex-start\",\n end: \"flex-end\",\n between: \"space-between\",\n around: \"space-around\",\n evenly: \"space-evenly\",\n baseline: \"baseline\",\n stretch: \"stretch\",\n};\n\nexport const alignContentRules: Rule[] = [\n [\n /^content-(normal|center|start|end|between|around|evenly|baseline|stretch)$/,\n ([, k]) => ({ \"align-content\": ALIGN_CONTENT[k ?? \"\"] ?? \"\" }),\n ],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// align-items — https://tailwindcss.com/docs/align-items\nconst ALIGN_ITEMS: Record<string, string> = {\n start: \"flex-start\",\n end: \"flex-end\",\n center: \"center\",\n baseline: \"baseline\",\n stretch: \"stretch\",\n};\n\nexport const alignItemsRules: Rule[] = [\n [/^items-(start|end|center|baseline|stretch)$/, ([, k]) => ({ \"align-items\": ALIGN_ITEMS[k ?? \"\"] ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// align-self — https://tailwindcss.com/docs/align-self\nconst ALIGN_SELF: Record<string, string> = {\n auto: \"auto\",\n start: \"flex-start\",\n end: \"flex-end\",\n center: \"center\",\n stretch: \"stretch\",\n baseline: \"baseline\",\n};\n\nexport const alignSelfRules: Rule[] = [\n [/^self-(auto|start|end|center|stretch|baseline)$/, ([, k]) => ({ \"align-self\": ALIGN_SELF[k ?? \"\"] ?? \"\" })],\n];\n","import { rem } from \"../../../helpers.ts\";\nimport type { Rule } from \"../../../types.ts\";\n\n// gap — https://tailwindcss.com/docs/gap\nconst props: Record<string, string> = {\n \"\": \"gap\",\n x: \"column-gap\",\n y: \"row-gap\",\n};\n\nexport const gapRules: Rule[] = [\n [\n /^gap(?:-([xy]))?-(\\d+(?:\\.\\d+)?|\\.\\d+)$/,\n ([, dir, num]) => {\n const prop = props[dir ?? \"\"];\n return prop && num ? { [prop]: rem(num) } : undefined;\n },\n ],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// grid-template-columns — https://tailwindcss.com/docs/grid-template-columns\nconst KEYWORDS: Record<string, string> = {\n none: \"none\",\n subgrid: \"subgrid\",\n};\n\nexport const gridTemplateColumnsRules: Rule[] = [\n [/^grid-cols-(none|subgrid)$/, ([, k]) => ({ \"grid-template-columns\": KEYWORDS[k ?? \"\"] ?? \"\" })],\n [/^grid-cols-(\\d+)$/, ([, n]) => ({ \"grid-template-columns\": `repeat(${n}, minmax(0, 1fr))` })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// grid-template-rows — https://tailwindcss.com/docs/grid-template-rows\nconst KEYWORDS: Record<string, string> = {\n none: \"none\",\n subgrid: \"subgrid\",\n};\n\nexport const gridTemplateRowsRules: Rule[] = [\n [/^grid-rows-(none|subgrid)$/, ([, k]) => ({ \"grid-template-rows\": KEYWORDS[k ?? \"\"] ?? \"\" })],\n [/^grid-rows-(\\d+)$/, ([, n]) => ({ \"grid-template-rows\": `repeat(${n}, minmax(0, 1fr))` })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// justify-content — https://tailwindcss.com/docs/justify-content\nconst JUSTIFY_CONTENT: Record<string, string> = {\n normal: \"normal\",\n start: \"flex-start\",\n end: \"flex-end\",\n center: \"center\",\n between: \"space-between\",\n around: \"space-around\",\n evenly: \"space-evenly\",\n stretch: \"stretch\",\n};\n\nexport const justifyContentRules: Rule[] = [\n [\n /^justify-(normal|start|end|center|between|around|evenly|stretch)$/,\n ([, k]) => ({ \"justify-content\": JUSTIFY_CONTENT[k ?? \"\"] ?? \"\" }),\n ],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// justify-items — https://tailwindcss.com/docs/justify-items\nexport const justifyItemsRules: Rule[] = [\n [/^justify-items-(normal|start|end|center|stretch)$/, ([, v]) => ({ \"justify-items\": v ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// justify-self — https://tailwindcss.com/docs/justify-self\nexport const justifySelfRules: Rule[] = [\n [/^justify-self-(auto|start|end|center|stretch)$/, ([, v]) => ({ \"justify-self\": v ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// order — https://tailwindcss.com/docs/order\nconst KEYWORDS: Record<string, string> = {\n first: \"calc(-infinity)\",\n last: \"calc(infinity)\",\n none: \"0\",\n};\n\nexport const orderRules: Rule[] = [\n [/^order-(first|last|none)$/, ([, k]) => ({ order: KEYWORDS[k ?? \"\"] ?? \"\" })],\n [/^(-?)order-(\\d+)$/, ([, neg, n]) => (n ? { order: `${neg ?? \"\"}${n}` } : undefined)],\n];\n","import type { Rule } from \"../../../types.ts\";\nimport { alignContentRules } from \"./align-content.ts\";\nimport { alignItemsRules } from \"./align-items.ts\";\nimport { alignSelfRules } from \"./align-self.ts\";\nimport { gapRules } from \"./gap.ts\";\nimport { gridTemplateColumnsRules } from \"./grid-template-columns.ts\";\nimport { gridTemplateRowsRules } from \"./grid-template-rows.ts\";\nimport { justifyContentRules } from \"./justify-content.ts\";\nimport { justifyItemsRules } from \"./justify-items.ts\";\nimport { justifySelfRules } from \"./justify-self.ts\";\nimport { orderRules } from \"./order.ts\";\n\n// re-export individual presets for granular use\nexport {\n alignContentRules,\n alignItemsRules,\n alignSelfRules,\n gapRules,\n gridTemplateColumnsRules,\n gridTemplateRowsRules,\n justifyContentRules,\n justifyItemsRules,\n justifySelfRules,\n orderRules,\n};\n\n// aggregate — every preset in this category combined.\nexport const flexboxGridRules: Rule[] = [\n ...alignContentRules,\n ...alignItemsRules,\n ...alignSelfRules,\n ...gapRules,\n ...gridTemplateColumnsRules,\n ...gridTemplateRowsRules,\n ...justifyContentRules,\n ...justifyItemsRules,\n ...justifySelfRules,\n ...orderRules,\n];\n","import type { CSSObject, Rule } from \"../../../types.ts\";\n\n// Display utilities — https://tailwindcss.com/docs/display\n// class name -> CSS `display` value (most are identical; `hidden` maps to `none`).\nconst DISPLAY: Record<string, string> = {\n inline: \"inline\",\n block: \"block\",\n \"inline-block\": \"inline-block\",\n \"flow-root\": \"flow-root\",\n flex: \"flex\",\n \"inline-flex\": \"inline-flex\",\n grid: \"grid\",\n \"inline-grid\": \"inline-grid\",\n contents: \"contents\",\n table: \"table\",\n \"inline-table\": \"inline-table\",\n \"table-caption\": \"table-caption\",\n \"table-cell\": \"table-cell\",\n \"table-column\": \"table-column\",\n \"table-column-group\": \"table-column-group\",\n \"table-footer-group\": \"table-footer-group\",\n \"table-header-group\": \"table-header-group\",\n \"table-row-group\": \"table-row-group\",\n \"table-row\": \"table-row\",\n \"list-item\": \"list-item\",\n hidden: \"none\",\n};\n\n// Screen-reader only — visually hide while keeping content accessible.\nconst srOnly: CSSObject = {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: \"0\",\n margin: \"-1px\",\n overflow: \"hidden\",\n clip: \"rect(0, 0, 0, 0)\",\n \"white-space\": \"nowrap\",\n \"border-width\": \"0\",\n};\n\nconst notSrOnly: CSSObject = {\n position: \"static\",\n width: \"auto\",\n height: \"auto\",\n padding: \"0\",\n margin: \"0\",\n overflow: \"visible\",\n clip: \"auto\",\n \"white-space\": \"normal\",\n};\n\nexport const displayRules: Rule[] = [\n ...Object.entries(DISPLAY).map(([name, value]): Rule => [new RegExp(`^${name}$`), () => ({ display: value })]),\n [/^sr-only$/, () => srOnly],\n [/^not-sr-only$/, () => notSrOnly],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// object-fit — https://tailwindcss.com/docs/object-fit\nexport const objectFitRules: Rule[] = [\n [/^object-(contain|cover|fill|none|scale-down)$/, ([, v]) => ({ \"object-fit\": v ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// object-position — https://tailwindcss.com/docs/object-position\n// class suffix -> CSS `object-position` value (some are two keywords).\nconst POSITIONS: Record<string, string> = {\n bottom: \"bottom\",\n center: \"center\",\n left: \"left\",\n \"left-bottom\": \"left bottom\",\n \"left-top\": \"left top\",\n right: \"right\",\n \"right-bottom\": \"right bottom\",\n \"right-top\": \"right top\",\n top: \"top\",\n};\n\nexport const objectPositionRules: Rule[] = [\n [\n /^object-(left-bottom|left-top|right-bottom|right-top|bottom|center|left|right|top)$/,\n ([, k]) => ({ \"object-position\": POSITIONS[k ?? \"\"] ?? \"\" }),\n ],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// overflow — https://tailwindcss.com/docs/overflow\nconst props: Record<string, string> = {\n \"\": \"overflow\",\n x: \"overflow-x\",\n y: \"overflow-y\",\n};\n\nexport const overflowRules: Rule[] = [\n [\n /^overflow(?:-([xy]))?-(auto|hidden|clip|visible|scroll)$/,\n ([, dir, v]) => {\n const prop = props[dir ?? \"\"];\n return prop && v ? { [prop]: v } : undefined;\n },\n ],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// overscroll-behavior — https://tailwindcss.com/docs/overscroll-behavior\nconst props: Record<string, string> = {\n \"\": \"overscroll-behavior\",\n x: \"overscroll-behavior-x\",\n y: \"overscroll-behavior-y\",\n};\n\nexport const overscrollRules: Rule[] = [\n [\n /^overscroll(?:-([xy]))?-(auto|contain|none)$/,\n ([, dir, v]) => {\n const prop = props[dir ?? \"\"];\n return prop && v ? { [prop]: v } : undefined;\n },\n ],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// position — https://tailwindcss.com/docs/position\nexport const positionRules: Rule[] = [\n [/^(static|fixed|absolute|relative|sticky)$/, ([, v]) => ({ position: v ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// z-index — https://tailwindcss.com/docs/z-index\n// Tailwind ships a 0/10/.../50 scale, but we accept any integer (and negatives) dynamically.\nexport const zIndexRules: Rule[] = [\n [/^z-auto$/, () => ({ \"z-index\": \"auto\" })],\n [/^(-?)z-(\\d+)$/, ([, neg, n]) => (n ? { \"z-index\": `${neg ?? \"\"}${n}` } : undefined)],\n];\n","import type { Rule } from \"../../../types.ts\";\nimport { displayRules } from \"./display.ts\";\nimport { objectFitRules } from \"./object-fit.ts\";\nimport { objectPositionRules } from \"./object-position.ts\";\nimport { overflowRules } from \"./overflow.ts\";\nimport { overscrollRules } from \"./overscroll.ts\";\nimport { positionRules } from \"./position.ts\";\nimport { zIndexRules } from \"./z-index.ts\";\n\n// re-export individual presets for granular use\nexport {\n displayRules,\n objectFitRules,\n objectPositionRules,\n overflowRules,\n overscrollRules,\n positionRules,\n zIndexRules,\n};\n\n// aggregate — every preset in this category combined.\nexport const layoutRules: Rule[] = [\n ...displayRules,\n ...objectFitRules,\n ...objectPositionRules,\n ...overflowRules,\n ...overscrollRules,\n ...positionRules,\n ...zIndexRules,\n];\n","import { rem } from \"../../../helpers.ts\";\nimport type { Rule } from \"../../../types.ts\";\n\n// margin — https://tailwindcss.com/docs/margin\nconst props: Record<string, string> = {\n m: \"margin\",\n mx: \"margin-inline\",\n my: \"margin-block\",\n ml: \"margin-left\",\n mr: \"margin-right\",\n mt: \"margin-top\",\n mb: \"margin-bottom\",\n};\n\n// margin utilities. supports positive (m-1), negative (-m-1), and auto (m-auto).\nexport const marginRules: Rule[] = [\n [\n /^(m[xylrtb]?)-(\\d+(?:\\.\\d+)?|\\.\\d+)$/,\n ([, key, num]) => {\n const prop = props[key ?? \"\"];\n return prop && num ? { [prop]: rem(num) } : undefined;\n },\n ],\n [\n /^-(m[xylrtb]?)-(\\d+(?:\\.\\d+)?|\\.\\d+)$/,\n ([, key, num]) => {\n const prop = props[key ?? \"\"];\n return prop && num ? { [prop]: `-${rem(num)}` } : undefined;\n },\n ],\n [\n /^(m[xylrtb]?)-auto$/,\n ([, key]) => {\n const prop = props[key ?? \"\"];\n return prop ? { [prop]: \"auto\" } : undefined;\n },\n ],\n];\n","import { rem } from \"../../../helpers.ts\";\nimport type { Rule } from \"../../../types.ts\";\n\n// padding — https://tailwindcss.com/docs/padding\nconst props: Record<string, string> = {\n p: \"padding\",\n px: \"padding-inline\",\n py: \"padding-block\",\n pl: \"padding-left\",\n pr: \"padding-right\",\n pt: \"padding-top\",\n pb: \"padding-bottom\",\n};\n\n// padding utilities. positive values only (no auto, no negative — CSS spec).\nexport const paddingRules: Rule[] = [\n [\n /^(p[xylrtb]?)-(\\d+(?:\\.\\d+)?|\\.\\d+)$/,\n ([, key, num]) => {\n const prop = props[key ?? \"\"];\n return prop && num ? { [prop]: rem(num) } : undefined;\n },\n ],\n];\n","import type { Rule } from \"../../../types.ts\";\nimport { marginRules } from \"./margin.ts\";\nimport { paddingRules } from \"./padding.ts\";\n\n// re-export individual presets for granular use\nexport { marginRules, paddingRules };\n\n// aggregate — every preset in this category combined.\nexport const spacingRules: Rule[] = [...marginRules, ...paddingRules];\n","import type { Rule } from \"../../../types.ts\";\n\n// font-family — https://tailwindcss.com/docs/font-family\nconst FONT_FAMILY: Record<string, string> = {\n sans: 'ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"',\n serif: 'ui-serif, Georgia, Cambria, \"Times New Roman\", Times, serif',\n mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace',\n};\n\nexport const fontFamilyRules: Rule[] = [\n [/^font-(sans|serif|mono)$/, ([, k]) => ({ \"font-family\": FONT_FAMILY[k ?? \"\"] ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// font-style — https://tailwindcss.com/docs/font-style\nconst VALUES: Record<string, string> = {\n italic: \"italic\",\n \"not-italic\": \"normal\",\n};\n\nexport const fontStyleRules: Rule[] = [[/^(not-italic|italic)$/, ([, k]) => ({ \"font-style\": VALUES[k ?? \"\"] ?? \"\" })]];\n","import type { Rule } from \"../../../types.ts\";\n\n// font-variant-numeric — https://tailwindcss.com/docs/font-variant-numeric\n// Tailwind composes these via CSS vars so they can stack (e.g. `ordinal tabular-nums`);\n// here each maps directly to a single value.\nconst VALUES: Record<string, string> = {\n \"normal-nums\": \"normal\",\n ordinal: \"ordinal\",\n \"slashed-zero\": \"slashed-zero\",\n \"lining-nums\": \"lining-nums\",\n \"oldstyle-nums\": \"oldstyle-nums\",\n \"proportional-nums\": \"proportional-nums\",\n \"tabular-nums\": \"tabular-nums\",\n \"diagonal-fractions\": \"diagonal-fractions\",\n \"stacked-fractions\": \"stacked-fractions\",\n};\n\nexport const fontVariantNumericRules: Rule[] = [\n [\n /^(normal-nums|ordinal|slashed-zero|lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions)$/,\n ([, k]) => ({ \"font-variant-numeric\": VALUES[k ?? \"\"] ?? \"\" }),\n ],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// font-weight — https://tailwindcss.com/docs/font-weight\nconst FONT_WEIGHT: Record<string, string> = {\n thin: \"100\",\n extralight: \"200\",\n light: \"300\",\n normal: \"400\",\n medium: \"500\",\n semibold: \"600\",\n bold: \"700\",\n extrabold: \"800\",\n black: \"900\",\n};\n\nexport const fontWeightRules: Rule[] = [\n [\n /^font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)$/,\n ([, k]) => ({ \"font-weight\": FONT_WEIGHT[k ?? \"\"] ?? \"\" }),\n ],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// line-clamp — https://tailwindcss.com/docs/line-clamp\nexport const lineClampRules: Rule[] = [\n [\n /^line-clamp-(\\d+)$/,\n ([, n]) => ({\n overflow: \"hidden\",\n display: \"-webkit-box\",\n \"-webkit-box-orient\": \"vertical\",\n \"-webkit-line-clamp\": n ?? \"\",\n }),\n ],\n [\n /^line-clamp-none$/,\n () => ({\n overflow: \"visible\",\n display: \"block\",\n \"-webkit-box-orient\": \"horizontal\",\n \"-webkit-line-clamp\": \"none\",\n }),\n ],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// text-align — https://tailwindcss.com/docs/text-align\nexport const textAlignRules: Rule[] = [\n [/^text-(left|center|right|justify)$/, ([, align]) => ({ \"text-align\": align ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// text-decoration-line — https://tailwindcss.com/docs/text-decoration-line\nconst VALUES: Record<string, string> = {\n underline: \"underline\",\n overline: \"overline\",\n \"line-through\": \"line-through\",\n \"no-underline\": \"none\",\n};\n\nexport const textDecorationLineRules: Rule[] = [\n [/^(line-through|no-underline|underline|overline)$/, ([, k]) => ({ \"text-decoration-line\": VALUES[k ?? \"\"] ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// text-overflow — https://tailwindcss.com/docs/text-overflow\nexport const textOverflowRules: Rule[] = [\n [/^truncate$/, () => ({ overflow: \"hidden\", \"text-overflow\": \"ellipsis\", \"white-space\": \"nowrap\" })],\n [/^text-(ellipsis|clip)$/, ([, v]) => ({ \"text-overflow\": v ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// text-transform — https://tailwindcss.com/docs/text-transform\nconst VALUES: Record<string, string> = {\n uppercase: \"uppercase\",\n lowercase: \"lowercase\",\n capitalize: \"capitalize\",\n \"normal-case\": \"none\",\n};\n\nexport const textTransformRules: Rule[] = [\n [/^(uppercase|lowercase|capitalize|normal-case)$/, ([, k]) => ({ \"text-transform\": VALUES[k ?? \"\"] ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// text-wrap — https://tailwindcss.com/docs/text-wrap\nexport const textWrapRules: Rule[] = [[/^text-(wrap|nowrap|balance|pretty)$/, ([, v]) => ({ \"text-wrap\": v ?? \"\" })]];\n","import type { Rule } from \"../../../types.ts\";\n\n// vertical-align — https://tailwindcss.com/docs/vertical-align\nexport const verticalAlignRules: Rule[] = [\n [/^align-(baseline|text-top|text-bottom|top|middle|bottom|sub|super)$/, ([, v]) => ({ \"vertical-align\": v ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// white-space — https://tailwindcss.com/docs/whitespace\nexport const whiteSpaceRules: Rule[] = [\n [/^whitespace-(normal|nowrap|pre-line|pre-wrap|pre|break-spaces)$/, ([, v]) => ({ \"white-space\": v ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\n\n// word-break — https://tailwindcss.com/docs/word-break\nconst WORD_BREAK: Record<string, string> = {\n normal: \"normal\",\n all: \"break-all\",\n keep: \"keep-all\",\n};\n\nexport const wordBreakRules: Rule[] = [\n [/^break-(normal|all|keep)$/, ([, k]) => ({ \"word-break\": WORD_BREAK[k ?? \"\"] ?? \"\" })],\n];\n","import type { Rule } from \"../../../types.ts\";\nimport { fontFamilyRules } from \"./font-family.ts\";\nimport { fontStyleRules } from \"./font-style.ts\";\nimport { fontVariantNumericRules } from \"./font-variant-numeric.ts\";\nimport { fontWeightRules } from \"./font-weight.ts\";\nimport { lineClampRules } from \"./line-clamp.ts\";\nimport { textAlignRules } from \"./text-align.ts\";\nimport { textDecorationLineRules } from \"./text-decoration-line.ts\";\nimport { textOverflowRules } from \"./text-overflow.ts\";\nimport { textTransformRules } from \"./text-transform.ts\";\nimport { textWrapRules } from \"./text-wrap.ts\";\nimport { verticalAlignRules } from \"./vertical-align.ts\";\nimport { whiteSpaceRules } from \"./white-space.ts\";\nimport { wordBreakRules } from \"./word-break.ts\";\n\n// re-export individual presets for granular use\nexport {\n fontFamilyRules,\n fontStyleRules,\n fontVariantNumericRules,\n fontWeightRules,\n lineClampRules,\n textAlignRules,\n textDecorationLineRules,\n textOverflowRules,\n textTransformRules,\n textWrapRules,\n verticalAlignRules,\n whiteSpaceRules,\n wordBreakRules,\n};\n\n// aggregate — every preset in this category combined.\nexport const typographyRules: Rule[] = [\n ...fontFamilyRules,\n ...fontStyleRules,\n ...fontVariantNumericRules,\n ...fontWeightRules,\n ...lineClampRules,\n ...textAlignRules,\n ...textDecorationLineRules,\n ...textOverflowRules,\n ...textTransformRules,\n ...textWrapRules,\n ...verticalAlignRules,\n ...whiteSpaceRules,\n ...wordBreakRules,\n];\n"],"mappings":";;AAGA,MAAa,uBAA+B,CAAC,CAAC,eAAe,GAAG,YAAY,EAAE,iBAAiB,SAAS,GAAG,EAAE,CAAC;;;ACI9G,MAAa,aAAqB,CAAC,GAAG,oBAAoB;;;ACJ1D,MAAM,gBAAwC;CAC5C,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,KAAK;CACL,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,SAAS;AACX;AAEA,MAAa,oBAA4B,CACvC,CACE,+EACC,GAAG,QAAQ,EAAE,iBAAiB,cAAc,KAAK,OAAO,GAAG,EAC9D,CACF;;;ACjBA,MAAM,cAAsC;CAC1C,OA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jB;AAEA,MAAa,qBAA6B,CACxC,CAAC,mDAAmD,GAAG,QAAQ,EAAE,kBAAkB,OAAO,KAAK,OAAO,GAAG,EAAE,CAC7G;;;ACTA,MAAa,gBAAwB,CAAC,CAAC,wCAAwC,GAAG,QAAQ,EAAE,aAAa,KAAK,GAAG,EAAE,CAAC;;;ACApH,MAAa,qBAA6B,CACxC,CAAC,wEAAwE,GAAG,QAAQ,EAAE,kBAAkB,KAAK,GAAG,EAAE,CACpH;;;ACFA,MAAa,kBAA0B,CACrC,CAAC,oEAAoE,GAAG,QAAQ,EAAE,eAAe,KAAK,GAAG,EAAE,CAC7G;;;ACFA,MAAM,aAAqC;CACzC,QAAQ;CACR,KAAK;CACL,MAAM;AACR;AAEA,MAAa,iBAAyB,CACpC,CAAC,8BAA8B,GAAG,QAAQ,EAAE,cAAc,WAAW,KAAK,OAAO,GAAG,EAAE,CACxF;;;ACsBA,MAAa,kBAA0B;CACrC,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A flat map of CSS property → value, e.g. `{ margin: "1rem", "background-color": "red" }`.
|
|
4
|
+
*
|
|
5
|
+
* Both camelCase (`backgroundColor`) and kebab-case (`"background-color"`) are accepted —
|
|
6
|
+
* camelCase keys are normalized at stringify time. Values are emitted verbatim, including
|
|
7
|
+
* units; no automatic `px` coercion is performed.
|
|
8
|
+
*/
|
|
9
|
+
type CSSObject = Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Context passed to each rule handler so the handler can inspect the original token,
|
|
12
|
+
* the post-variant residue, and the variant chain that produced it.
|
|
13
|
+
*/
|
|
14
|
+
interface RuleContext {
|
|
15
|
+
/** Original token as it appeared in source (e.g. `"md:hover:m-1"`). */
|
|
16
|
+
rawSelector: string;
|
|
17
|
+
/** Token after the variant chain has stripped its prefixes (e.g. `"m-1"`). */
|
|
18
|
+
currentSelector: string;
|
|
19
|
+
/** Variants applied to the token, in order from outermost to innermost. */
|
|
20
|
+
variants: VariantHandlerResult[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Rule handler signature.
|
|
24
|
+
*
|
|
25
|
+
* Returning `undefined` skips this rule and lets the next matching one try, which is
|
|
26
|
+
* useful for guards (e.g. only handle when a captured value is numerically valid).
|
|
27
|
+
*/
|
|
28
|
+
type RuleHandler = (match: RegExpMatchArray, ctx: RuleContext) => CSSObject | undefined;
|
|
29
|
+
/** A single rule: a regex and a handler that produces a {@link CSSObject}. */
|
|
30
|
+
type Rule = [RegExp, RuleHandler];
|
|
31
|
+
/**
|
|
32
|
+
* Result of a variant matcher. The generator collects these in order during the variant
|
|
33
|
+
* chain phase and uses them to wrap the final selector / at-rule output.
|
|
34
|
+
*/
|
|
35
|
+
interface VariantHandlerResult {
|
|
36
|
+
/** Token with this variant's prefix stripped — passed to the next variant or to rules. */
|
|
37
|
+
matcher: string;
|
|
38
|
+
/** Optional selector wrapper, e.g. `(s) => `${s}:hover`` or `(s) => `.group:hover ${s}``. */
|
|
39
|
+
selector?: (sel: string) => string;
|
|
40
|
+
/** Optional at-rule that wraps the produced rule, e.g. `"@media (--md)"`. */
|
|
41
|
+
parent?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Variant handler signature. Return `undefined` to leave the token unchanged. */
|
|
44
|
+
type VariantHandler = (match: RegExpMatchArray, raw: string) => VariantHandlerResult | undefined;
|
|
45
|
+
/** A single variant: a regex and a handler that yields a {@link VariantHandlerResult}. */
|
|
46
|
+
type Variant = [RegExp, VariantHandler];
|
|
47
|
+
/** Glob patterns describing which source files to scan for utility class tokens. */
|
|
48
|
+
interface ContentConfig {
|
|
49
|
+
/** Files / directories to scan. Relative paths and root-external paths are both supported. */
|
|
50
|
+
include: string[];
|
|
51
|
+
/** Files / directories to skip even if matched by `include`. */
|
|
52
|
+
exclude?: string[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Library configuration. Pass this to {@link createGenerator} (or `defineConfig`) to drive
|
|
56
|
+
* the generator. All fields except `rules` are optional.
|
|
57
|
+
*/
|
|
58
|
+
interface UserConfig {
|
|
59
|
+
/**
|
|
60
|
+
* User-defined utility rules. Each rule is a `[RegExp, handler]` tuple where the handler
|
|
61
|
+
* receives the regex match array and returns a CSSObject, or `undefined` to defer to the
|
|
62
|
+
* next matching rule.
|
|
63
|
+
*/
|
|
64
|
+
rules: Rule[];
|
|
65
|
+
/**
|
|
66
|
+
* Variant matchers applied to tokens before rule matching. Variants are recursively
|
|
67
|
+
* applied head-to-tail until none match; each variant strips its own prefix and may wrap
|
|
68
|
+
* the resulting selector and/or at-rule.
|
|
69
|
+
*/
|
|
70
|
+
variants?: Variant[];
|
|
71
|
+
/**
|
|
72
|
+
* Wraps the generated declarations in `@layer <layerName> { ... }`. Use this to control
|
|
73
|
+
* cascade order against other CSS in the project. Omit to skip the layer wrap.
|
|
74
|
+
*/
|
|
75
|
+
layerName?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Required namespace prefix for generated classes (e.g. `"tw-"`). When set, tokens not
|
|
78
|
+
* starting with this prefix are silently skipped (strict mode). The prefix is outermost
|
|
79
|
+
* and variants live inside it — `tw-md:hover:m-4`.
|
|
80
|
+
*/
|
|
81
|
+
prefix?: string;
|
|
82
|
+
/**
|
|
83
|
+
* `@custom-media` declarations emitted at the top of generated CSS. Each entry becomes
|
|
84
|
+
* `@custom-media --<name> <query>;`. Requires LightningCSS's `drafts.customMedia: true`
|
|
85
|
+
* flag in `vite.config.ts` to be resolved by the bundler.
|
|
86
|
+
*/
|
|
87
|
+
customMedia?: Record<string, string>;
|
|
88
|
+
/** Source files to scan for utility tokens. */
|
|
89
|
+
content?: ContentConfig;
|
|
90
|
+
/**
|
|
91
|
+
* Custom token extractor. The default matches `[\w:.\-/]+` from the full source text.
|
|
92
|
+
* Override to target specific syntax (e.g. `class="..."` attributes only).
|
|
93
|
+
*/
|
|
94
|
+
extractor?: (code: string) => Iterable<string>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* `UserConfig` with all defaults applied. Returned via `Generator.config`. Useful for
|
|
98
|
+
* introspecting effective settings from plugins or tooling.
|
|
99
|
+
*/
|
|
100
|
+
interface ResolvedConfig {
|
|
101
|
+
rules: Rule[];
|
|
102
|
+
variants: Variant[];
|
|
103
|
+
layerName: string | undefined;
|
|
104
|
+
prefix: string;
|
|
105
|
+
customMedia: Record<string, string>;
|
|
106
|
+
content: ContentConfig;
|
|
107
|
+
extractor: (code: string) => Iterable<string>;
|
|
108
|
+
}
|
|
109
|
+
/** Output of a single `Generator.generate` call. */
|
|
110
|
+
interface GenerateResult {
|
|
111
|
+
/** The fully-rendered CSS string. May include `@custom-media`, `@layer`, etc. */
|
|
112
|
+
css: string;
|
|
113
|
+
/** Set of tokens that successfully matched a rule. Useful for debugging / coverage. */
|
|
114
|
+
matched: Set<string>;
|
|
115
|
+
}
|
|
116
|
+
/** Per-call options for {@link Generator.generate}. */
|
|
117
|
+
interface GenerateOptions {
|
|
118
|
+
/**
|
|
119
|
+
* Override `config.layerName` for this call only. Pass `""` to disable layer wrapping
|
|
120
|
+
* entirely for this call. Useful when the Vite plugin needs different layers for
|
|
121
|
+
* different `@import "regexcss" layer(<name>);` sites in the same source.
|
|
122
|
+
*/
|
|
123
|
+
layerName?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Stateful generator built from a {@link UserConfig}. Call `generate(tokens)` to produce
|
|
127
|
+
* CSS; the same generator can be reused across many calls.
|
|
128
|
+
*/
|
|
129
|
+
interface Generator {
|
|
130
|
+
/** Generate CSS for the given iterable of utility tokens. */
|
|
131
|
+
generate(tokens: Iterable<string>, options?: GenerateOptions): Promise<GenerateResult>;
|
|
132
|
+
/** Effective config with defaults applied. */
|
|
133
|
+
readonly config: ResolvedConfig;
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
export { Generator as a, RuleContext as c, Variant as d, VariantHandler as f, GenerateResult as i, RuleHandler as l, ContentConfig as n, ResolvedConfig as o, VariantHandlerResult as p, GenerateOptions as r, Rule as s, CSSObject as t, UserConfig as u };
|
|
137
|
+
//# sourceMappingURL=types-jVjPo8bk.d.mts.map
|
package/dist/vite.d.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { u as UserConfig } from "./types-jVjPo8bk.mjs";
|
|
2
|
+
import { Plugin } from "vite";
|
|
3
|
+
|
|
4
|
+
//#region src/plugin/vite.d.ts
|
|
5
|
+
interface PluginOptions {
|
|
6
|
+
config?: UserConfig;
|
|
7
|
+
}
|
|
8
|
+
declare function regexcss(options?: PluginOptions): Plugin;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type PluginOptions, regexcss as default };
|
|
11
|
+
//# sourceMappingURL=vite.d.mts.map
|