@unocss/preset-mini 66.6.6 → 66.6.7

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.
@@ -1,1701 +0,0 @@
1
- import { C as globalKeywords, S as directionMap, T as positionMap, a as colorableShadows, c as isCSSMathFn, d as parseColor, f as resolveBreakpoints, g as h, h as transformXYZ, i as colorResolver, l as isSize, m as splitShorthand, o as directionSize, s as hasParseableColor, u as makeGlobalStaticRules, w as insetMap, y as cornerMap } from "./utils-BiEVyyOJ.mjs";
2
- import { toArray } from "@unocss/core";
3
- import { colorOpacityToString, colorToString } from "@unocss/rule-utils";
4
-
5
- //#region src/_rules/align.ts
6
- const verticalAlignAlias = {
7
- "mid": "middle",
8
- "base": "baseline",
9
- "btm": "bottom",
10
- "baseline": "baseline",
11
- "top": "top",
12
- "start": "top",
13
- "middle": "middle",
14
- "bottom": "bottom",
15
- "end": "bottom",
16
- "text-top": "text-top",
17
- "text-bottom": "text-bottom",
18
- "sub": "sub",
19
- "super": "super",
20
- ...Object.fromEntries(globalKeywords.map((x) => [x, x]))
21
- };
22
- const verticalAligns = [[
23
- /^(?:vertical|align|v)-(.+)$/,
24
- ([, v]) => ({ "vertical-align": verticalAlignAlias[v] ?? h.bracket.cssvar.numberWithUnit(v) }),
25
- { autocomplete: [`(vertical|align|v)-(${Object.keys(verticalAlignAlias).join("|")})`, "(vertical|align|v)-<percentage>"] }
26
- ]];
27
- const textAlignValues = [
28
- "center",
29
- "left",
30
- "right",
31
- "justify",
32
- "start",
33
- "end"
34
- ];
35
- const textAligns = [...textAlignValues.map((v) => [`text-${v}`, { "text-align": v }]), ...[...globalKeywords, ...textAlignValues].map((v) => [`text-align-${v}`, { "text-align": v }])];
36
-
37
- //#endregion
38
- //#region src/_rules/behaviors.ts
39
- const outline = [
40
- [
41
- /^outline-(?:width-|size-)?(.+)$/,
42
- handleWidth$3,
43
- { autocomplete: "outline-(width|size)-<num>" }
44
- ],
45
- [
46
- /^outline-(?:color-)?(.+)$/,
47
- handleColorOrWidth$3,
48
- { autocomplete: "outline-$colors" }
49
- ],
50
- [
51
- /^outline-offset-(.+)$/,
52
- ([, d], { theme }) => ({ "outline-offset": theme.lineWidth?.[d] ?? h.bracket.cssvar.global.px(d) }),
53
- { autocomplete: "outline-(offset)-<num>" }
54
- ],
55
- ["outline", { "outline-style": "solid" }],
56
- ...[
57
- "auto",
58
- "dashed",
59
- "dotted",
60
- "double",
61
- "hidden",
62
- "solid",
63
- "groove",
64
- "ridge",
65
- "inset",
66
- "outset",
67
- ...globalKeywords
68
- ].map((v) => [`outline-${v}`, { "outline-style": v }]),
69
- ["outline-none", {
70
- "outline": "2px solid transparent",
71
- "outline-offset": "2px"
72
- }]
73
- ];
74
- function handleWidth$3([, b], { theme }) {
75
- return { "outline-width": theme.lineWidth?.[b] ?? h.bracket.cssvar.global.px(b) };
76
- }
77
- function handleColorOrWidth$3(match, ctx) {
78
- if (isCSSMathFn(h.bracket(match[1]))) return handleWidth$3(match, ctx);
79
- return colorResolver("outline-color", "outline-color", "borderColor")(match, ctx);
80
- }
81
- const appearance = [["appearance-auto", {
82
- "-webkit-appearance": "auto",
83
- "appearance": "auto"
84
- }], ["appearance-none", {
85
- "-webkit-appearance": "none",
86
- "appearance": "none"
87
- }]];
88
- function willChangeProperty(prop) {
89
- return h.properties.auto.global(prop) ?? {
90
- contents: "contents",
91
- scroll: "scroll-position"
92
- }[prop];
93
- }
94
- const willChange = [[/^will-change-(.+)/, ([, p]) => ({ "will-change": willChangeProperty(p) })]];
95
-
96
- //#endregion
97
- //#region src/_rules/border.ts
98
- const borderStyles = [
99
- "solid",
100
- "dashed",
101
- "dotted",
102
- "double",
103
- "hidden",
104
- "none",
105
- "groove",
106
- "ridge",
107
- "inset",
108
- "outset",
109
- ...globalKeywords
110
- ];
111
- const borders = [
112
- [
113
- /^(?:border|b)()(?:-(.+))?$/,
114
- handlerBorderSize,
115
- { autocomplete: "(border|b)-<directions>" }
116
- ],
117
- [/^(?:border|b)-([xy])(?:-(.+))?$/, handlerBorderSize],
118
- [/^(?:border|b)-([rltbse])(?:-(.+))?$/, handlerBorderSize],
119
- [/^(?:border|b)-(block|inline)(?:-(.+))?$/, handlerBorderSize],
120
- [/^(?:border|b)-([bi][se])(?:-(.+))?$/, handlerBorderSize],
121
- [
122
- /^(?:border|b)-()(?:width|size)-(.+)$/,
123
- handlerBorderSize,
124
- { autocomplete: ["(border|b)-<num>", "(border|b)-<directions>-<num>"] }
125
- ],
126
- [/^(?:border|b)-([xy])-(?:width|size)-(.+)$/, handlerBorderSize],
127
- [/^(?:border|b)-([rltbse])-(?:width|size)-(.+)$/, handlerBorderSize],
128
- [/^(?:border|b)-(block|inline)-(?:width|size)-(.+)$/, handlerBorderSize],
129
- [/^(?:border|b)-([bi][se])-(?:width|size)-(.+)$/, handlerBorderSize],
130
- [
131
- /^(?:border|b)-()(?:color-)?(.+)$/,
132
- handlerBorderColorOrSize,
133
- { autocomplete: ["(border|b)-$colors", "(border|b)-<directions>-$colors"] }
134
- ],
135
- [/^(?:border|b)-([xy])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
136
- [/^(?:border|b)-([rltbse])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
137
- [/^(?:border|b)-(block|inline)-(?:color-)?(.+)$/, handlerBorderColorOrSize],
138
- [/^(?:border|b)-([bi][se])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
139
- [
140
- /^(?:border|b)-()op(?:acity)?-?(.+)$/,
141
- handlerBorderOpacity,
142
- { autocomplete: "(border|b)-(op|opacity)-<percent>" }
143
- ],
144
- [/^(?:border|b)-([xy])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
145
- [/^(?:border|b)-([rltbse])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
146
- [/^(?:border|b)-(block|inline)-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
147
- [/^(?:border|b)-([bi][se])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
148
- [
149
- /^(?:border-|b-)?(?:rounded|rd)()(?:-(.+))?$/,
150
- handlerRounded,
151
- { autocomplete: [
152
- "(border|b)-(rounded|rd)",
153
- "(border|b)-(rounded|rd)-$borderRadius",
154
- "(rounded|rd)",
155
- "(rounded|rd)-$borderRadius"
156
- ] }
157
- ],
158
- [/^(?:border-|b-)?(?:rounded|rd)-([rltbse])(?:-(.+))?$/, handlerRounded],
159
- [/^(?:border-|b-)?(?:rounded|rd)-([rltb]{2})(?:-(.+))?$/, handlerRounded],
160
- [/^(?:border-|b-)?(?:rounded|rd)-([bise][se])(?:-(.+))?$/, handlerRounded],
161
- [/^(?:border-|b-)?(?:rounded|rd)-([bi][se]-[bi][se])(?:-(.+))?$/, handlerRounded],
162
- [
163
- /^(?:border|b)-(?:style-)?()(.+)$/,
164
- handlerBorderStyle,
165
- { autocomplete: [
166
- "(border|b)-style",
167
- `(border|b)-(${borderStyles.join("|")})`,
168
- "(border|b)-<directions>-style",
169
- `(border|b)-<directions>-(${borderStyles.join("|")})`,
170
- `(border|b)-<directions>-style-(${borderStyles.join("|")})`,
171
- `(border|b)-style-(${borderStyles.join("|")})`
172
- ] }
173
- ],
174
- [/^(?:border|b)-([xy])-(?:style-)?(.+)$/, handlerBorderStyle],
175
- [/^(?:border|b)-([rltbse])-(?:style-)?(.+)$/, handlerBorderStyle],
176
- [/^(?:border|b)-(block|inline)-(?:style-)?(.+)$/, handlerBorderStyle],
177
- [/^(?:border|b)-([bi][se])-(?:style-)?(.+)$/, handlerBorderStyle]
178
- ];
179
- function transformBorderColor(color, alpha, direction) {
180
- if (alpha != null) return { [`border${direction}-color`]: colorToString(color, alpha) };
181
- if (direction === "") {
182
- const object = {};
183
- const opacityVar = `--un-border-opacity`;
184
- const result = colorToString(color, `var(${opacityVar})`);
185
- if (result.includes(opacityVar)) object[opacityVar] = typeof color === "string" ? 1 : colorOpacityToString(color);
186
- object["border-color"] = result;
187
- return object;
188
- } else {
189
- const object = {};
190
- const opacityVar = "--un-border-opacity";
191
- const opacityDirectionVar = `--un-border${direction}-opacity`;
192
- const result = colorToString(color, `var(${opacityDirectionVar})`);
193
- if (result.includes(opacityDirectionVar)) {
194
- object[opacityVar] = typeof color === "string" ? 1 : colorOpacityToString(color);
195
- object[opacityDirectionVar] = `var(${opacityVar})`;
196
- }
197
- object[`border${direction}-color`] = result;
198
- return object;
199
- }
200
- }
201
- function borderColorResolver(direction) {
202
- return ([, body], theme) => {
203
- const data = parseColor(body, theme, "borderColor");
204
- if (!data) return;
205
- const { alpha, color, cssColor } = data;
206
- if (cssColor) return transformBorderColor(cssColor, alpha, direction);
207
- else if (color) return transformBorderColor(color, alpha, direction);
208
- };
209
- }
210
- function handlerBorderSize([, a = "", b], { theme }) {
211
- const v = theme.lineWidth?.[b || "DEFAULT"] ?? h.bracket.cssvar.global.px(b || "1");
212
- if (a in directionMap && v != null) return directionMap[a].map((i) => [`border${i}-width`, v]);
213
- }
214
- function handlerBorderColorOrSize([, a = "", b], ctx) {
215
- if (a in directionMap) {
216
- if (isCSSMathFn(h.bracket(b))) return handlerBorderSize([
217
- "",
218
- a,
219
- b
220
- ], ctx);
221
- if (hasParseableColor(b, ctx.theme, "borderColor")) return Object.assign({}, ...directionMap[a].map((i) => borderColorResolver(i)(["", b], ctx.theme)));
222
- }
223
- }
224
- function handlerBorderOpacity([, a = "", opacity$1]) {
225
- const v = h.bracket.percent.cssvar(opacity$1);
226
- if (a in directionMap && v != null) return directionMap[a].map((i) => [`--un-border${i}-opacity`, v]);
227
- }
228
- function handlerRounded([, a = "", s], { theme }) {
229
- const v = theme.borderRadius?.[s || "DEFAULT"] || h.bracket.cssvar.global.fraction.rem(s || "1");
230
- if (a in cornerMap && v != null) return cornerMap[a].map((i) => [`border${i}-radius`, v]);
231
- }
232
- function handlerBorderStyle([, a = "", s]) {
233
- if (borderStyles.includes(s) && a in directionMap) return directionMap[a].map((i) => [`border${i}-style`, s]);
234
- }
235
-
236
- //#endregion
237
- //#region src/_rules/color.ts
238
- /**
239
- * @example op10 op-30 opacity-100
240
- */
241
- const opacity = [[/^op(?:acity)?-?(.+)$/, ([, d]) => ({ opacity: h.bracket.percent.cssvar(d) })]];
242
- const bgUrlRE = /^\[url\(.+\)\]$/;
243
- const bgLengthRE = /^\[(?:length|size):.+\]$/;
244
- const bgPositionRE = /^\[position:.+\]$/;
245
- const bgGradientRE = /^\[(?:linear|conic|radial)-gradient\(.+\)\]$/;
246
- const bgImageRE = /^\[image:.+\]$/;
247
- const bgColors = [[
248
- /^bg-(.+)$/,
249
- (...args) => {
250
- const d = args[0][1];
251
- if (bgUrlRE.test(d)) return {
252
- "--un-url": h.bracket(d),
253
- "background-image": "var(--un-url)"
254
- };
255
- if (bgLengthRE.test(d) && h.bracketOfLength(d) != null) return { "background-size": h.bracketOfLength(d).split(" ").map((e) => h.fraction.auto.px.cssvar(e) ?? e).join(" ") };
256
- if ((isSize(d) || bgPositionRE.test(d)) && h.bracketOfPosition(d) != null) return { "background-position": h.bracketOfPosition(d).split(" ").map((e) => h.position.fraction.auto.px.cssvar(e) ?? e).join(" ") };
257
- if (bgGradientRE.test(d) || bgImageRE.test(d)) {
258
- const s = h.bracket(d);
259
- if (s) {
260
- const url = s.startsWith("http") ? `url(${s})` : h.cssvar(s);
261
- return { "background-image": url ?? s };
262
- }
263
- }
264
- return colorResolver("background-color", "bg", "backgroundColor")(...args);
265
- },
266
- { autocomplete: "bg-$colors" }
267
- ], [
268
- /^bg-op(?:acity)?-?(.+)$/,
269
- ([, opacity$1]) => ({ "--un-bg-opacity": h.bracket.percent.cssvar(opacity$1) }),
270
- { autocomplete: "bg-(op|opacity)-<percent>" }
271
- ]];
272
- const colorScheme = [[/^color-scheme-(\w+)$/, ([, v]) => ({ "color-scheme": v })]];
273
-
274
- //#endregion
275
- //#region src/_rules/container.ts
276
- const containerParent = [[/^@container(?:\/(\w+))?(?:-(normal|inline-size|size))?$/, ([, l, v]) => {
277
- return {
278
- "container-type": v ?? "inline-size",
279
- "container-name": l
280
- };
281
- }]];
282
-
283
- //#endregion
284
- //#region src/_rules/decoration.ts
285
- const decorationStyles = [
286
- "solid",
287
- "double",
288
- "dotted",
289
- "dashed",
290
- "wavy",
291
- ...globalKeywords
292
- ];
293
- const textDecorations = [
294
- [
295
- /^(?:decoration-)?(underline|overline|line-through)$/,
296
- ([, s]) => ({ "text-decoration-line": s }),
297
- { autocomplete: "decoration-(underline|overline|line-through)" }
298
- ],
299
- [
300
- /^(?:underline|decoration)-(?:size-)?(.+)$/,
301
- handleWidth$2,
302
- { autocomplete: "(underline|decoration)-<num>" }
303
- ],
304
- [
305
- /^(?:underline|decoration)-(auto|from-font)$/,
306
- ([, s]) => ({ "text-decoration-thickness": s }),
307
- { autocomplete: "(underline|decoration)-(auto|from-font)" }
308
- ],
309
- [
310
- /^(?:underline|decoration)-(.+)$/,
311
- handleColorOrWidth$2,
312
- { autocomplete: "(underline|decoration)-$colors" }
313
- ],
314
- [
315
- /^(?:underline|decoration)-op(?:acity)?-?(.+)$/,
316
- ([, opacity$1]) => ({ "--un-line-opacity": h.bracket.percent.cssvar(opacity$1) }),
317
- { autocomplete: "(underline|decoration)-(op|opacity)-<percent>" }
318
- ],
319
- [
320
- /^(?:underline|decoration)-offset-(.+)$/,
321
- ([, s], { theme }) => ({ "text-underline-offset": theme.lineWidth?.[s] ?? h.auto.bracket.cssvar.global.px(s) }),
322
- { autocomplete: "(underline|decoration)-(offset)-<num>" }
323
- ],
324
- ...decorationStyles.map((v) => [`underline-${v}`, { "text-decoration-style": v }]),
325
- ...decorationStyles.map((v) => [`decoration-${v}`, { "text-decoration-style": v }]),
326
- ["no-underline", { "text-decoration": "none" }],
327
- ["decoration-none", { "text-decoration": "none" }]
328
- ];
329
- function handleWidth$2([, b], { theme }) {
330
- return { "text-decoration-thickness": theme.lineWidth?.[b] ?? h.bracket.cssvar.global.px(b) };
331
- }
332
- function handleColorOrWidth$2(match, ctx) {
333
- if (isCSSMathFn(h.bracket(match[1]))) return handleWidth$2(match, ctx);
334
- const result = colorResolver("text-decoration-color", "line", "borderColor")(match, ctx);
335
- if (result) return {
336
- "-webkit-text-decoration-color": result["text-decoration-color"],
337
- ...result
338
- };
339
- }
340
-
341
- //#endregion
342
- //#region src/_rules/flex.ts
343
- const flex = [
344
- ["flex", { display: "flex" }],
345
- ["inline-flex", { display: "inline-flex" }],
346
- ["flex-inline", { display: "inline-flex" }],
347
- [/^flex-(.*)$/, ([, d]) => ({ flex: h.bracket(d) != null ? h.bracket(d).split(" ").map((e) => h.cssvar.fraction(e) ?? e).join(" ") : h.cssvar.fraction(d) })],
348
- ["flex-1", { flex: "1 1 0%" }],
349
- ["flex-auto", { flex: "1 1 auto" }],
350
- ["flex-initial", { flex: "0 1 auto" }],
351
- ["flex-none", { flex: "none" }],
352
- [
353
- /^(?:flex-)?shrink(?:-(.*))?$/,
354
- ([, d = ""]) => ({ "flex-shrink": h.bracket.cssvar.number(d) ?? 1 }),
355
- { autocomplete: ["flex-shrink-<num>", "shrink-<num>"] }
356
- ],
357
- [
358
- /^(?:flex-)?grow(?:-(.*))?$/,
359
- ([, d = ""]) => ({ "flex-grow": h.bracket.cssvar.number(d) ?? 1 }),
360
- { autocomplete: ["flex-grow-<num>", "grow-<num>"] }
361
- ],
362
- [
363
- /^(?:flex-)?basis-(.+)$/,
364
- ([, d], { theme }) => ({ "flex-basis": theme.spacing?.[d] ?? h.bracket.cssvar.auto.fraction.rem(d) }),
365
- { autocomplete: ["flex-basis-$spacing", "basis-$spacing"] }
366
- ],
367
- ["flex-row", { "flex-direction": "row" }],
368
- ["flex-row-reverse", { "flex-direction": "row-reverse" }],
369
- ["flex-col", { "flex-direction": "column" }],
370
- ["flex-col-reverse", { "flex-direction": "column-reverse" }],
371
- ["flex-wrap", { "flex-wrap": "wrap" }],
372
- ["flex-wrap-reverse", { "flex-wrap": "wrap-reverse" }],
373
- ["flex-nowrap", { "flex-wrap": "nowrap" }]
374
- ];
375
-
376
- //#endregion
377
- //#region src/_rules/gap.ts
378
- const directions = {
379
- "": "",
380
- "x": "column-",
381
- "y": "row-",
382
- "col": "column-",
383
- "row": "row-"
384
- };
385
- function handleGap([, d = "", s], { theme }) {
386
- const v = theme.spacing?.[s] ?? h.bracket.cssvar.global.rem(s);
387
- if (v != null) return { [`${directions[d]}gap`]: v };
388
- }
389
- const gaps = [
390
- [
391
- /^(?:flex-|grid-)?gap-?()(.+)$/,
392
- handleGap,
393
- { autocomplete: ["gap-$spacing", "gap-<num>"] }
394
- ],
395
- [
396
- /^(?:flex-|grid-)?gap-([xy])-?(.+)$/,
397
- handleGap,
398
- { autocomplete: ["gap-(x|y)-$spacing", "gap-(x|y)-<num>"] }
399
- ],
400
- [
401
- /^(?:flex-|grid-)?gap-(col|row)-?(.+)$/,
402
- handleGap,
403
- { autocomplete: ["gap-(col|row)-$spacing", "gap-(col|row)-<num>"] }
404
- ]
405
- ];
406
-
407
- //#endregion
408
- //#region src/_rules/grid.ts
409
- function rowCol(s) {
410
- return s.replace("col", "column");
411
- }
412
- function rowColTheme(s) {
413
- return s[0] === "r" ? "Row" : "Column";
414
- }
415
- function autoDirection(c, theme, prop) {
416
- const v = theme[`gridAuto${rowColTheme(c)}`]?.[prop];
417
- if (v != null) return v;
418
- switch (prop) {
419
- case "min": return "min-content";
420
- case "max": return "max-content";
421
- case "fr": return "minmax(0,1fr)";
422
- }
423
- return h.bracket.cssvar.auto.rem(prop);
424
- }
425
- const grids = [
426
- ["grid", { display: "grid" }],
427
- ["inline-grid", { display: "inline-grid" }],
428
- [/^(?:grid-)?(row|col)-(.+)$/, ([, c, v], { theme }) => ({ [`grid-${rowCol(c)}`]: theme[`grid${rowColTheme(c)}`]?.[v] ?? h.bracket.cssvar.auto(v) })],
429
- [
430
- /^(?:grid-)?(row|col)-span-(.+)$/,
431
- ([, c, s]) => {
432
- if (s === "full") return { [`grid-${rowCol(c)}`]: "1/-1" };
433
- const v = h.bracket.number(s);
434
- if (v != null) return { [`grid-${rowCol(c)}`]: `span ${v}/span ${v}` };
435
- },
436
- { autocomplete: "(grid-row|grid-col|row|col)-span-<num>" }
437
- ],
438
- [/^(?:grid-)?(row|col)-start-(.+)$/, ([, c, v]) => ({ [`grid-${rowCol(c)}-start`]: h.bracket.cssvar(v) ?? v })],
439
- [
440
- /^(?:grid-)?(row|col)-end-(.+)$/,
441
- ([, c, v]) => ({ [`grid-${rowCol(c)}-end`]: h.bracket.cssvar(v) ?? v }),
442
- { autocomplete: "(grid-row|grid-col|row|col)-(start|end)-<num>" }
443
- ],
444
- [
445
- /^(?:grid-)?auto-(rows|cols)-(.+)$/,
446
- ([, c, v], { theme }) => ({ [`grid-auto-${rowCol(c)}`]: autoDirection(c, theme, v) }),
447
- { autocomplete: "(grid-auto|auto)-(rows|cols)-<num>" }
448
- ],
449
- [/^(?:grid-auto-flow|auto-flow|grid-flow)-(.+)$/, ([, v]) => ({ "grid-auto-flow": h.bracket.cssvar(v) })],
450
- [
451
- /^(?:grid-auto-flow|auto-flow|grid-flow)-(row|col|dense|row-dense|col-dense)$/,
452
- ([, v]) => ({ "grid-auto-flow": rowCol(v).replace("-", " ") }),
453
- { autocomplete: ["(grid-auto-flow|auto-flow|grid-flow)-(row|col|dense|row-dense|col-dense)"] }
454
- ],
455
- [/^(?:grid-)?(rows|cols)-(.+)$/, ([, c, v], { theme }) => ({ [`grid-template-${rowCol(c)}`]: theme[`gridTemplate${rowColTheme(c)}`]?.[v] ?? h.bracket.cssvar(v) })],
456
- [/^(?:grid-)?(rows|cols)-minmax-([\w.-]+)$/, ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(auto-fill,minmax(${d},1fr))` })],
457
- [
458
- /^(?:grid-)?(rows|cols)-(\d+)$/,
459
- ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(${d},minmax(0,1fr))` }),
460
- { autocomplete: "(grid-rows|grid-cols|rows|cols)-<num>" }
461
- ],
462
- [/^grid-area(s)?-(.+)$/, ([, s, v]) => {
463
- if (s != null) return { "grid-template-areas": h.cssvar(v) ?? v.split("-").map((s$1) => `"${h.bracket(s$1)}"`).join(" ") };
464
- return { "grid-area": h.bracket.cssvar(v) };
465
- }],
466
- ["grid-rows-none", { "grid-template-rows": "none" }],
467
- ["grid-cols-none", { "grid-template-columns": "none" }],
468
- ["grid-rows-subgrid", { "grid-template-rows": "subgrid" }],
469
- ["grid-cols-subgrid", { "grid-template-columns": "subgrid" }]
470
- ];
471
-
472
- //#endregion
473
- //#region src/_rules/layout.ts
474
- const overflowValues = [
475
- "auto",
476
- "hidden",
477
- "clip",
478
- "visible",
479
- "scroll",
480
- "overlay",
481
- ...globalKeywords
482
- ];
483
- const overflows = [[
484
- /^(?:overflow|of)-(.+)$/,
485
- ([, v]) => overflowValues.includes(v) ? { overflow: v } : void 0,
486
- { autocomplete: [`(overflow|of)-(${overflowValues.join("|")})`, `(overflow|of)-(x|y)-(${overflowValues.join("|")})`] }
487
- ], [/^(?:overflow|of)-([xy])-(.+)$/, ([, d, v]) => overflowValues.includes(v) ? { [`overflow-${d}`]: v } : void 0]];
488
-
489
- //#endregion
490
- //#region src/_rules/position.ts
491
- const positions = [
492
- [
493
- /^(?:position-|pos-)?(relative|absolute|fixed|sticky)$/,
494
- ([, v]) => ({ position: v }),
495
- { autocomplete: [
496
- "(position|pos)-<position>",
497
- "(position|pos)-<globalKeyword>",
498
- "<position>"
499
- ] }
500
- ],
501
- [/^(?:position-|pos-)([-\w]+)$/, ([, v]) => globalKeywords.includes(v) ? { position: v } : void 0],
502
- [/^(?:position-|pos-)?(static)$/, ([, v]) => ({ position: v })]
503
- ];
504
- const justifies = [
505
- ["justify-start", { "justify-content": "flex-start" }],
506
- ["justify-end", { "justify-content": "flex-end" }],
507
- ["justify-center", { "justify-content": "center" }],
508
- ["justify-between", { "justify-content": "space-between" }],
509
- ["justify-around", { "justify-content": "space-around" }],
510
- ["justify-evenly", { "justify-content": "space-evenly" }],
511
- ["justify-stretch", { "justify-content": "stretch" }],
512
- ["justify-left", { "justify-content": "left" }],
513
- ["justify-right", { "justify-content": "right" }],
514
- ["justify-center-safe", { "justify-content": "safe center" }],
515
- ["justify-end-safe", { "justify-content": "safe flex-end" }],
516
- ["justify-normal", { "justify-content": "normal" }],
517
- ...makeGlobalStaticRules("justify", "justify-content"),
518
- ["justify-items-start", { "justify-items": "start" }],
519
- ["justify-items-end", { "justify-items": "end" }],
520
- ["justify-items-center", { "justify-items": "center" }],
521
- ["justify-items-stretch", { "justify-items": "stretch" }],
522
- ["justify-items-center-safe", { "justify-items": "safe center" }],
523
- ["justify-items-end-safe", { "justify-items": "safe flex-end" }],
524
- ...makeGlobalStaticRules("justify-items"),
525
- ["justify-self-auto", { "justify-self": "auto" }],
526
- ["justify-self-start", { "justify-self": "start" }],
527
- ["justify-self-end", { "justify-self": "end" }],
528
- ["justify-self-center", { "justify-self": "center" }],
529
- ["justify-self-stretch", { "justify-self": "stretch" }],
530
- ["justify-self-baseline", { "justify-self": "baseline" }],
531
- ["justify-self-center-safe", { "justify-self": "safe center" }],
532
- ["justify-self-end-safe", { "justify-self": "safe flex-end" }],
533
- ...makeGlobalStaticRules("justify-self")
534
- ];
535
- const orders = [
536
- [/^order-(.+)$/, ([, v]) => ({ order: h.bracket.cssvar.number(v) })],
537
- ["order-first", { order: "-9999" }],
538
- ["order-last", { order: "9999" }],
539
- ["order-none", { order: "0" }]
540
- ];
541
- const alignments = [
542
- ["content-center", { "align-content": "center" }],
543
- ["content-start", { "align-content": "flex-start" }],
544
- ["content-end", { "align-content": "flex-end" }],
545
- ["content-between", { "align-content": "space-between" }],
546
- ["content-around", { "align-content": "space-around" }],
547
- ["content-evenly", { "align-content": "space-evenly" }],
548
- ["content-baseline", { "align-content": "baseline" }],
549
- ["content-center-safe", { "align-content": "safe center" }],
550
- ["content-end-safe", { "align-content": "safe flex-end" }],
551
- ["content-stretch", { "align-content": "stretch" }],
552
- ["content-normal", { "align-content": "normal" }],
553
- ...makeGlobalStaticRules("content", "align-content"),
554
- ["items-start", { "align-items": "flex-start" }],
555
- ["items-end", { "align-items": "flex-end" }],
556
- ["items-center", { "align-items": "center" }],
557
- ["items-baseline", { "align-items": "baseline" }],
558
- ["items-stretch", { "align-items": "stretch" }],
559
- ["items-baseline-last", { "align-items": "last baseline" }],
560
- ["items-center-safe", { "align-items": "safe center" }],
561
- ["items-end-safe", { "align-items": "safe flex-end" }],
562
- ...makeGlobalStaticRules("items", "align-items"),
563
- ["self-auto", { "align-self": "auto" }],
564
- ["self-start", { "align-self": "flex-start" }],
565
- ["self-end", { "align-self": "flex-end" }],
566
- ["self-center", { "align-self": "center" }],
567
- ["self-stretch", { "align-self": "stretch" }],
568
- ["self-baseline", { "align-self": "baseline" }],
569
- ["self-baseline-last", { "align-self": "last baseline" }],
570
- ["self-center-safe", { "align-self": "safe center" }],
571
- ["self-end-safe", { "align-self": "safe flex-end" }],
572
- ...makeGlobalStaticRules("self", "align-self")
573
- ];
574
- const placements = [
575
- ["place-content-center", { "place-content": "center" }],
576
- ["place-content-start", { "place-content": "start" }],
577
- ["place-content-end", { "place-content": "end" }],
578
- ["place-content-between", { "place-content": "space-between" }],
579
- ["place-content-around", { "place-content": "space-around" }],
580
- ["place-content-evenly", { "place-content": "space-evenly" }],
581
- ["place-content-stretch", { "place-content": "stretch" }],
582
- ["place-content-baseline", { "place-content": "baseline" }],
583
- ["place-content-center-safe", { "place-content": "safe center" }],
584
- ["place-content-end-safe", { "place-content": "safe flex-end" }],
585
- ...makeGlobalStaticRules("place-content"),
586
- ["place-items-start", { "place-items": "start" }],
587
- ["place-items-end", { "place-items": "end" }],
588
- ["place-items-center", { "place-items": "center" }],
589
- ["place-items-stretch", { "place-items": "stretch" }],
590
- ["place-items-baseline", { "place-items": "baseline" }],
591
- ["place-items-center-safe", { "place-items": "safe center" }],
592
- ["place-items-end-safe", { "place-items": "safe flex-end" }],
593
- ...makeGlobalStaticRules("place-items"),
594
- ["place-self-auto", { "place-self": "auto" }],
595
- ["place-self-start", { "place-self": "start" }],
596
- ["place-self-end", { "place-self": "end" }],
597
- ["place-self-center", { "place-self": "center" }],
598
- ["place-self-stretch", { "place-self": "stretch" }],
599
- ["place-self-center-safe", { "place-self": "safe center" }],
600
- ["place-self-end-safe", { "place-self": "safe flex-end" }],
601
- ...makeGlobalStaticRules("place-self")
602
- ];
603
- /**
604
- * This is to add `flex-` and `grid-` prefix to the alignment rules,
605
- * supporting `flex="~ items-center"` in attributify mode.
606
- */
607
- const flexGridJustifiesAlignments = [
608
- ...justifies,
609
- ...alignments,
610
- ...placements
611
- ].flatMap(([k, v]) => [[`flex-${k}`, v], [`grid-${k}`, v]]);
612
- function handleInsetValue(v, { theme }) {
613
- return theme.spacing?.[v] ?? h.bracket.cssvar.global.auto.fraction.rem(v);
614
- }
615
- function handleInsetValues([, d, v], ctx) {
616
- const r = handleInsetValue(v, ctx);
617
- if (r != null && d in insetMap) return insetMap[d].map((i) => [i.slice(1), r]);
618
- }
619
- const insets = [
620
- [
621
- /^(?:position-|pos-)?inset-(.+)$/,
622
- ([, v], ctx) => ({ inset: handleInsetValue(v, ctx) }),
623
- { autocomplete: [
624
- "(position|pos)-inset-<directions>-$spacing",
625
- "(position|pos)-inset-(block|inline)-$spacing",
626
- "(position|pos)-inset-(bs|be|is|ie)-$spacing",
627
- "(position|pos)-(top|left|right|bottom)-$spacing"
628
- ] }
629
- ],
630
- [/^(?:position-|pos-)?(start|end)-(.+)$/, handleInsetValues],
631
- [/^(?:position-|pos-)?inset-([xy])-(.+)$/, handleInsetValues],
632
- [/^(?:position-|pos-)?inset-([rltbse])-(.+)$/, handleInsetValues],
633
- [/^(?:position-|pos-)?inset-(block|inline)-(.+)$/, handleInsetValues],
634
- [/^(?:position-|pos-)?inset-([bi][se])-(.+)$/, handleInsetValues],
635
- [/^(?:position-|pos-)?(top|left|right|bottom)-(.+)$/, ([, d, v], ctx) => ({ [d]: handleInsetValue(v, ctx) })]
636
- ];
637
- const floats = [
638
- ["float-left", { float: "left" }],
639
- ["float-right", { float: "right" }],
640
- ["float-start", { float: "inline-start" }],
641
- ["float-end", { float: "inline-end" }],
642
- ["float-none", { float: "none" }],
643
- ...makeGlobalStaticRules("float"),
644
- ["clear-left", { clear: "left" }],
645
- ["clear-right", { clear: "right" }],
646
- ["clear-both", { clear: "both" }],
647
- ["clear-start", { clear: "inline-start" }],
648
- ["clear-end", { clear: "inline-end" }],
649
- ["clear-none", { clear: "none" }],
650
- ...makeGlobalStaticRules("clear")
651
- ];
652
- const zIndexes = [[/^(?:position-|pos-)?z([\d.]+)$/, ([, v]) => ({ "z-index": h.number(v) })], [
653
- /^(?:position-|pos-)?z-(.+)$/,
654
- ([, v], { theme }) => ({ "z-index": theme.zIndex?.[v] ?? h.bracket.cssvar.global.auto.number(v) }),
655
- { autocomplete: "z-<num>" }
656
- ]];
657
- const boxSizing = [
658
- ["box-border", { "box-sizing": "border-box" }],
659
- ["box-content", { "box-sizing": "content-box" }],
660
- ...makeGlobalStaticRules("box", "box-sizing")
661
- ];
662
-
663
- //#endregion
664
- //#region src/_rules/question-mark.ts
665
- /**
666
- * Used for debugging, only available in development mode.
667
- *
668
- * @example `?` / `where`
669
- */
670
- const questionMark = [[/^(where|\?)$/, (_, { constructCSS, generator }) => {
671
- if (generator.userConfig.envMode === "dev") return `@keyframes __un_qm{0%{box-shadow:inset 4px 4px #ff1e90, inset -4px -4px #ff1e90}100%{box-shadow:inset 8px 8px #3399ff, inset -8px -8px #3399ff}} ${constructCSS({ animation: "__un_qm 0.5s ease-in-out alternate infinite" })}`;
672
- }]];
673
-
674
- //#endregion
675
- //#region src/_rules/static.ts
676
- const cursorValues = [
677
- "auto",
678
- "default",
679
- "none",
680
- "context-menu",
681
- "help",
682
- "pointer",
683
- "progress",
684
- "wait",
685
- "cell",
686
- "crosshair",
687
- "text",
688
- "vertical-text",
689
- "alias",
690
- "copy",
691
- "move",
692
- "no-drop",
693
- "not-allowed",
694
- "grab",
695
- "grabbing",
696
- "all-scroll",
697
- "col-resize",
698
- "row-resize",
699
- "n-resize",
700
- "e-resize",
701
- "s-resize",
702
- "w-resize",
703
- "ne-resize",
704
- "nw-resize",
705
- "se-resize",
706
- "sw-resize",
707
- "ew-resize",
708
- "ns-resize",
709
- "nesw-resize",
710
- "nwse-resize",
711
- "zoom-in",
712
- "zoom-out"
713
- ];
714
- const containValues = [
715
- "none",
716
- "strict",
717
- "content",
718
- "size",
719
- "inline-size",
720
- "layout",
721
- "style",
722
- "paint"
723
- ];
724
- const varEmpty = " ";
725
- const displays = [
726
- ["inline", { display: "inline" }],
727
- ["block", { display: "block" }],
728
- ["inline-block", { display: "inline-block" }],
729
- ["contents", { display: "contents" }],
730
- ["flow-root", { display: "flow-root" }],
731
- ["list-item", { display: "list-item" }],
732
- ["hidden", { display: "none" }],
733
- [/^display-(.+)$/, ([, c]) => ({ display: h.bracket.cssvar.global(c) })]
734
- ];
735
- const appearances = [
736
- ["visible", { visibility: "visible" }],
737
- ["invisible", { visibility: "hidden" }],
738
- ["backface-visible", { "backface-visibility": "visible" }],
739
- ["backface-hidden", { "backface-visibility": "hidden" }],
740
- ...makeGlobalStaticRules("backface", "backface-visibility")
741
- ];
742
- const cursors = [[/^cursor-(.+)$/, ([, c]) => ({ cursor: h.bracket.cssvar.global(c) })], ...cursorValues.map((v) => [`cursor-${v}`, { cursor: v }])];
743
- const contains = [[/^contain-(.*)$/, ([, d]) => {
744
- if (h.bracket(d) != null) return { contain: h.bracket(d).split(" ").map((e) => h.cssvar.fraction(e) ?? e).join(" ") };
745
- return containValues.includes(d) ? { contain: d } : void 0;
746
- }]];
747
- const pointerEvents = [
748
- ["pointer-events-auto", { "pointer-events": "auto" }],
749
- ["pointer-events-none", { "pointer-events": "none" }],
750
- ...makeGlobalStaticRules("pointer-events")
751
- ];
752
- const resizes = [
753
- ["resize-x", { resize: "horizontal" }],
754
- ["resize-y", { resize: "vertical" }],
755
- ["resize", { resize: "both" }],
756
- ["resize-none", { resize: "none" }],
757
- ...makeGlobalStaticRules("resize")
758
- ];
759
- const userSelects = [
760
- ["select-auto", {
761
- "-webkit-user-select": "auto",
762
- "user-select": "auto"
763
- }],
764
- ["select-all", {
765
- "-webkit-user-select": "all",
766
- "user-select": "all"
767
- }],
768
- ["select-text", {
769
- "-webkit-user-select": "text",
770
- "user-select": "text"
771
- }],
772
- ["select-none", {
773
- "-webkit-user-select": "none",
774
- "user-select": "none"
775
- }],
776
- ...makeGlobalStaticRules("select", "user-select")
777
- ];
778
- const whitespaces = [[
779
- /^(?:whitespace-|ws-)([-\w]+)$/,
780
- ([, v]) => [
781
- "normal",
782
- "nowrap",
783
- "pre",
784
- "pre-line",
785
- "pre-wrap",
786
- "break-spaces",
787
- ...globalKeywords
788
- ].includes(v) ? { "white-space": v } : void 0,
789
- { autocomplete: "(whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap|break-spaces)" }
790
- ]];
791
- const contentVisibility = [
792
- [
793
- /^intrinsic(?:-(block|inline|w|h))?(?:-size)?-(.+)$/,
794
- ([, d, s]) => {
795
- return { [`contain-intrinsic-${{
796
- block: "block-size",
797
- inline: "inline-size",
798
- w: "width",
799
- h: "height"
800
- }[d] ?? "size"}`]: h.bracket.cssvar.global.fraction.rem(s) };
801
- },
802
- { autocomplete: [
803
- "intrinsic-size-<num>",
804
- "intrinsic-<num>",
805
- "intrinsic-(block|inline|w|h)-<num>"
806
- ] }
807
- ],
808
- ["content-visibility-visible", { "content-visibility": "visible" }],
809
- ["content-visibility-hidden", { "content-visibility": "hidden" }],
810
- ["content-visibility-auto", { "content-visibility": "auto" }],
811
- ...makeGlobalStaticRules("content-visibility")
812
- ];
813
- const contents = [
814
- [/^content-(.+)$/, ([, v]) => ({ content: h.bracket.cssvar(v) })],
815
- ["content-empty", { content: "\"\"" }],
816
- ["content-none", { content: "none" }]
817
- ];
818
- const breaks = [
819
- ["break-normal", {
820
- "overflow-wrap": "normal",
821
- "word-break": "normal"
822
- }],
823
- ["break-words", { "overflow-wrap": "break-word" }],
824
- ["break-all", { "word-break": "break-all" }],
825
- ["break-keep", { "word-break": "keep-all" }],
826
- ["break-anywhere", { "overflow-wrap": "anywhere" }]
827
- ];
828
- const textWraps = [
829
- ["text-wrap", { "text-wrap": "wrap" }],
830
- ["text-nowrap", { "text-wrap": "nowrap" }],
831
- ["text-balance", { "text-wrap": "balance" }],
832
- ["text-pretty", { "text-wrap": "pretty" }]
833
- ];
834
- const textOverflows = [
835
- ["truncate", {
836
- "overflow": "hidden",
837
- "text-overflow": "ellipsis",
838
- "white-space": "nowrap"
839
- }],
840
- ["text-truncate", {
841
- "overflow": "hidden",
842
- "text-overflow": "ellipsis",
843
- "white-space": "nowrap"
844
- }],
845
- ["text-ellipsis", { "text-overflow": "ellipsis" }],
846
- ["text-clip", { "text-overflow": "clip" }]
847
- ];
848
- const textTransforms = [
849
- ["case-upper", { "text-transform": "uppercase" }],
850
- ["case-lower", { "text-transform": "lowercase" }],
851
- ["case-capital", { "text-transform": "capitalize" }],
852
- ["case-normal", { "text-transform": "none" }],
853
- ...makeGlobalStaticRules("case", "text-transform")
854
- ];
855
- const fontStyles = [
856
- ["italic", { "font-style": "italic" }],
857
- ["not-italic", { "font-style": "normal" }],
858
- ["font-italic", { "font-style": "italic" }],
859
- ["font-not-italic", { "font-style": "normal" }],
860
- ["oblique", { "font-style": "oblique" }],
861
- ["not-oblique", { "font-style": "normal" }],
862
- ["font-oblique", { "font-style": "oblique" }],
863
- ["font-not-oblique", { "font-style": "normal" }]
864
- ];
865
- const fontSmoothings = [["antialiased", {
866
- "-webkit-font-smoothing": "antialiased",
867
- "-moz-osx-font-smoothing": "grayscale"
868
- }], ["subpixel-antialiased", {
869
- "-webkit-font-smoothing": "auto",
870
- "-moz-osx-font-smoothing": "auto"
871
- }]];
872
- const fieldSizing = [["field-sizing-fixed", { "field-sizing": "fixed" }], ["field-sizing-content", { "field-sizing": "content" }]];
873
-
874
- //#endregion
875
- //#region src/_rules/ring.ts
876
- const ringBase = {
877
- "--un-ring-inset": varEmpty,
878
- "--un-ring-offset-width": "0px",
879
- "--un-ring-offset-color": "#fff",
880
- "--un-ring-width": "0px",
881
- "--un-ring-color": "rgb(147 197 253 / 0.5)",
882
- "--un-shadow": "0 0 rgb(0 0 0 / 0)"
883
- };
884
- const preflightKeys$2 = Object.keys(ringBase);
885
- const rings = [
886
- [
887
- /^ring(?:-(.+))?$/,
888
- ([, d], { theme }) => {
889
- const value = theme.ringWidth?.[d || "DEFAULT"] ?? h.px(d || "1");
890
- if (value) return {
891
- "--un-ring-width": value,
892
- "--un-ring-offset-shadow": "var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color)",
893
- "--un-ring-shadow": "var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color)",
894
- "box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow)"
895
- };
896
- },
897
- {
898
- custom: { preflightKeys: preflightKeys$2 },
899
- autocomplete: "ring-$ringWidth"
900
- }
901
- ],
902
- [
903
- /^ring-(?:width-|size-)(.+)$/,
904
- handleWidth$1,
905
- { autocomplete: "ring-(width|size)-$lineWidth" }
906
- ],
907
- ["ring-offset", { "--un-ring-offset-width": "1px" }],
908
- [
909
- /^ring-offset-(?:width-|size-)?(.+)$/,
910
- ([, d], { theme }) => ({ "--un-ring-offset-width": theme.lineWidth?.[d] ?? h.bracket.cssvar.px(d) }),
911
- { autocomplete: "ring-offset-(width|size)-$lineWidth" }
912
- ],
913
- [
914
- /^ring-(.+)$/,
915
- handleColorOrWidth$1,
916
- { autocomplete: "ring-$colors" }
917
- ],
918
- [
919
- /^ring-op(?:acity)?-?(.+)$/,
920
- ([, opacity$1]) => ({ "--un-ring-opacity": h.bracket.percent.cssvar(opacity$1) }),
921
- { autocomplete: "ring-(op|opacity)-<percent>" }
922
- ],
923
- [
924
- /^ring-offset-(.+)$/,
925
- colorResolver("--un-ring-offset-color", "ring-offset", "borderColor"),
926
- { autocomplete: "ring-offset-$colors" }
927
- ],
928
- [
929
- /^ring-offset-op(?:acity)?-?(.+)$/,
930
- ([, opacity$1]) => ({ "--un-ring-offset-opacity": h.bracket.percent.cssvar(opacity$1) }),
931
- { autocomplete: "ring-offset-(op|opacity)-<percent>" }
932
- ],
933
- ["ring-inset", { "--un-ring-inset": "inset" }]
934
- ];
935
- function handleWidth$1([, b], { theme }) {
936
- return { "--un-ring-width": theme.ringWidth?.[b] ?? h.bracket.cssvar.px(b) };
937
- }
938
- function handleColorOrWidth$1(match, ctx) {
939
- if (isCSSMathFn(h.bracket(match[1]))) return handleWidth$1(match, ctx);
940
- return colorResolver("--un-ring-color", "ring", "borderColor")(match, ctx);
941
- }
942
-
943
- //#endregion
944
- //#region src/_rules/shadow.ts
945
- const boxShadowsBase = {
946
- "--un-ring-offset-shadow": "0 0 rgb(0 0 0 / 0)",
947
- "--un-ring-shadow": "0 0 rgb(0 0 0 / 0)",
948
- "--un-shadow-inset": varEmpty,
949
- "--un-shadow": "0 0 rgb(0 0 0 / 0)"
950
- };
951
- const preflightKeys$1 = Object.keys(boxShadowsBase);
952
- const boxShadows = [
953
- [
954
- /^shadow(?:-(.+))?$/,
955
- (match, context) => {
956
- const [, d] = match;
957
- const { theme } = context;
958
- const v = theme.boxShadow?.[d || "DEFAULT"];
959
- const c = d ? h.bracket.cssvar(d) : void 0;
960
- if ((v != null || c != null) && !hasParseableColor(c, theme, "shadowColor")) return {
961
- "--un-shadow": colorableShadows(v || c, "--un-shadow-color").join(","),
962
- "box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow)"
963
- };
964
- return colorResolver("--un-shadow-color", "shadow", "shadowColor")(match, context);
965
- },
966
- {
967
- custom: { preflightKeys: preflightKeys$1 },
968
- autocomplete: ["shadow-$colors", "shadow-$boxShadow"]
969
- }
970
- ],
971
- [
972
- /^shadow-op(?:acity)?-?(.+)$/,
973
- ([, opacity$1]) => ({ "--un-shadow-opacity": h.bracket.percent.cssvar(opacity$1) }),
974
- { autocomplete: "shadow-(op|opacity)-<percent>" }
975
- ],
976
- ["shadow-inset", { "--un-shadow-inset": "inset" }]
977
- ];
978
-
979
- //#endregion
980
- //#region src/_rules/size.ts
981
- const sizeMapping = {
982
- h: "height",
983
- w: "width",
984
- inline: "inline-size",
985
- block: "block-size"
986
- };
987
- function getPropName(minmax, hw) {
988
- return `${minmax || ""}${sizeMapping[hw]}`;
989
- }
990
- function getSizeValue(minmax, hw, theme, prop) {
991
- const v = theme[getPropName(minmax, hw).replace(/-(\w)/g, (_, p) => p.toUpperCase())]?.[prop];
992
- if (v != null) return v;
993
- switch (prop) {
994
- case "fit":
995
- case "max":
996
- case "min": return `${prop}-content`;
997
- case "stretch": return "stretch";
998
- }
999
- return h.bracket.cssvar.global.auto.fraction.rem(prop);
1000
- }
1001
- const sizes = [
1002
- [/^size-(min-|max-)?(.+)$/, ([, m, s], { theme }) => ({
1003
- [getPropName(m, "w")]: getSizeValue(m, "w", theme, s),
1004
- [getPropName(m, "h")]: getSizeValue(m, "h", theme, s)
1005
- })],
1006
- [/^(?:size-)?(min-|max-)?([wh])-?(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) })],
1007
- [
1008
- /^(?:size-)?(min-|max-)?(block|inline)-(.+)$/,
1009
- ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) }),
1010
- { autocomplete: [
1011
- "(w|h)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
1012
- "(block|inline)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
1013
- "(max|min)-(w|h|block|inline)",
1014
- "(max|min)-(w|h|block|inline)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
1015
- "(w|h)-full",
1016
- "(max|min)-(w|h)-full"
1017
- ] }
1018
- ],
1019
- [/^(?:size-)?(min-|max-)?(h)-screen-(.+)$/, ([, m, h$1, p], context) => ({ [getPropName(m, h$1)]: handleBreakpoint(context, p, "verticalBreakpoints") })],
1020
- [
1021
- /^(?:size-)?(min-|max-)?(w)-screen-(.+)$/,
1022
- ([, m, w, p], context) => ({ [getPropName(m, w)]: handleBreakpoint(context, p) }),
1023
- { autocomplete: [
1024
- "(w|h)-screen",
1025
- "(min|max)-(w|h)-screen",
1026
- "h-screen-$verticalBreakpoints",
1027
- "(min|max)-h-screen-$verticalBreakpoints",
1028
- "w-screen-$breakpoints",
1029
- "(min|max)-w-screen-$breakpoints"
1030
- ] }
1031
- ]
1032
- ];
1033
- function handleBreakpoint(context, point, key = "breakpoints") {
1034
- const bp = resolveBreakpoints(context, key);
1035
- if (bp) return bp.find((i) => i.point === point)?.size;
1036
- }
1037
- function getAspectRatio(prop) {
1038
- if (/^\d+\/\d+$/.test(prop)) return prop;
1039
- switch (prop) {
1040
- case "square": return "1/1";
1041
- case "video": return "16/9";
1042
- }
1043
- return h.bracket.cssvar.global.auto.number(prop);
1044
- }
1045
- const aspectRatio = [[
1046
- /^(?:size-)?aspect-(?:ratio-)?(.+)$/,
1047
- ([, d]) => ({ "aspect-ratio": getAspectRatio(d) }),
1048
- { autocomplete: ["aspect-(square|video|ratio)", "aspect-ratio-(square|video)"] }
1049
- ]];
1050
-
1051
- //#endregion
1052
- //#region src/_rules/spacing.ts
1053
- const paddings = [
1054
- [
1055
- /^pa?()-?(.+)$/,
1056
- directionSize("padding"),
1057
- { autocomplete: ["(m|p)<num>", "(m|p)-<num>"] }
1058
- ],
1059
- [
1060
- /^p-?xy()()$/,
1061
- directionSize("padding"),
1062
- { autocomplete: "(m|p)-(xy)" }
1063
- ],
1064
- [/^p-?([xy])(?:-?(.+))?$/, directionSize("padding")],
1065
- [
1066
- /^p-?([rltbse])(?:-?(.+))?$/,
1067
- directionSize("padding"),
1068
- { autocomplete: "(m|p)<directions>-<num>" }
1069
- ],
1070
- [
1071
- /^p-(block|inline)(?:-(.+))?$/,
1072
- directionSize("padding"),
1073
- { autocomplete: "(m|p)-(block|inline)-<num>" }
1074
- ],
1075
- [
1076
- /^p-?([bi][se])(?:-?(.+))?$/,
1077
- directionSize("padding"),
1078
- { autocomplete: "(m|p)-(bs|be|is|ie)-<num>" }
1079
- ]
1080
- ];
1081
- const margins = [
1082
- [/^ma?()-?(.+)$/, directionSize("margin")],
1083
- [/^m-?xy()()$/, directionSize("margin")],
1084
- [/^m-?([xy])(?:-?(.+))?$/, directionSize("margin")],
1085
- [/^m-?([rltbse])(?:-?(.+))?$/, directionSize("margin")],
1086
- [/^m-(block|inline)(?:-(.+))?$/, directionSize("margin")],
1087
- [/^m-?([bi][se])(?:-?(.+))?$/, directionSize("margin")]
1088
- ];
1089
-
1090
- //#endregion
1091
- //#region src/_rules/svg.ts
1092
- const svgUtilities = [
1093
- [
1094
- /^fill-(.+)$/,
1095
- colorResolver("fill", "fill", "backgroundColor"),
1096
- { autocomplete: "fill-$colors" }
1097
- ],
1098
- [
1099
- /^fill-op(?:acity)?-?(.+)$/,
1100
- ([, opacity$1]) => ({ "--un-fill-opacity": h.bracket.percent.cssvar(opacity$1) }),
1101
- { autocomplete: "fill-(op|opacity)-<percent>" }
1102
- ],
1103
- ["fill-none", { fill: "none" }],
1104
- [
1105
- /^stroke-(?:width-|size-)?(.+)$/,
1106
- handleWidth,
1107
- { autocomplete: ["stroke-width-$lineWidth", "stroke-size-$lineWidth"] }
1108
- ],
1109
- [
1110
- /^stroke-dash-(.+)$/,
1111
- ([, s]) => ({ "stroke-dasharray": h.bracket.cssvar.number(s) }),
1112
- { autocomplete: "stroke-dash-<num>" }
1113
- ],
1114
- [
1115
- /^stroke-offset-(.+)$/,
1116
- ([, s], { theme }) => ({ "stroke-dashoffset": theme.lineWidth?.[s] ?? h.bracket.cssvar.px.numberWithUnit(s) }),
1117
- { autocomplete: "stroke-offset-$lineWidth" }
1118
- ],
1119
- [
1120
- /^stroke-(.+)$/,
1121
- handleColorOrWidth,
1122
- { autocomplete: "stroke-$colors" }
1123
- ],
1124
- [
1125
- /^stroke-op(?:acity)?-?(.+)$/,
1126
- ([, opacity$1]) => ({ "--un-stroke-opacity": h.bracket.percent.cssvar(opacity$1) }),
1127
- { autocomplete: "stroke-(op|opacity)-<percent>" }
1128
- ],
1129
- ["stroke-cap-square", { "stroke-linecap": "square" }],
1130
- ["stroke-cap-round", { "stroke-linecap": "round" }],
1131
- ["stroke-cap-auto", { "stroke-linecap": "butt" }],
1132
- ["stroke-join-arcs", { "stroke-linejoin": "arcs" }],
1133
- ["stroke-join-bevel", { "stroke-linejoin": "bevel" }],
1134
- ["stroke-join-clip", { "stroke-linejoin": "miter-clip" }],
1135
- ["stroke-join-round", { "stroke-linejoin": "round" }],
1136
- ["stroke-join-auto", { "stroke-linejoin": "miter" }],
1137
- ["stroke-none", { stroke: "none" }]
1138
- ];
1139
- function handleWidth([, b], { theme }) {
1140
- return { "stroke-width": theme.lineWidth?.[b] ?? h.bracket.cssvar.fraction.px.number(b) };
1141
- }
1142
- function handleColorOrWidth(match, ctx) {
1143
- if (isCSSMathFn(h.bracket(match[1]))) return handleWidth(match, ctx);
1144
- return colorResolver("stroke", "stroke", "borderColor")(match, ctx);
1145
- }
1146
-
1147
- //#endregion
1148
- //#region src/_rules/transform.ts
1149
- const transformValues = [
1150
- "translate",
1151
- "rotate",
1152
- "scale"
1153
- ];
1154
- const transformCpu = [
1155
- "translateX(var(--un-translate-x))",
1156
- "translateY(var(--un-translate-y))",
1157
- "rotate(var(--un-rotate))",
1158
- "rotateZ(var(--un-rotate-z))",
1159
- "skewX(var(--un-skew-x))",
1160
- "skewY(var(--un-skew-y))",
1161
- "scaleX(var(--un-scale-x))",
1162
- "scaleY(var(--un-scale-y))"
1163
- ].join(" ");
1164
- const transform = [
1165
- "translateX(var(--un-translate-x))",
1166
- "translateY(var(--un-translate-y))",
1167
- "translateZ(var(--un-translate-z))",
1168
- "rotate(var(--un-rotate))",
1169
- "rotateX(var(--un-rotate-x))",
1170
- "rotateY(var(--un-rotate-y))",
1171
- "rotateZ(var(--un-rotate-z))",
1172
- "skewX(var(--un-skew-x))",
1173
- "skewY(var(--un-skew-y))",
1174
- "scaleX(var(--un-scale-x))",
1175
- "scaleY(var(--un-scale-y))",
1176
- "scaleZ(var(--un-scale-z))"
1177
- ].join(" ");
1178
- const transformGpu = [
1179
- "translate3d(var(--un-translate-x), var(--un-translate-y), var(--un-translate-z))",
1180
- "rotate(var(--un-rotate))",
1181
- "rotateX(var(--un-rotate-x))",
1182
- "rotateY(var(--un-rotate-y))",
1183
- "rotateZ(var(--un-rotate-z))",
1184
- "skewX(var(--un-skew-x))",
1185
- "skewY(var(--un-skew-y))",
1186
- "scaleX(var(--un-scale-x))",
1187
- "scaleY(var(--un-scale-y))",
1188
- "scaleZ(var(--un-scale-z))"
1189
- ].join(" ");
1190
- const transformBase = {
1191
- "--un-rotate": 0,
1192
- "--un-rotate-x": 0,
1193
- "--un-rotate-y": 0,
1194
- "--un-rotate-z": 0,
1195
- "--un-scale-x": 1,
1196
- "--un-scale-y": 1,
1197
- "--un-scale-z": 1,
1198
- "--un-skew-x": 0,
1199
- "--un-skew-y": 0,
1200
- "--un-translate-x": 0,
1201
- "--un-translate-y": 0,
1202
- "--un-translate-z": 0
1203
- };
1204
- const preflightKeys = Object.keys(transformBase);
1205
- const transforms = [
1206
- [
1207
- /^(?:transform-)?origin-(.+)$/,
1208
- ([, s]) => ({ "transform-origin": positionMap[s] ?? h.bracket.cssvar(s) }),
1209
- { autocomplete: [`transform-origin-(${Object.keys(positionMap).join("|")})`, `origin-(${Object.keys(positionMap).join("|")})`] }
1210
- ],
1211
- [/^(transform-)?perspect(?:ive)?-(.+)$/, ([, t, s]) => {
1212
- const v = h.bracket.cssvar.px.numberWithUnit(s);
1213
- if (v != null) {
1214
- if (t) return {
1215
- "--un-perspective": `perspective(${v})`,
1216
- "transform": `var(--un-perspective) ${transform}`
1217
- };
1218
- return {
1219
- "-webkit-perspective": v,
1220
- "perspective": v
1221
- };
1222
- }
1223
- }],
1224
- [/^perspect(?:ive)?-origin-(.+)$/, ([, s]) => {
1225
- const v = h.bracket.cssvar(s) ?? (s.length >= 3 ? positionMap[s] : void 0);
1226
- if (v != null) return {
1227
- "-webkit-perspective-origin": v,
1228
- "perspective-origin": v
1229
- };
1230
- }],
1231
- [
1232
- /^(?:transform-)?translate-()(.+)$/,
1233
- handleTranslate,
1234
- { custom: { preflightKeys } }
1235
- ],
1236
- [
1237
- /^(?:transform-)?translate-([xyz])-(.+)$/,
1238
- handleTranslate,
1239
- { custom: { preflightKeys } }
1240
- ],
1241
- [
1242
- /^(?:transform-)?rotate-()(.+)$/,
1243
- handleRotate,
1244
- { custom: { preflightKeys } }
1245
- ],
1246
- [
1247
- /^(?:transform-)?rotate-([xyz])-(.+)$/,
1248
- handleRotate,
1249
- { custom: { preflightKeys } }
1250
- ],
1251
- [
1252
- /^(?:transform-)?skew-()(.+)$/,
1253
- handleSkew,
1254
- { custom: { preflightKeys } }
1255
- ],
1256
- [
1257
- /^(?:transform-)?skew-([xy])-(.+)$/,
1258
- handleSkew,
1259
- {
1260
- custom: { preflightKeys },
1261
- autocomplete: ["transform-skew-(x|y)-<percent>", "skew-(x|y)-<percent>"]
1262
- }
1263
- ],
1264
- [
1265
- /^(?:transform-)?scale-()(.+)$/,
1266
- handleScale,
1267
- { custom: { preflightKeys } }
1268
- ],
1269
- [
1270
- /^(?:transform-)?scale-([xyz])-(.+)$/,
1271
- handleScale,
1272
- {
1273
- custom: { preflightKeys },
1274
- autocomplete: [
1275
- `transform-(${transformValues.join("|")})-<percent>`,
1276
- `transform-(${transformValues.join("|")})-(x|y|z)-<percent>`,
1277
- `(${transformValues.join("|")})-<percent>`,
1278
- `(${transformValues.join("|")})-(x|y|z)-<percent>`
1279
- ]
1280
- }
1281
- ],
1282
- [/^(?:transform-)?preserve-3d$/, () => ({ "transform-style": "preserve-3d" })],
1283
- [/^(?:transform-)?preserve-flat$/, () => ({ "transform-style": "flat" })],
1284
- [
1285
- "transform",
1286
- { transform },
1287
- { custom: { preflightKeys } }
1288
- ],
1289
- [
1290
- "transform-cpu",
1291
- { transform: transformCpu },
1292
- { custom: { preflightKeys: [
1293
- "--un-translate-x",
1294
- "--un-translate-y",
1295
- "--un-rotate",
1296
- "--un-rotate-z",
1297
- "--un-skew-x",
1298
- "--un-skew-y",
1299
- "--un-scale-x",
1300
- "--un-scale-y"
1301
- ] } }
1302
- ],
1303
- [
1304
- "transform-gpu",
1305
- { transform: transformGpu },
1306
- { custom: { preflightKeys } }
1307
- ],
1308
- ["transform-none", { transform: "none" }],
1309
- ...makeGlobalStaticRules("transform")
1310
- ];
1311
- function handleTranslate([, d, b], { theme }) {
1312
- const v = theme.spacing?.[b] ?? h.bracket.cssvar.fraction.rem(b);
1313
- if (v != null) return [...transformXYZ(d, v, "translate"), ["transform", transform]];
1314
- }
1315
- function handleScale([, d, b]) {
1316
- const v = h.bracket.cssvar.fraction.percent(b);
1317
- if (v != null) return [...transformXYZ(d, v, "scale"), ["transform", transform]];
1318
- }
1319
- function handleRotate([, d = "", b]) {
1320
- const v = h.bracket.cssvar.degree(b);
1321
- if (v != null) if (d) return {
1322
- "--un-rotate": 0,
1323
- [`--un-rotate-${d}`]: v,
1324
- "transform": transform
1325
- };
1326
- else return {
1327
- "--un-rotate-x": 0,
1328
- "--un-rotate-y": 0,
1329
- "--un-rotate-z": 0,
1330
- "--un-rotate": v,
1331
- "transform": transform
1332
- };
1333
- }
1334
- function handleSkew([, d, b]) {
1335
- const v = h.bracket.cssvar.degree(b);
1336
- if (v != null) return [...transformXYZ(d, v, "skew"), ["transform", transform]];
1337
- }
1338
-
1339
- //#endregion
1340
- //#region src/_rules/transition.ts
1341
- function resolveTransitionProperty(prop, theme) {
1342
- let p;
1343
- if (h.cssvar(prop) != null) p = h.cssvar(prop);
1344
- else {
1345
- if (prop.startsWith("[") && prop.endsWith("]")) prop = prop.slice(1, -1);
1346
- const props = prop.split(",").map((p$1) => theme.transitionProperty?.[p$1] ?? h.properties(p$1));
1347
- if (props.every(Boolean)) p = props.join(",");
1348
- }
1349
- return p;
1350
- }
1351
- const transitions = [
1352
- [
1353
- /^transition(?:-(\D+?))?(?:-(\d+))?$/,
1354
- ([, prop, d], { theme }) => {
1355
- if (!prop && !d) return {
1356
- "transition-property": theme.transitionProperty?.DEFAULT,
1357
- "transition-timing-function": theme.easing?.DEFAULT,
1358
- "transition-duration": theme.duration?.DEFAULT ?? h.time("150")
1359
- };
1360
- else if (prop != null) {
1361
- const p = resolveTransitionProperty(prop, theme);
1362
- const duration = theme.duration?.[d || "DEFAULT"] ?? h.time(d || "150");
1363
- if (p) return {
1364
- "transition-property": p,
1365
- "transition-timing-function": theme.easing?.DEFAULT,
1366
- "transition-duration": duration
1367
- };
1368
- } else if (d != null) return {
1369
- "transition-property": theme.transitionProperty?.DEFAULT,
1370
- "transition-timing-function": theme.easing?.DEFAULT,
1371
- "transition-duration": theme.duration?.[d] ?? h.time(d)
1372
- };
1373
- },
1374
- { autocomplete: "transition-$transitionProperty-$duration" }
1375
- ],
1376
- [
1377
- /^(?:transition-)?duration-(.+)$/,
1378
- ([, d], { theme }) => ({ "transition-duration": theme.duration?.[d || "DEFAULT"] ?? h.bracket.cssvar.time(d) }),
1379
- { autocomplete: ["transition-duration-$duration", "duration-$duration"] }
1380
- ],
1381
- [
1382
- /^(?:transition-)?delay-(.+)$/,
1383
- ([, d], { theme }) => ({ "transition-delay": theme.duration?.[d || "DEFAULT"] ?? h.bracket.cssvar.time(d) }),
1384
- { autocomplete: ["transition-delay-$duration", "delay-$duration"] }
1385
- ],
1386
- [
1387
- /^(?:transition-)?ease(?:-(.+))?$/,
1388
- ([, d], { theme }) => ({ "transition-timing-function": theme.easing?.[d || "DEFAULT"] ?? h.bracket.cssvar(d) }),
1389
- { autocomplete: ["transition-ease-(linear|in|out|in-out|DEFAULT)", "ease-(linear|in|out|in-out|DEFAULT)"] }
1390
- ],
1391
- [
1392
- /^(?:transition-)?property-(.+)$/,
1393
- ([, v], { theme }) => {
1394
- const p = h.global(v) || resolveTransitionProperty(v, theme);
1395
- if (p) return { "transition-property": p };
1396
- },
1397
- { autocomplete: [
1398
- `transition-property-(${[...globalKeywords].join("|")})`,
1399
- "transition-property-$transitionProperty",
1400
- "property-$transitionProperty"
1401
- ] }
1402
- ],
1403
- ["transition-none", { transition: "none" }],
1404
- ...makeGlobalStaticRules("transition"),
1405
- ["transition-discrete", { "transition-behavior": "allow-discrete" }],
1406
- ["transition-normal", { "transition-behavior": "normal" }]
1407
- ];
1408
-
1409
- //#endregion
1410
- //#region src/_rules/typography.ts
1411
- const fonts = [
1412
- [
1413
- /^text-(.+)$/,
1414
- handleText,
1415
- { autocomplete: "text-$fontSize" }
1416
- ],
1417
- [
1418
- /^(?:text|font)-size-(.+)$/,
1419
- handleSize,
1420
- { autocomplete: "text-size-$fontSize" }
1421
- ],
1422
- [
1423
- /^text-(?:color-)?(.+)$/,
1424
- handlerColorOrSize,
1425
- { autocomplete: "text-$colors" }
1426
- ],
1427
- [
1428
- /^(?:color|c)-(.+)$/,
1429
- colorResolver("color", "text", "textColor"),
1430
- { autocomplete: "(color|c)-$colors" }
1431
- ],
1432
- [
1433
- /^(?:text|color|c)-(.+)$/,
1434
- ([, v]) => globalKeywords.includes(v) ? { color: v } : void 0,
1435
- { autocomplete: `(text|color|c)-(${globalKeywords.join("|")})` }
1436
- ],
1437
- [
1438
- /^(?:text|color|c)-op(?:acity)?-?(.+)$/,
1439
- ([, opacity$1]) => ({ "--un-text-opacity": h.bracket.percent.cssvar(opacity$1) }),
1440
- { autocomplete: "(text|color|c)-(op|opacity)-<percent>" }
1441
- ],
1442
- [
1443
- /^(?:font|fw)-?([^-]+)$/,
1444
- ([, s], { theme }) => ({ "font-weight": theme.fontWeight?.[s] || h.bracket.global.number(s) }),
1445
- { autocomplete: ["(font|fw)-(100|200|300|400|500|600|700|800|900)", "(font|fw)-$fontWeight"] }
1446
- ],
1447
- [
1448
- /^(?:font-)?(?:leading|lh|line-height)-(.+)$/,
1449
- ([, s], { theme }) => ({ "line-height": handleThemeByKey(s, theme, "lineHeight") }),
1450
- { autocomplete: "(leading|lh|line-height)-$lineHeight" }
1451
- ],
1452
- ["font-synthesis-weight", { "font-synthesis": "weight" }],
1453
- ["font-synthesis-style", { "font-synthesis": "style" }],
1454
- ["font-synthesis-small-caps", { "font-synthesis": "small-caps" }],
1455
- ["font-synthesis-none", { "font-synthesis": "none" }],
1456
- [/^font-synthesis-(.+)$/, ([, s]) => ({ "font-synthesis": h.bracket.cssvar.global(s) })],
1457
- [
1458
- /^(?:font-)?tracking-(.+)$/,
1459
- ([, s], { theme }) => ({ "letter-spacing": theme.letterSpacing?.[s] || h.bracket.cssvar.global.rem(s) }),
1460
- { autocomplete: "tracking-$letterSpacing" }
1461
- ],
1462
- [
1463
- /^(?:font-)?word-spacing-(.+)$/,
1464
- ([, s], { theme }) => ({ "word-spacing": theme.wordSpacing?.[s] || h.bracket.cssvar.global.rem(s) }),
1465
- { autocomplete: "word-spacing-$wordSpacing" }
1466
- ],
1467
- ["font-stretch-normal", { "font-stretch": "normal" }],
1468
- ["font-stretch-ultra-condensed", { "font-stretch": "ultra-condensed" }],
1469
- ["font-stretch-extra-condensed", { "font-stretch": "extra-condensed" }],
1470
- ["font-stretch-condensed", { "font-stretch": "condensed" }],
1471
- ["font-stretch-semi-condensed", { "font-stretch": "semi-condensed" }],
1472
- ["font-stretch-semi-expanded", { "font-stretch": "semi-expanded" }],
1473
- ["font-stretch-expanded", { "font-stretch": "expanded" }],
1474
- ["font-stretch-extra-expanded", { "font-stretch": "extra-expanded" }],
1475
- ["font-stretch-ultra-expanded", { "font-stretch": "ultra-expanded" }],
1476
- [
1477
- /^font-stretch-(.+)$/,
1478
- ([, s]) => ({ "font-stretch": h.bracket.cssvar.fraction.global(s) }),
1479
- { autocomplete: "font-stretch-<percentage>" }
1480
- ],
1481
- [
1482
- /^font-(.+)$/,
1483
- ([, d], { theme }) => ({ "font-family": theme.fontFamily?.[d] || h.bracket.cssvar.global(d) }),
1484
- { autocomplete: "font-$fontFamily" }
1485
- ]
1486
- ];
1487
- const tabSizes = [[/^tab(?:-(.+))?$/, ([, s]) => {
1488
- const v = h.bracket.cssvar.global.number(s || "4");
1489
- if (v != null) return {
1490
- "-moz-tab-size": v,
1491
- "-o-tab-size": v,
1492
- "tab-size": v
1493
- };
1494
- }]];
1495
- const textIndents = [[
1496
- /^indent(?:-(.+))?$/,
1497
- ([, s], { theme }) => ({ "text-indent": theme.textIndent?.[s || "DEFAULT"] || h.bracket.cssvar.global.fraction.rem(s) }),
1498
- { autocomplete: "indent-$textIndent" }
1499
- ]];
1500
- const textStrokes = [
1501
- [
1502
- /^text-stroke(?:-(.+))?$/,
1503
- ([, s], { theme }) => ({ "-webkit-text-stroke-width": theme.textStrokeWidth?.[s || "DEFAULT"] || h.bracket.cssvar.px(s) }),
1504
- { autocomplete: "text-stroke-$textStrokeWidth" }
1505
- ],
1506
- [
1507
- /^text-stroke-(.+)$/,
1508
- colorResolver("-webkit-text-stroke-color", "text-stroke", "borderColor"),
1509
- { autocomplete: "text-stroke-$colors" }
1510
- ],
1511
- [
1512
- /^text-stroke-op(?:acity)?-?(.+)$/,
1513
- ([, opacity$1]) => ({ "--un-text-stroke-opacity": h.bracket.percent.cssvar(opacity$1) }),
1514
- { autocomplete: "text-stroke-(op|opacity)-<percent>" }
1515
- ]
1516
- ];
1517
- const textShadows = [
1518
- [
1519
- /^text-shadow(?:-(.+))?$/,
1520
- ([, s], { theme }) => {
1521
- const v = theme.textShadow?.[s || "DEFAULT"];
1522
- if (v != null) return {
1523
- "--un-text-shadow": colorableShadows(v, "--un-text-shadow-color").join(","),
1524
- "text-shadow": "var(--un-text-shadow)"
1525
- };
1526
- return { "text-shadow": h.bracket.cssvar.global(s) };
1527
- },
1528
- { autocomplete: "text-shadow-$textShadow" }
1529
- ],
1530
- [
1531
- /^text-shadow-color-(.+)$/,
1532
- colorResolver("--un-text-shadow-color", "text-shadow", "shadowColor"),
1533
- { autocomplete: "text-shadow-color-$colors" }
1534
- ],
1535
- [
1536
- /^text-shadow-color-op(?:acity)?-?(.+)$/,
1537
- ([, opacity$1]) => ({ "--un-text-shadow-opacity": h.bracket.percent.cssvar(opacity$1) }),
1538
- { autocomplete: "text-shadow-color-(op|opacity)-<percent>" }
1539
- ]
1540
- ];
1541
- function handleThemeByKey(s, theme, key) {
1542
- return theme[key]?.[s] || h.bracket.cssvar.global.rem(s);
1543
- }
1544
- function handleSize([, s], { theme }) {
1545
- const size = toArray(theme.fontSize?.[s])?.[0] ?? h.bracket.cssvar.global.rem(s);
1546
- if (size != null) return { "font-size": size };
1547
- }
1548
- function handlerColorOrSize(match, ctx) {
1549
- if (isCSSMathFn(h.bracket(match[1]))) return handleSize(match, ctx);
1550
- return colorResolver("color", "text", "textColor")(match, ctx);
1551
- }
1552
- function handleText([, s = "base"], { theme }) {
1553
- const split = splitShorthand(s, "length");
1554
- if (!split) return;
1555
- const [size, leading] = split;
1556
- const sizePairs = toArray(theme.fontSize?.[size]);
1557
- const lineHeight = leading ? handleThemeByKey(leading, theme, "lineHeight") : void 0;
1558
- if (sizePairs?.[0]) {
1559
- const [fontSize$1, height, letterSpacing] = sizePairs;
1560
- if (typeof height === "object") return {
1561
- "font-size": fontSize$1,
1562
- ...height
1563
- };
1564
- return {
1565
- "font-size": fontSize$1,
1566
- "line-height": lineHeight ?? height ?? "1",
1567
- "letter-spacing": letterSpacing ? handleThemeByKey(letterSpacing, theme, "letterSpacing") : void 0
1568
- };
1569
- }
1570
- const fontSize = h.bracketOfLength.rem(size);
1571
- if (lineHeight && fontSize) return {
1572
- "font-size": fontSize,
1573
- "line-height": lineHeight
1574
- };
1575
- return { "font-size": h.bracketOfLength.rem(s) };
1576
- }
1577
-
1578
- //#endregion
1579
- //#region src/_rules/variables.ts
1580
- const variablesAbbrMap = {
1581
- backface: "backface-visibility",
1582
- break: "word-break",
1583
- case: "text-transform",
1584
- content: "align-content",
1585
- fw: "font-weight",
1586
- items: "align-items",
1587
- justify: "justify-content",
1588
- select: "user-select",
1589
- self: "align-self",
1590
- vertical: "vertical-align",
1591
- visible: "visibility",
1592
- whitespace: "white-space",
1593
- ws: "white-space"
1594
- };
1595
- const cssVariables = [[/^(.+?)-(\$.+)$/, ([, name, varname]) => {
1596
- const prop = variablesAbbrMap[name];
1597
- if (prop) return { [prop]: h.cssvar(varname) };
1598
- }]];
1599
- const cssProperty = [[/^\[(.*)\]$/, ([_, body]) => {
1600
- if (!body.includes(":")) return;
1601
- const [prop, ...rest] = body.split(":");
1602
- const value = rest.join(":");
1603
- if (!isURI(body) && /^[\w-]+$/.test(prop) && isValidCSSBody(value)) {
1604
- const parsed = h.bracket(`[${value}]`);
1605
- if (parsed) return { [prop]: parsed };
1606
- }
1607
- }]];
1608
- function isValidCSSBody(body) {
1609
- let i = 0;
1610
- function findUntil(c) {
1611
- while (i < body.length) {
1612
- i += 1;
1613
- if (body[i] === c) return true;
1614
- }
1615
- return false;
1616
- }
1617
- for (i = 0; i < body.length; i++) {
1618
- const c = body[i];
1619
- if ("\"`'".includes(c)) {
1620
- if (!findUntil(c)) return false;
1621
- } else if (c === "(") {
1622
- if (!findUntil(")")) return false;
1623
- } else if ("[]{}:".includes(c)) return false;
1624
- }
1625
- return true;
1626
- }
1627
- function isURI(declaration) {
1628
- if (!declaration.includes("://")) return false;
1629
- try {
1630
- return new URL(declaration).host !== "";
1631
- } catch {
1632
- return false;
1633
- }
1634
- }
1635
-
1636
- //#endregion
1637
- //#region src/_rules/default.ts
1638
- const rules = [
1639
- cssVariables,
1640
- cssProperty,
1641
- contains,
1642
- pointerEvents,
1643
- appearances,
1644
- positions,
1645
- insets,
1646
- zIndexes,
1647
- orders,
1648
- grids,
1649
- floats,
1650
- margins,
1651
- boxSizing,
1652
- displays,
1653
- aspectRatio,
1654
- sizes,
1655
- flex,
1656
- transforms,
1657
- cursors,
1658
- userSelects,
1659
- resizes,
1660
- appearance,
1661
- placements,
1662
- alignments,
1663
- justifies,
1664
- gaps,
1665
- flexGridJustifiesAlignments,
1666
- overflows,
1667
- textOverflows,
1668
- whitespaces,
1669
- breaks,
1670
- borders,
1671
- bgColors,
1672
- colorScheme,
1673
- svgUtilities,
1674
- paddings,
1675
- textAligns,
1676
- textIndents,
1677
- textWraps,
1678
- verticalAligns,
1679
- fonts,
1680
- textTransforms,
1681
- fontStyles,
1682
- textDecorations,
1683
- fontSmoothings,
1684
- tabSizes,
1685
- textStrokes,
1686
- textShadows,
1687
- opacity,
1688
- boxShadows,
1689
- outline,
1690
- rings,
1691
- transitions,
1692
- willChange,
1693
- contentVisibility,
1694
- contents,
1695
- containerParent,
1696
- fieldSizing,
1697
- questionMark
1698
- ].flat(1);
1699
-
1700
- //#endregion
1701
- export { flex as $, fontStyles as A, alignments as B, contains as C, displays as D, cursors as E, textWraps as F, justifies as G, flexGridJustifiesAlignments as H, userSelects as I, positions as J, orders as K, varEmpty as L, resizes as M, textOverflows as N, fieldSizing as O, textTransforms as P, gaps as Q, whitespaces as R, breaks as S, contents as T, floats as U, boxSizing as V, insets as W, overflows as X, zIndexes as Y, grids as Z, boxShadows as _, tabSizes as a, borderStyles as at, rings as b, textStrokes as c, appearance as ct, transforms as d, textAligns as dt, textDecorations as et, svgUtilities as f, verticalAligns as ft, sizes as g, aspectRatio as h, fonts as i, opacity as it, pointerEvents as j, fontSmoothings as k, transitions as l, outline as lt, paddings as m, cssProperty as n, bgColors as nt, textIndents as o, borders as ot, margins as p, placements as q, cssVariables as r, colorScheme as rt, textShadows as s, handlerBorderStyle as st, rules as t, containerParent as tt, transformBase as u, willChange as ut, boxShadowsBase as v, contentVisibility as w, appearances as x, ringBase as y, questionMark as z };