@unocss/preset-mini 0.58.9 → 0.59.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.
@@ -1,1033 +0,0 @@
1
- 'use strict';
2
-
3
- const utilities = require('./preset-mini.DahJgnb1.cjs');
4
- const ruleUtils = require('@unocss/rule-utils');
5
- const core = require('@unocss/core');
6
- const transform = require('./preset-mini.mjThnwTD.cjs');
7
-
8
- const verticalAlignAlias = {
9
- "mid": "middle",
10
- "base": "baseline",
11
- "btm": "bottom",
12
- "baseline": "baseline",
13
- "top": "top",
14
- "start": "top",
15
- "middle": "middle",
16
- "bottom": "bottom",
17
- "end": "bottom",
18
- "text-top": "text-top",
19
- "text-bottom": "text-bottom",
20
- "sub": "sub",
21
- "super": "super",
22
- ...Object.fromEntries(utilities.globalKeywords.map((x) => [x, x]))
23
- };
24
- const verticalAligns = [
25
- [
26
- /^(?:vertical|align|v)-([-\w]+%?)$/,
27
- ([, v]) => ({ "vertical-align": verticalAlignAlias[v] ?? utilities.h.numberWithUnit(v) }),
28
- {
29
- autocomplete: [
30
- `(vertical|align|v)-(${Object.keys(verticalAlignAlias).join("|")})`,
31
- "(vertical|align|v)-<percentage>"
32
- ]
33
- }
34
- ]
35
- ];
36
- const textAligns = ["center", "left", "right", "justify", "start", "end"].map((v) => [`text-${v}`, { "text-align": v }]);
37
-
38
- const outline = [
39
- // size
40
- [/^outline-(?:width-|size-)?(.+)$/, handleWidth$2, { autocomplete: "outline-(width|size)-<num>" }],
41
- // color
42
- [/^outline-(?:color-)?(.+)$/, handleColorOrWidth$2, { autocomplete: "outline-$colors" }],
43
- // offset
44
- [/^outline-offset-(.+)$/, ([, d], { theme }) => ({ "outline-offset": theme.lineWidth?.[d] ?? utilities.h.bracket.cssvar.global.px(d) }), { autocomplete: "outline-(offset)-<num>" }],
45
- // style
46
- ["outline", { "outline-style": "solid" }],
47
- ...["auto", "dashed", "dotted", "double", "hidden", "solid", "groove", "ridge", "inset", "outset", ...utilities.globalKeywords].map((v) => [`outline-${v}`, { "outline-style": v }]),
48
- ["outline-none", { "outline": "2px solid transparent", "outline-offset": "2px" }]
49
- ];
50
- function handleWidth$2([, b], { theme }) {
51
- return { "outline-width": theme.lineWidth?.[b] ?? utilities.h.bracket.cssvar.global.px(b) };
52
- }
53
- function handleColorOrWidth$2(match, ctx) {
54
- if (utilities.isCSSMathFn(utilities.h.bracket(match[1])))
55
- return handleWidth$2(match, ctx);
56
- return utilities.colorResolver("outline-color", "outline-color", "borderColor")(match, ctx);
57
- }
58
- const appearance = [
59
- ["appearance-auto", { "-webkit-appearance": "auto", "appearance": "auto" }],
60
- ["appearance-none", { "-webkit-appearance": "none", "appearance": "none" }]
61
- ];
62
- function willChangeProperty(prop) {
63
- return utilities.h.properties.auto.global(prop) ?? {
64
- contents: "contents",
65
- scroll: "scroll-position"
66
- }[prop];
67
- }
68
- const willChange = [
69
- [/^will-change-(.+)/, ([, p]) => ({ "will-change": willChangeProperty(p) })]
70
- ];
71
-
72
- const borderStyles = ["solid", "dashed", "dotted", "double", "hidden", "none", "groove", "ridge", "inset", "outset", ...utilities.globalKeywords];
73
- const borders = [
74
- // compound
75
- [/^(?:border|b)()(?:-(.+))?$/, handlerBorderSize, { autocomplete: "(border|b)-<directions>" }],
76
- [/^(?:border|b)-([xy])(?:-(.+))?$/, handlerBorderSize],
77
- [/^(?:border|b)-([rltbse])(?:-(.+))?$/, handlerBorderSize],
78
- [/^(?:border|b)-(block|inline)(?:-(.+))?$/, handlerBorderSize],
79
- [/^(?:border|b)-([bi][se])(?:-(.+))?$/, handlerBorderSize],
80
- // size
81
- [/^(?:border|b)-()(?:width|size)-(.+)$/, handlerBorderSize, { autocomplete: ["(border|b)-<num>", "(border|b)-<directions>-<num>"] }],
82
- [/^(?:border|b)-([xy])-(?:width|size)-(.+)$/, handlerBorderSize],
83
- [/^(?:border|b)-([rltbse])-(?:width|size)-(.+)$/, handlerBorderSize],
84
- [/^(?:border|b)-(block|inline)-(?:width|size)-(.+)$/, handlerBorderSize],
85
- [/^(?:border|b)-([bi][se])-(?:width|size)-(.+)$/, handlerBorderSize],
86
- // colors
87
- [/^(?:border|b)-()(?:color-)?(.+)$/, handlerBorderColorOrSize, { autocomplete: ["(border|b)-$colors", "(border|b)-<directions>-$colors"] }],
88
- [/^(?:border|b)-([xy])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
89
- [/^(?:border|b)-([rltbse])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
90
- [/^(?:border|b)-(block|inline)-(?:color-)?(.+)$/, handlerBorderColorOrSize],
91
- [/^(?:border|b)-([bi][se])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
92
- // opacity
93
- [/^(?:border|b)-()op(?:acity)?-?(.+)$/, handlerBorderOpacity, { autocomplete: "(border|b)-(op|opacity)-<percent>" }],
94
- [/^(?:border|b)-([xy])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
95
- [/^(?:border|b)-([rltbse])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
96
- [/^(?:border|b)-(block|inline)-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
97
- [/^(?:border|b)-([bi][se])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
98
- // radius
99
- [/^(?:border-|b-)?(?:rounded|rd)()(?:-(.+))?$/, handlerRounded, { autocomplete: ["(border|b)-(rounded|rd)", "(border|b)-(rounded|rd)-<num>", "(rounded|rd)", "(rounded|rd)-<num>"] }],
100
- [/^(?:border-|b-)?(?:rounded|rd)-([rltbse])(?:-(.+))?$/, handlerRounded],
101
- [/^(?:border-|b-)?(?:rounded|rd)-([rltb]{2})(?:-(.+))?$/, handlerRounded],
102
- [/^(?:border-|b-)?(?:rounded|rd)-([bise][se])(?:-(.+))?$/, handlerRounded],
103
- [/^(?:border-|b-)?(?:rounded|rd)-([bi][se]-[bi][se])(?:-(.+))?$/, handlerRounded],
104
- // style
105
- [/^(?:border|b)-(?:style-)?()(.+)$/, handlerBorderStyle, { autocomplete: ["(border|b)-style", `(border|b)-(${borderStyles.join("|")})`, "(border|b)-<directions>-style", `(border|b)-<directions>-(${borderStyles.join("|")})`, `(border|b)-<directions>-style-(${borderStyles.join("|")})`, `(border|b)-style-(${borderStyles.join("|")})`] }],
106
- [/^(?:border|b)-([xy])-(?:style-)?(.+)$/, handlerBorderStyle],
107
- [/^(?:border|b)-([rltbse])-(?:style-)?(.+)$/, handlerBorderStyle],
108
- [/^(?:border|b)-(block|inline)-(?:style-)?(.+)$/, handlerBorderStyle],
109
- [/^(?:border|b)-([bi][se])-(?:style-)?(.+)$/, handlerBorderStyle]
110
- ];
111
- function transformBorderColor(color, alpha, direction) {
112
- if (alpha != null) {
113
- return {
114
- [`border${direction}-color`]: ruleUtils.colorToString(color, alpha)
115
- };
116
- }
117
- if (direction === "") {
118
- const object = {};
119
- const opacityVar = `--un-border-opacity`;
120
- const result = ruleUtils.colorToString(color, `var(${opacityVar})`);
121
- if (result.includes(opacityVar))
122
- object[opacityVar] = typeof color === "string" ? 1 : ruleUtils.colorOpacityToString(color);
123
- object["border-color"] = result;
124
- return object;
125
- } else {
126
- const object = {};
127
- const opacityVar = "--un-border-opacity";
128
- const opacityDirectionVar = `--un-border${direction}-opacity`;
129
- const result = ruleUtils.colorToString(color, `var(${opacityDirectionVar})`);
130
- if (result.includes(opacityDirectionVar)) {
131
- object[opacityVar] = typeof color === "string" ? 1 : ruleUtils.colorOpacityToString(color);
132
- object[opacityDirectionVar] = `var(${opacityVar})`;
133
- }
134
- object[`border${direction}-color`] = result;
135
- return object;
136
- }
137
- }
138
- function borderColorResolver(direction) {
139
- return ([, body], theme) => {
140
- const data = utilities.parseColor(body, theme, "borderColor");
141
- if (!data)
142
- return;
143
- const { alpha, color, cssColor } = data;
144
- if (cssColor)
145
- return transformBorderColor(cssColor, alpha, direction);
146
- else if (color)
147
- return transformBorderColor(color, alpha, direction);
148
- };
149
- }
150
- function handlerBorderSize([, a = "", b], { theme }) {
151
- const v = theme.lineWidth?.[b || "DEFAULT"] ?? utilities.h.bracket.cssvar.global.px(b || "1");
152
- if (a in utilities.directionMap && v != null)
153
- return utilities.directionMap[a].map((i) => [`border${i}-width`, v]);
154
- }
155
- function handlerBorderColorOrSize([, a = "", b], ctx) {
156
- if (a in utilities.directionMap) {
157
- if (utilities.isCSSMathFn(utilities.h.bracket(b)))
158
- return handlerBorderSize(["", a, b], ctx);
159
- if (utilities.hasParseableColor(b, ctx.theme, "borderColor")) {
160
- return Object.assign(
161
- {},
162
- ...utilities.directionMap[a].map((i) => borderColorResolver(i)(["", b], ctx.theme))
163
- );
164
- }
165
- }
166
- }
167
- function handlerBorderOpacity([, a = "", opacity]) {
168
- const v = utilities.h.bracket.percent.cssvar(opacity);
169
- if (a in utilities.directionMap && v != null)
170
- return utilities.directionMap[a].map((i) => [`--un-border${i}-opacity`, v]);
171
- }
172
- function handlerRounded([, a = "", s], { theme }) {
173
- const v = theme.borderRadius?.[s || "DEFAULT"] || utilities.h.bracket.cssvar.global.fraction.rem(s || "1");
174
- if (a in utilities.cornerMap && v != null)
175
- return utilities.cornerMap[a].map((i) => [`border${i}-radius`, v]);
176
- }
177
- function handlerBorderStyle([, a = "", s]) {
178
- if (borderStyles.includes(s) && a in utilities.directionMap)
179
- return utilities.directionMap[a].map((i) => [`border${i}-style`, s]);
180
- }
181
-
182
- const opacity = [
183
- [/^op(?:acity)?-?(.+)$/, ([, d]) => ({ opacity: utilities.h.bracket.percent.cssvar(d) })]
184
- ];
185
- const bgUrlRE = /^\[url\(.+\)\]$/;
186
- const bgLengthRE = /^\[(length|size):.+\]$/;
187
- const bgPositionRE = /^\[position:.+\]$/;
188
- const bgGradientRE = /^\[(linear|conic|radial)-gradient\(.+\)\]$/;
189
- const bgColors = [
190
- [/^bg-(.+)$/, (...args) => {
191
- const d = args[0][1];
192
- if (bgUrlRE.test(d))
193
- return { "--un-url": utilities.h.bracket(d), "background-image": "var(--un-url)" };
194
- if (bgLengthRE.test(d) && utilities.h.bracketOfLength(d) != null)
195
- return { "background-size": utilities.h.bracketOfLength(d).split(" ").map((e) => utilities.h.fraction.auto.px.cssvar(e) ?? e).join(" ") };
196
- if ((utilities.isSize(d) || bgPositionRE.test(d)) && utilities.h.bracketOfPosition(d) != null)
197
- return { "background-position": utilities.h.bracketOfPosition(d).split(" ").map((e) => utilities.h.position.fraction.auto.px.cssvar(e) ?? e).join(" ") };
198
- if (bgGradientRE.test(d))
199
- return { "background-image": utilities.h.bracket(d) };
200
- return utilities.colorResolver("background-color", "bg", "backgroundColor")(...args);
201
- }, { autocomplete: "bg-$colors" }],
202
- [/^bg-op(?:acity)?-?(.+)$/, ([, opacity2]) => ({ "--un-bg-opacity": utilities.h.bracket.percent.cssvar(opacity2) }), { autocomplete: "bg-(op|opacity)-<percent>" }]
203
- ];
204
- const colorScheme = [
205
- [/^color-scheme-(\w+)$/, ([, v]) => ({ "color-scheme": v })]
206
- ];
207
-
208
- const containerParent = [
209
- [/^@container(?:\/(\w+))?(?:-(normal))?$/, ([, l, v]) => {
210
- core.warnOnce("The container query rule is experimental and may not follow semver.");
211
- return {
212
- "container-type": v ?? "inline-size",
213
- "container-name": l
214
- };
215
- }]
216
- ];
217
-
218
- const decorationStyles = ["solid", "double", "dotted", "dashed", "wavy", ...utilities.globalKeywords];
219
- const textDecorations = [
220
- [/^(?:decoration-)?(underline|overline|line-through)$/, ([, s]) => ({ "text-decoration-line": s }), { autocomplete: "decoration-(underline|overline|line-through)" }],
221
- // size
222
- [/^(?:underline|decoration)-(?:size-)?(.+)$/, handleWidth$1, { autocomplete: "(underline|decoration)-<num>" }],
223
- [/^(?:underline|decoration)-(auto|from-font)$/, ([, s]) => ({ "text-decoration-thickness": s }), { autocomplete: "(underline|decoration)-(auto|from-font)" }],
224
- // colors
225
- [/^(?:underline|decoration)-(.+)$/, handleColorOrWidth$1, { autocomplete: "(underline|decoration)-$colors" }],
226
- [/^(?:underline|decoration)-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-line-opacity": utilities.h.bracket.percent.cssvar(opacity) }), { autocomplete: "(underline|decoration)-(op|opacity)-<percent>" }],
227
- // offset
228
- [/^(?:underline|decoration)-offset-(.+)$/, ([, s], { theme }) => ({ "text-underline-offset": theme.lineWidth?.[s] ?? utilities.h.auto.bracket.cssvar.global.px(s) }), { autocomplete: "(underline|decoration)-(offset)-<num>" }],
229
- // style
230
- ...decorationStyles.map((v) => [`underline-${v}`, { "text-decoration-style": v }]),
231
- ...decorationStyles.map((v) => [`decoration-${v}`, { "text-decoration-style": v }]),
232
- ["no-underline", { "text-decoration": "none" }],
233
- ["decoration-none", { "text-decoration": "none" }]
234
- ];
235
- function handleWidth$1([, b], { theme }) {
236
- return { "text-decoration-thickness": theme.lineWidth?.[b] ?? utilities.h.bracket.cssvar.global.px(b) };
237
- }
238
- function handleColorOrWidth$1(match, ctx) {
239
- if (utilities.isCSSMathFn(utilities.h.bracket(match[1])))
240
- return handleWidth$1(match, ctx);
241
- const result = utilities.colorResolver("text-decoration-color", "line", "borderColor")(match, ctx);
242
- if (result) {
243
- return {
244
- "-webkit-text-decoration-color": result["text-decoration-color"],
245
- ...result
246
- };
247
- }
248
- }
249
-
250
- const transitionPropertyGroup = {
251
- all: "all",
252
- colors: ["color", "background-color", "border-color", "outline-color", "text-decoration-color", "fill", "stroke"].join(","),
253
- none: "none",
254
- opacity: "opacity",
255
- shadow: "box-shadow",
256
- transform: "transform"
257
- };
258
- function transitionProperty(prop) {
259
- return utilities.h.properties(prop) ?? transitionPropertyGroup[prop];
260
- }
261
- const transitions = [
262
- // transition
263
- [
264
- /^transition(?:-([a-z-]+(?:,[a-z-]+)*))?(?:-(\d+))?$/,
265
- ([, prop, d], { theme }) => {
266
- const p = prop != null ? transitionProperty(prop) : [transitionPropertyGroup.colors, "opacity", "box-shadow", "transform", "filter", "backdrop-filter"].join(",");
267
- if (p) {
268
- const duration = theme.duration?.[d || "DEFAULT"] ?? utilities.h.time(d || "150");
269
- return {
270
- "transition-property": p,
271
- "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)",
272
- "transition-duration": duration
273
- };
274
- }
275
- },
276
- { autocomplete: `transition-(${Object.keys(transitionPropertyGroup).join("|")})` }
277
- ],
278
- // timings
279
- [
280
- /^(?:transition-)?duration-(.+)$/,
281
- ([, d], { theme }) => ({ "transition-duration": theme.duration?.[d || "DEFAULT"] ?? utilities.h.bracket.cssvar.time(d) }),
282
- { autocomplete: ["transition-duration-$duration", "duration-$duration"] }
283
- ],
284
- [
285
- /^(?:transition-)?delay-(.+)$/,
286
- ([, d], { theme }) => ({ "transition-delay": theme.duration?.[d || "DEFAULT"] ?? utilities.h.bracket.cssvar.time(d) }),
287
- { autocomplete: ["transition-delay-$duration", "delay-$duration"] }
288
- ],
289
- [
290
- /^(?:transition-)?ease(?:-(.+))?$/,
291
- ([, d], { theme }) => ({ "transition-timing-function": theme.easing?.[d || "DEFAULT"] ?? utilities.h.bracket.cssvar(d) }),
292
- { autocomplete: ["transition-ease-(linear|in|out|in-out|DEFAULT)", "ease-(linear|in|out|in-out|DEFAULT)"] }
293
- ],
294
- // props
295
- [
296
- /^(?:transition-)?property-(.+)$/,
297
- ([, v]) => ({ "transition-property": utilities.h.bracket.global(v) || transitionProperty(v) }),
298
- { autocomplete: [`transition-property-(${[...utilities.globalKeywords, ...Object.keys(transitionPropertyGroup)].join("|")})`] }
299
- ],
300
- // none
301
- ["transition-none", { transition: "none" }],
302
- ...utilities.makeGlobalStaticRules("transition")
303
- ];
304
-
305
- const flex = [
306
- // display
307
- ["flex", { display: "flex" }],
308
- ["inline-flex", { display: "inline-flex" }],
309
- ["flex-inline", { display: "inline-flex" }],
310
- // flex
311
- [/^flex-(.*)$/, ([, d]) => ({ flex: utilities.h.bracket(d) != null ? utilities.h.bracket(d).split(" ").map((e) => utilities.h.cssvar.fraction(e) ?? e).join(" ") : utilities.h.cssvar.fraction(d) })],
312
- ["flex-1", { flex: "1 1 0%" }],
313
- ["flex-auto", { flex: "1 1 auto" }],
314
- ["flex-initial", { flex: "0 1 auto" }],
315
- ["flex-none", { flex: "none" }],
316
- // shrink/grow/basis
317
- [/^(?:flex-)?shrink(?:-(.*))?$/, ([, d = ""]) => ({ "flex-shrink": utilities.h.bracket.cssvar.number(d) ?? 1 }), { autocomplete: ["flex-shrink-<num>", "shrink-<num>"] }],
318
- [/^(?:flex-)?grow(?:-(.*))?$/, ([, d = ""]) => ({ "flex-grow": utilities.h.bracket.cssvar.number(d) ?? 1 }), { autocomplete: ["flex-grow-<num>", "grow-<num>"] }],
319
- [/^(?:flex-)?basis-(.+)$/, ([, d], { theme }) => ({ "flex-basis": theme.spacing?.[d] ?? utilities.h.bracket.cssvar.auto.fraction.rem(d) }), { autocomplete: ["flex-basis-$spacing", "basis-$spacing"] }],
320
- // directions
321
- ["flex-row", { "flex-direction": "row" }],
322
- ["flex-row-reverse", { "flex-direction": "row-reverse" }],
323
- ["flex-col", { "flex-direction": "column" }],
324
- ["flex-col-reverse", { "flex-direction": "column-reverse" }],
325
- // wraps
326
- ["flex-wrap", { "flex-wrap": "wrap" }],
327
- ["flex-wrap-reverse", { "flex-wrap": "wrap-reverse" }],
328
- ["flex-nowrap", { "flex-wrap": "nowrap" }]
329
- ];
330
-
331
- const fonts = [
332
- // text
333
- [/^text-(.+)$/, handleText, { autocomplete: "text-$fontSize" }],
334
- // text size
335
- [/^(?:text|font)-size-(.+)$/, handleSize, { autocomplete: "text-size-$fontSize" }],
336
- // text colors
337
- [/^text-(?:color-)?(.+)$/, handlerColorOrSize, { autocomplete: "text-$colors" }],
338
- // colors
339
- [/^(?:color|c)-(.+)$/, utilities.colorResolver("color", "text", "textColor"), { autocomplete: "(color|c)-$colors" }],
340
- // style
341
- [/^(?:text|color|c)-(.+)$/, ([, v]) => utilities.globalKeywords.includes(v) ? { color: v } : void 0, { autocomplete: `(text|color|c)-(${utilities.globalKeywords.join("|")})` }],
342
- // opacity
343
- [/^(?:text|color|c)-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-text-opacity": utilities.h.bracket.percent.cssvar(opacity) }), { autocomplete: "(text|color|c)-(op|opacity)-<percent>" }],
344
- // weights
345
- [
346
- /^(?:font|fw)-?([^-]+)$/,
347
- ([, s], { theme }) => ({ "font-weight": theme.fontWeight?.[s] || utilities.h.bracket.global.number(s) }),
348
- {
349
- autocomplete: [
350
- "(font|fw)-(100|200|300|400|500|600|700|800|900)",
351
- "(font|fw)-$fontWeight"
352
- ]
353
- }
354
- ],
355
- // leadings
356
- [
357
- /^(?:font-)?(?:leading|lh|line-height)-(.+)$/,
358
- ([, s], { theme }) => ({ "line-height": handleThemeByKey(s, theme, "lineHeight") }),
359
- { autocomplete: "(leading|lh|line-height)-$lineHeight" }
360
- ],
361
- // synthesis
362
- ["font-synthesis-weight", { "font-synthesis": "weight" }],
363
- ["font-synthesis-style", { "font-synthesis": "style" }],
364
- ["font-synthesis-small-caps", { "font-synthesis": "small-caps" }],
365
- ["font-synthesis-none", { "font-synthesis": "none" }],
366
- [/^font-synthesis-(.+)$/, ([, s]) => ({ "font-synthesis": utilities.h.bracket.cssvar.global(s) })],
367
- // tracking
368
- [
369
- /^(?:font-)?tracking-(.+)$/,
370
- ([, s], { theme }) => ({ "letter-spacing": theme.letterSpacing?.[s] || utilities.h.bracket.cssvar.global.rem(s) }),
371
- { autocomplete: "tracking-$letterSpacing" }
372
- ],
373
- // word-spacing
374
- [
375
- /^(?:font-)?word-spacing-(.+)$/,
376
- ([, s], { theme }) => ({ "word-spacing": theme.wordSpacing?.[s] || utilities.h.bracket.cssvar.global.rem(s) }),
377
- { autocomplete: "word-spacing-$wordSpacing" }
378
- ],
379
- // stretch
380
- ["font-stretch-normal", { "font-stretch": "normal" }],
381
- ["font-stretch-ultra-condensed", { "font-stretch": "ultra-condensed" }],
382
- ["font-stretch-extra-condensed", { "font-stretch": "extra-condensed" }],
383
- ["font-stretch-condensed", { "font-stretch": "condensed" }],
384
- ["font-stretch-semi-condensed", { "font-stretch": "semi-condensed" }],
385
- ["font-stretch-semi-expanded", { "font-stretch": "semi-expanded" }],
386
- ["font-stretch-expanded", { "font-stretch": "expanded" }],
387
- ["font-stretch-extra-expanded", { "font-stretch": "extra-expanded" }],
388
- ["font-stretch-ultra-expanded", { "font-stretch": "ultra-expanded" }],
389
- [
390
- /^font-stretch-(.+)$/,
391
- ([, s]) => ({ "font-stretch": utilities.h.bracket.cssvar.fraction.global(s) }),
392
- { autocomplete: "font-stretch-<percentage>" }
393
- ],
394
- // family
395
- [
396
- /^font-(.+)$/,
397
- ([, d], { theme }) => ({ "font-family": theme.fontFamily?.[d] || utilities.h.bracket.cssvar.global(d) }),
398
- { autocomplete: "font-$fontFamily" }
399
- ]
400
- ];
401
- const tabSizes = [
402
- [/^tab(?:-(.+))?$/, ([, s]) => {
403
- const v = utilities.h.bracket.cssvar.global.number(s || "4");
404
- if (v != null) {
405
- return {
406
- "-moz-tab-size": v,
407
- "-o-tab-size": v,
408
- "tab-size": v
409
- };
410
- }
411
- }]
412
- ];
413
- const textIndents = [
414
- [/^indent(?:-(.+))?$/, ([, s], { theme }) => ({ "text-indent": theme.textIndent?.[s || "DEFAULT"] || utilities.h.bracket.cssvar.global.fraction.rem(s) }), { autocomplete: "indent-$textIndent" }]
415
- ];
416
- const textStrokes = [
417
- // widths
418
- [/^text-stroke(?:-(.+))?$/, ([, s], { theme }) => ({ "-webkit-text-stroke-width": theme.textStrokeWidth?.[s || "DEFAULT"] || utilities.h.bracket.cssvar.px(s) }), { autocomplete: "text-stroke-$textStrokeWidth" }],
419
- // colors
420
- [/^text-stroke-(.+)$/, utilities.colorResolver("-webkit-text-stroke-color", "text-stroke", "borderColor"), { autocomplete: "text-stroke-$colors" }],
421
- [/^text-stroke-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-text-stroke-opacity": utilities.h.bracket.percent.cssvar(opacity) }), { autocomplete: "text-stroke-(op|opacity)-<percent>" }]
422
- ];
423
- const textShadows = [
424
- [/^text-shadow(?:-(.+))?$/, ([, s], { theme }) => {
425
- const v = theme.textShadow?.[s || "DEFAULT"];
426
- if (v != null) {
427
- return {
428
- "--un-text-shadow": utilities.colorableShadows(v, "--un-text-shadow-color").join(","),
429
- "text-shadow": "var(--un-text-shadow)"
430
- };
431
- }
432
- return { "text-shadow": utilities.h.bracket.cssvar.global(s) };
433
- }, { autocomplete: "text-shadow-$textShadow" }],
434
- // colors
435
- [/^text-shadow-color-(.+)$/, utilities.colorResolver("--un-text-shadow-color", "text-shadow", "shadowColor"), { autocomplete: "text-shadow-color-$colors" }],
436
- [/^text-shadow-color-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-text-shadow-opacity": utilities.h.bracket.percent.cssvar(opacity) }), { autocomplete: "text-shadow-color-(op|opacity)-<percent>" }]
437
- ];
438
- function handleThemeByKey(s, theme, key) {
439
- return theme[key]?.[s] || utilities.h.bracket.cssvar.global.rem(s);
440
- }
441
- function handleSize([, s], { theme }) {
442
- const themed = core.toArray(theme.fontSize?.[s]);
443
- const size = themed?.[0] ?? utilities.h.bracket.cssvar.global.rem(s);
444
- if (size != null)
445
- return { "font-size": size };
446
- }
447
- function handlerColorOrSize(match, ctx) {
448
- if (utilities.isCSSMathFn(utilities.h.bracket(match[1])))
449
- return handleSize(match, ctx);
450
- return utilities.colorResolver("color", "text", "textColor")(match, ctx);
451
- }
452
- function handleText([, s = "base"], { theme }) {
453
- const split = utilities.splitShorthand(s, "length");
454
- if (!split)
455
- return;
456
- const [size, leading] = split;
457
- const sizePairs = core.toArray(theme.fontSize?.[size]);
458
- const lineHeight = leading ? handleThemeByKey(leading, theme, "lineHeight") : void 0;
459
- if (sizePairs?.[0]) {
460
- const [fontSize2, height, letterSpacing] = sizePairs;
461
- if (typeof height === "object") {
462
- return {
463
- "font-size": fontSize2,
464
- ...height
465
- };
466
- }
467
- return {
468
- "font-size": fontSize2,
469
- "line-height": lineHeight ?? height ?? "1",
470
- "letter-spacing": letterSpacing ? handleThemeByKey(letterSpacing, theme, "letterSpacing") : void 0
471
- };
472
- }
473
- const fontSize = utilities.h.bracketOfLength.rem(size);
474
- if (lineHeight && fontSize) {
475
- return {
476
- "font-size": fontSize,
477
- "line-height": lineHeight
478
- };
479
- }
480
- return { "font-size": utilities.h.bracketOfLength.rem(s) };
481
- }
482
-
483
- const directions = {
484
- "": "",
485
- "x": "column-",
486
- "y": "row-",
487
- "col": "column-",
488
- "row": "row-"
489
- };
490
- function handleGap([, d = "", s], { theme }) {
491
- const v = theme.spacing?.[s] ?? utilities.h.bracket.cssvar.global.rem(s);
492
- if (v != null) {
493
- return {
494
- [`${directions[d]}gap`]: v
495
- };
496
- }
497
- }
498
- const gaps = [
499
- [/^(?:flex-|grid-)?gap-?()(.+)$/, handleGap, { autocomplete: ["gap-$spacing", "gap-<num>"] }],
500
- [/^(?:flex-|grid-)?gap-([xy])-?(.+)$/, handleGap, { autocomplete: ["gap-(x|y)-$spacing", "gap-(x|y)-<num>"] }],
501
- [/^(?:flex-|grid-)?gap-(col|row)-?(.+)$/, handleGap, { autocomplete: ["gap-(col|row)-$spacing", "gap-(col|row)-<num>"] }]
502
- ];
503
-
504
- function rowCol(s) {
505
- return s.replace("col", "column");
506
- }
507
- function rowColTheme(s) {
508
- return s[0] === "r" ? "Row" : "Column";
509
- }
510
- function autoDirection(c, theme, prop) {
511
- const v = theme[`gridAuto${rowColTheme(c)}`]?.[prop];
512
- if (v != null)
513
- return v;
514
- switch (prop) {
515
- case "min":
516
- return "min-content";
517
- case "max":
518
- return "max-content";
519
- case "fr":
520
- return "minmax(0,1fr)";
521
- }
522
- return utilities.h.bracket.cssvar.auto.rem(prop);
523
- }
524
- const grids = [
525
- // displays
526
- ["grid", { display: "grid" }],
527
- ["inline-grid", { display: "inline-grid" }],
528
- // global
529
- [/^(?:grid-)?(row|col)-(.+)$/, ([, c, v], { theme }) => ({
530
- [`grid-${rowCol(c)}`]: theme[`grid${rowColTheme(c)}`]?.[v] ?? utilities.h.bracket.cssvar.auto(v)
531
- })],
532
- // span
533
- [/^(?:grid-)?(row|col)-span-(.+)$/, ([, c, s]) => {
534
- if (s === "full")
535
- return { [`grid-${rowCol(c)}`]: "1/-1" };
536
- const v = utilities.h.bracket.number(s);
537
- if (v != null)
538
- return { [`grid-${rowCol(c)}`]: `span ${v}/span ${v}` };
539
- }, { autocomplete: "(grid-row|grid-col|row|col)-span-<num>" }],
540
- // starts & ends
541
- [/^(?:grid-)?(row|col)-start-(.+)$/, ([, c, v]) => ({ [`grid-${rowCol(c)}-start`]: utilities.h.bracket.cssvar(v) ?? v })],
542
- [/^(?:grid-)?(row|col)-end-(.+)$/, ([, c, v]) => ({ [`grid-${rowCol(c)}-end`]: utilities.h.bracket.cssvar(v) ?? v }), { autocomplete: "(grid-row|grid-col|row|col)-(start|end)-<num>" }],
543
- // auto flows
544
- [/^(?:grid-)?auto-(rows|cols)-(.+)$/, ([, c, v], { theme }) => ({ [`grid-auto-${rowCol(c)}`]: autoDirection(c, theme, v) }), { autocomplete: "(grid-auto|auto)-(rows|cols)-<num>" }],
545
- // grid-auto-flow, auto-flow: uno
546
- // grid-flow: wind
547
- [/^(?:grid-auto-flow|auto-flow|grid-flow)-(.+)$/, ([, v]) => ({ "grid-auto-flow": utilities.h.bracket.cssvar(v) })],
548
- [/^(?:grid-auto-flow|auto-flow|grid-flow)-(row|col|dense|row-dense|col-dense)$/, ([, v]) => ({ "grid-auto-flow": rowCol(v).replace("-", " ") }), { autocomplete: ["(grid-auto-flow|auto-flow|grid-flow)-(row|col|dense|row-dense|col-dense)"] }],
549
- // templates
550
- [/^(?:grid-)?(rows|cols)-(.+)$/, ([, c, v], { theme }) => ({
551
- [`grid-template-${rowCol(c)}`]: theme[`gridTemplate${rowColTheme(c)}`]?.[v] ?? utilities.h.bracket.cssvar(v)
552
- })],
553
- [/^(?:grid-)?(rows|cols)-minmax-([\w.-]+)$/, ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(auto-fill,minmax(${d},1fr))` })],
554
- [/^(?:grid-)?(rows|cols)-(\d+)$/, ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(${d},minmax(0,1fr))` }), { autocomplete: "(grid-rows|grid-cols|rows|cols)-<num>" }],
555
- // areas
556
- [/^grid-area(s)?-(.+)$/, ([, s, v]) => {
557
- if (s != null)
558
- return { "grid-template-areas": utilities.h.cssvar(v) ?? v.split("-").map((s2) => `"${utilities.h.bracket(s2)}"`).join(" ") };
559
- return { "grid-area": utilities.h.bracket.cssvar(v) };
560
- }],
561
- // template none
562
- ["grid-rows-none", { "grid-template-rows": "none" }],
563
- ["grid-cols-none", { "grid-template-columns": "none" }],
564
- // template subgrid
565
- ["grid-rows-subgrid", { "grid-template-rows": "subgrid" }],
566
- ["grid-cols-subgrid", { "grid-template-columns": "subgrid" }]
567
- ];
568
-
569
- const overflowValues = [
570
- "auto",
571
- "hidden",
572
- "clip",
573
- "visible",
574
- "scroll",
575
- "overlay",
576
- ...utilities.globalKeywords
577
- ];
578
- const overflows = [
579
- [/^(?:overflow|of)-(.+)$/, ([, v]) => overflowValues.includes(v) ? { overflow: v } : void 0, { autocomplete: [`(overflow|of)-(${overflowValues.join("|")})`, `(overflow|of)-(x|y)-(${overflowValues.join("|")})`] }],
580
- [/^(?:overflow|of)-([xy])-(.+)$/, ([, d, v]) => overflowValues.includes(v) ? { [`overflow-${d}`]: v } : void 0]
581
- ];
582
-
583
- const positions = [
584
- [/^(?:position-|pos-)?(relative|absolute|fixed|sticky)$/, ([, v]) => ({ position: v }), {
585
- autocomplete: [
586
- "(position|pos)-<position>",
587
- "(position|pos)-<globalKeyword>",
588
- "<position>"
589
- ]
590
- }],
591
- [/^(?:position-|pos-)([-\w]+)$/, ([, v]) => utilities.globalKeywords.includes(v) ? { position: v } : void 0],
592
- [/^(?:position-|pos-)?(static)$/, ([, v]) => ({ position: v })]
593
- ];
594
- const justifies = [
595
- // contents
596
- ["justify-start", { "justify-content": "flex-start" }],
597
- ["justify-end", { "justify-content": "flex-end" }],
598
- ["justify-center", { "justify-content": "center" }],
599
- ["justify-between", { "justify-content": "space-between" }],
600
- ["justify-around", { "justify-content": "space-around" }],
601
- ["justify-evenly", { "justify-content": "space-evenly" }],
602
- ["justify-stretch", { "justify-content": "stretch" }],
603
- ["justify-left", { "justify-content": "left" }],
604
- ["justify-right", { "justify-content": "right" }],
605
- ...utilities.makeGlobalStaticRules("justify", "justify-content"),
606
- // items
607
- ["justify-items-start", { "justify-items": "start" }],
608
- ["justify-items-end", { "justify-items": "end" }],
609
- ["justify-items-center", { "justify-items": "center" }],
610
- ["justify-items-stretch", { "justify-items": "stretch" }],
611
- ...utilities.makeGlobalStaticRules("justify-items"),
612
- // selfs
613
- ["justify-self-auto", { "justify-self": "auto" }],
614
- ["justify-self-start", { "justify-self": "start" }],
615
- ["justify-self-end", { "justify-self": "end" }],
616
- ["justify-self-center", { "justify-self": "center" }],
617
- ["justify-self-stretch", { "justify-self": "stretch" }],
618
- ...utilities.makeGlobalStaticRules("justify-self")
619
- ];
620
- const orders = [
621
- [/^order-(.+)$/, ([, v]) => ({ order: utilities.h.bracket.cssvar.number(v) })],
622
- ["order-first", { order: "-9999" }],
623
- ["order-last", { order: "9999" }],
624
- ["order-none", { order: "0" }]
625
- ];
626
- const alignments = [
627
- // contents
628
- ["content-center", { "align-content": "center" }],
629
- ["content-start", { "align-content": "flex-start" }],
630
- ["content-end", { "align-content": "flex-end" }],
631
- ["content-between", { "align-content": "space-between" }],
632
- ["content-around", { "align-content": "space-around" }],
633
- ["content-evenly", { "align-content": "space-evenly" }],
634
- ...utilities.makeGlobalStaticRules("content", "align-content"),
635
- // items
636
- ["items-start", { "align-items": "flex-start" }],
637
- ["items-end", { "align-items": "flex-end" }],
638
- ["items-center", { "align-items": "center" }],
639
- ["items-baseline", { "align-items": "baseline" }],
640
- ["items-stretch", { "align-items": "stretch" }],
641
- ...utilities.makeGlobalStaticRules("items", "align-items"),
642
- // selfs
643
- ["self-auto", { "align-self": "auto" }],
644
- ["self-start", { "align-self": "flex-start" }],
645
- ["self-end", { "align-self": "flex-end" }],
646
- ["self-center", { "align-self": "center" }],
647
- ["self-stretch", { "align-self": "stretch" }],
648
- ["self-baseline", { "align-self": "baseline" }],
649
- ...utilities.makeGlobalStaticRules("self", "align-self")
650
- ];
651
- const placements = [
652
- // contents
653
- ["place-content-center", { "place-content": "center" }],
654
- ["place-content-start", { "place-content": "start" }],
655
- ["place-content-end", { "place-content": "end" }],
656
- ["place-content-between", { "place-content": "space-between" }],
657
- ["place-content-around", { "place-content": "space-around" }],
658
- ["place-content-evenly", { "place-content": "space-evenly" }],
659
- ["place-content-stretch", { "place-content": "stretch" }],
660
- ...utilities.makeGlobalStaticRules("place-content"),
661
- // items
662
- ["place-items-start", { "place-items": "start" }],
663
- ["place-items-end", { "place-items": "end" }],
664
- ["place-items-center", { "place-items": "center" }],
665
- ["place-items-stretch", { "place-items": "stretch" }],
666
- ...utilities.makeGlobalStaticRules("place-items"),
667
- // selfs
668
- ["place-self-auto", { "place-self": "auto" }],
669
- ["place-self-start", { "place-self": "start" }],
670
- ["place-self-end", { "place-self": "end" }],
671
- ["place-self-center", { "place-self": "center" }],
672
- ["place-self-stretch", { "place-self": "stretch" }],
673
- ...utilities.makeGlobalStaticRules("place-self")
674
- ];
675
- const flexGridJustifiesAlignments = [...justifies, ...alignments, ...placements].flatMap(([k, v]) => [
676
- [`flex-${k}`, v],
677
- [`grid-${k}`, v]
678
- ]);
679
- function handleInsetValue(v, { theme }) {
680
- return theme.spacing?.[v] ?? utilities.h.bracket.cssvar.global.auto.fraction.rem(v);
681
- }
682
- function handleInsetValues([, d, v], ctx) {
683
- const r = handleInsetValue(v, ctx);
684
- if (r != null && d in utilities.insetMap)
685
- return utilities.insetMap[d].map((i) => [i.slice(1), r]);
686
- }
687
- const insets = [
688
- [
689
- /^(?:position-|pos-)?inset-(.+)$/,
690
- ([, v], ctx) => ({ inset: handleInsetValue(v, ctx) }),
691
- {
692
- autocomplete: [
693
- "(position|pos)-inset-<directions>-$spacing",
694
- "(position|pos)-inset-(block|inline)-$spacing",
695
- "(position|pos)-inset-(bs|be|is|ie)-$spacing",
696
- "(position|pos)-(top|left|right|bottom)-$spacing"
697
- ]
698
- }
699
- ],
700
- [/^(?:position-|pos-)?(start|end)-(.+)$/, handleInsetValues],
701
- [/^(?:position-|pos-)?inset-([xy])-(.+)$/, handleInsetValues],
702
- [/^(?:position-|pos-)?inset-([rltbse])-(.+)$/, handleInsetValues],
703
- [/^(?:position-|pos-)?inset-(block|inline)-(.+)$/, handleInsetValues],
704
- [/^(?:position-|pos-)?inset-([bi][se])-(.+)$/, handleInsetValues],
705
- [/^(?:position-|pos-)?(top|left|right|bottom)-(.+)$/, ([, d, v], ctx) => ({ [d]: handleInsetValue(v, ctx) })]
706
- ];
707
- const floats = [
708
- // floats
709
- ["float-left", { float: "left" }],
710
- ["float-right", { float: "right" }],
711
- ["float-none", { float: "none" }],
712
- ...utilities.makeGlobalStaticRules("float"),
713
- // clears
714
- ["clear-left", { clear: "left" }],
715
- ["clear-right", { clear: "right" }],
716
- ["clear-both", { clear: "both" }],
717
- ["clear-none", { clear: "none" }],
718
- ...utilities.makeGlobalStaticRules("clear")
719
- ];
720
- const zIndexes = [
721
- [/^(?:position-|pos-)?z([\d.]+)$/, ([, v]) => ({ "z-index": utilities.h.number(v) })],
722
- [/^(?:position-|pos-)?z-(.+)$/, ([, v], { theme }) => ({ "z-index": theme.zIndex?.[v] ?? utilities.h.bracket.cssvar.global.auto.number(v) }), { autocomplete: "z-<num>" }]
723
- ];
724
- const boxSizing = [
725
- ["box-border", { "box-sizing": "border-box" }],
726
- ["box-content", { "box-sizing": "content-box" }],
727
- ...utilities.makeGlobalStaticRules("box", "box-sizing")
728
- ];
729
-
730
- const sizeMapping = {
731
- h: "height",
732
- w: "width",
733
- inline: "inline-size",
734
- block: "block-size"
735
- };
736
- function getPropName(minmax, hw) {
737
- return `${minmax || ""}${sizeMapping[hw]}`;
738
- }
739
- function getSizeValue(minmax, hw, theme, prop) {
740
- const str = getPropName(minmax, hw).replace(/-(\w)/g, (_, p) => p.toUpperCase());
741
- const v = theme[str]?.[prop];
742
- if (v != null)
743
- return v;
744
- switch (prop) {
745
- case "fit":
746
- case "max":
747
- case "min":
748
- return `${prop}-content`;
749
- }
750
- return utilities.h.bracket.cssvar.global.auto.fraction.rem(prop);
751
- }
752
- const sizes = [
753
- [/^size-(min-|max-)?(.+)$/, ([, m, s], { theme }) => ({ [getPropName(m, "w")]: getSizeValue(m, "w", theme, s), [getPropName(m, "h")]: getSizeValue(m, "h", theme, s) })],
754
- [/^(?:size-)?(min-|max-)?([wh])-?(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) })],
755
- [/^(?:size-)?(min-|max-)?(block|inline)-(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) }), {
756
- autocomplete: [
757
- "(w|h)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
758
- "(block|inline)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
759
- "(max|min)-(w|h|block|inline)",
760
- "(max|min)-(w|h|block|inline)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
761
- "(w|h)-full",
762
- "(max|min)-(w|h)-full"
763
- ]
764
- }],
765
- [/^(?:size-)?(min-|max-)?(h)-screen-(.+)$/, ([, m, h2, p], context) => ({ [getPropName(m, h2)]: handleBreakpoint(context, p, "verticalBreakpoints") })],
766
- [/^(?:size-)?(min-|max-)?(w)-screen-(.+)$/, ([, m, w, p], context) => ({ [getPropName(m, w)]: handleBreakpoint(context, p) }), {
767
- autocomplete: [
768
- "(w|h)-screen",
769
- "(min|max)-(w|h)-screen",
770
- "h-screen-$verticalBreakpoints",
771
- "(min|max)-h-screen-$verticalBreakpoints",
772
- "w-screen-$breakpoints",
773
- "(min|max)-w-screen-$breakpoints"
774
- ]
775
- }]
776
- ];
777
- function handleBreakpoint(context, point, key = "breakpoints") {
778
- const bp = utilities.resolveBreakpoints(context, key);
779
- if (bp)
780
- return bp.find((i) => i.point === point)?.size;
781
- }
782
- function getAspectRatio(prop) {
783
- if (/^\d+\/\d+$/.test(prop))
784
- return prop;
785
- switch (prop) {
786
- case "square":
787
- return "1/1";
788
- case "video":
789
- return "16/9";
790
- }
791
- return utilities.h.bracket.cssvar.global.auto.number(prop);
792
- }
793
- const aspectRatio = [
794
- [/^(?:size-)?aspect-(?:ratio-)?(.+)$/, ([, d]) => ({ "aspect-ratio": getAspectRatio(d) }), { autocomplete: ["aspect-(square|video|ratio)", "aspect-ratio-(square|video)"] }]
795
- ];
796
-
797
- const paddings = [
798
- [/^pa?()-?(-?.+)$/, utilities.directionSize("padding"), { autocomplete: ["(m|p)<num>", "(m|p)-<num>"] }],
799
- [/^p-?xy()()$/, utilities.directionSize("padding"), { autocomplete: "(m|p)-(xy)" }],
800
- [/^p-?([xy])(?:-?(-?.+))?$/, utilities.directionSize("padding")],
801
- [/^p-?([rltbse])(?:-?(-?.+))?$/, utilities.directionSize("padding"), { autocomplete: "(m|p)<directions>-<num>" }],
802
- [/^p-(block|inline)(?:-(-?.+))?$/, utilities.directionSize("padding"), { autocomplete: "(m|p)-(block|inline)-<num>" }],
803
- [/^p-?([bi][se])(?:-?(-?.+))?$/, utilities.directionSize("padding"), { autocomplete: "(m|p)-(bs|be|is|ie)-<num>" }]
804
- ];
805
- const margins = [
806
- [/^ma?()-?(-?.+)$/, utilities.directionSize("margin")],
807
- [/^m-?xy()()$/, utilities.directionSize("margin")],
808
- [/^m-?([xy])(?:-?(-?.+))?$/, utilities.directionSize("margin")],
809
- [/^m-?([rltbse])(?:-?(-?.+))?$/, utilities.directionSize("margin")],
810
- [/^m-(block|inline)(?:-(-?.+))?$/, utilities.directionSize("margin")],
811
- [/^m-?([bi][se])(?:-?(-?.+))?$/, utilities.directionSize("margin")]
812
- ];
813
-
814
- const variablesAbbrMap = {
815
- backface: "backface-visibility",
816
- break: "word-break",
817
- case: "text-transform",
818
- content: "align-content",
819
- fw: "font-weight",
820
- items: "align-items",
821
- justify: "justify-content",
822
- select: "user-select",
823
- self: "align-self",
824
- vertical: "vertical-align",
825
- visible: "visibility",
826
- whitespace: "white-space",
827
- ws: "white-space"
828
- };
829
- const cssVariables = [
830
- [/^(.+?)-(\$.+)$/, ([, name, varname]) => {
831
- const prop = variablesAbbrMap[name];
832
- if (prop)
833
- return { [prop]: utilities.h.cssvar(varname) };
834
- }]
835
- ];
836
- const cssProperty = [
837
- [/^\[(.*)\]$/, ([_, body]) => {
838
- if (!body.includes(":"))
839
- return;
840
- const [prop, ...rest] = body.split(":");
841
- const value = rest.join(":");
842
- if (!isURI(body) && /^[a-z-]+$/.test(prop) && isValidCSSBody(value)) {
843
- const parsed = utilities.h.bracket(`[${value}]`);
844
- if (parsed)
845
- return { [prop]: parsed };
846
- }
847
- }]
848
- ];
849
- function isValidCSSBody(body) {
850
- let i = 0;
851
- function findUntil(c) {
852
- while (i < body.length) {
853
- i += 1;
854
- const char = body[i];
855
- if (char === c)
856
- return true;
857
- }
858
- return false;
859
- }
860
- for (i = 0; i < body.length; i++) {
861
- const c = body[i];
862
- if ("\"`'".includes(c)) {
863
- if (!findUntil(c))
864
- return false;
865
- } else if (c === "(") {
866
- if (!findUntil(")"))
867
- return false;
868
- } else if ("[]{}:".includes(c)) {
869
- return false;
870
- }
871
- }
872
- return true;
873
- }
874
- function isURI(declaration) {
875
- if (!declaration.includes("://"))
876
- return false;
877
- try {
878
- return new URL(declaration).host !== "";
879
- } catch (err) {
880
- return false;
881
- }
882
- }
883
-
884
- const questionMark = [
885
- [
886
- /^(where|\?)$/,
887
- (_, { constructCSS, generator }) => {
888
- if (generator.userConfig.envMode === "dev")
889
- 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}}
890
- ${constructCSS({ animation: "__un_qm 0.5s ease-in-out alternate infinite" })}`;
891
- }
892
- ]
893
- ];
894
-
895
- const svgUtilities = [
896
- // fills
897
- [/^fill-(.+)$/, utilities.colorResolver("fill", "fill", "backgroundColor"), { autocomplete: "fill-$colors" }],
898
- [/^fill-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-fill-opacity": utilities.h.bracket.percent.cssvar(opacity) }), { autocomplete: "fill-(op|opacity)-<percent>" }],
899
- ["fill-none", { fill: "none" }],
900
- // stroke size
901
- [/^stroke-(?:width-|size-)?(.+)$/, handleWidth, { autocomplete: ["stroke-width-$lineWidth", "stroke-size-$lineWidth"] }],
902
- // stroke dash
903
- [/^stroke-dash-(.+)$/, ([, s]) => ({ "stroke-dasharray": utilities.h.bracket.cssvar.number(s) }), { autocomplete: "stroke-dash-<num>" }],
904
- [/^stroke-offset-(.+)$/, ([, s], { theme }) => ({ "stroke-dashoffset": theme.lineWidth?.[s] ?? utilities.h.bracket.cssvar.px.numberWithUnit(s) }), { autocomplete: "stroke-offset-$lineWidth" }],
905
- // stroke colors
906
- [/^stroke-(.+)$/, handleColorOrWidth, { autocomplete: "stroke-$colors" }],
907
- [/^stroke-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-stroke-opacity": utilities.h.bracket.percent.cssvar(opacity) }), { autocomplete: "stroke-(op|opacity)-<percent>" }],
908
- // line cap
909
- ["stroke-cap-square", { "stroke-linecap": "square" }],
910
- ["stroke-cap-round", { "stroke-linecap": "round" }],
911
- ["stroke-cap-auto", { "stroke-linecap": "butt" }],
912
- // line join
913
- ["stroke-join-arcs", { "stroke-linejoin": "arcs" }],
914
- ["stroke-join-bevel", { "stroke-linejoin": "bevel" }],
915
- ["stroke-join-clip", { "stroke-linejoin": "miter-clip" }],
916
- ["stroke-join-round", { "stroke-linejoin": "round" }],
917
- ["stroke-join-auto", { "stroke-linejoin": "miter" }],
918
- // none
919
- ["stroke-none", { stroke: "none" }]
920
- ];
921
- function handleWidth([, b], { theme }) {
922
- return { "stroke-width": theme.lineWidth?.[b] ?? utilities.h.bracket.cssvar.fraction.px.number(b) };
923
- }
924
- function handleColorOrWidth(match, ctx) {
925
- if (utilities.isCSSMathFn(utilities.h.bracket(match[1])))
926
- return handleWidth(match, ctx);
927
- return utilities.colorResolver("stroke", "stroke", "borderColor")(match, ctx);
928
- }
929
-
930
- const rules = [
931
- cssVariables,
932
- cssProperty,
933
- paddings,
934
- margins,
935
- transform.displays,
936
- opacity,
937
- bgColors,
938
- colorScheme,
939
- svgUtilities,
940
- borders,
941
- transform.contentVisibility,
942
- transform.contents,
943
- fonts,
944
- tabSizes,
945
- textIndents,
946
- transform.textOverflows,
947
- textDecorations,
948
- textStrokes,
949
- textShadows,
950
- transform.textTransforms,
951
- textAligns,
952
- transform.fontStyles,
953
- transform.fontSmoothings,
954
- transform.boxShadows,
955
- transform.rings,
956
- flex,
957
- grids,
958
- gaps,
959
- positions,
960
- sizes,
961
- aspectRatio,
962
- transform.cursors,
963
- transform.appearances,
964
- transform.pointerEvents,
965
- transform.resizes,
966
- verticalAligns,
967
- transform.userSelects,
968
- transform.whitespaces,
969
- transform.breaks,
970
- overflows,
971
- outline,
972
- appearance,
973
- orders,
974
- justifies,
975
- alignments,
976
- placements,
977
- flexGridJustifiesAlignments,
978
- insets,
979
- floats,
980
- zIndexes,
981
- boxSizing,
982
- transitions,
983
- transform.transforms,
984
- willChange,
985
- containerParent,
986
- transform.contains,
987
- transform.textWraps,
988
- // should be the last
989
- questionMark
990
- ].flat(1);
991
-
992
- exports.alignments = alignments;
993
- exports.appearance = appearance;
994
- exports.aspectRatio = aspectRatio;
995
- exports.bgColors = bgColors;
996
- exports.borderStyles = borderStyles;
997
- exports.borders = borders;
998
- exports.boxSizing = boxSizing;
999
- exports.colorScheme = colorScheme;
1000
- exports.containerParent = containerParent;
1001
- exports.cssProperty = cssProperty;
1002
- exports.cssVariables = cssVariables;
1003
- exports.flex = flex;
1004
- exports.flexGridJustifiesAlignments = flexGridJustifiesAlignments;
1005
- exports.floats = floats;
1006
- exports.fonts = fonts;
1007
- exports.gaps = gaps;
1008
- exports.grids = grids;
1009
- exports.handlerBorderStyle = handlerBorderStyle;
1010
- exports.insets = insets;
1011
- exports.justifies = justifies;
1012
- exports.margins = margins;
1013
- exports.opacity = opacity;
1014
- exports.orders = orders;
1015
- exports.outline = outline;
1016
- exports.overflows = overflows;
1017
- exports.paddings = paddings;
1018
- exports.placements = placements;
1019
- exports.positions = positions;
1020
- exports.questionMark = questionMark;
1021
- exports.rules = rules;
1022
- exports.sizes = sizes;
1023
- exports.svgUtilities = svgUtilities;
1024
- exports.tabSizes = tabSizes;
1025
- exports.textAligns = textAligns;
1026
- exports.textDecorations = textDecorations;
1027
- exports.textIndents = textIndents;
1028
- exports.textShadows = textShadows;
1029
- exports.textStrokes = textStrokes;
1030
- exports.transitions = transitions;
1031
- exports.verticalAligns = verticalAligns;
1032
- exports.willChange = willChange;
1033
- exports.zIndexes = zIndexes;