@unocss/preset-mini 0.15.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.
@@ -0,0 +1,1077 @@
1
+ 'use strict';
2
+
3
+ const core = require('@unocss/core');
4
+ const index = require('./index.cjs');
5
+ const pseudo = require('./pseudo.cjs');
6
+
7
+ const verticalAlignAlias = {
8
+ mid: "middle",
9
+ base: "baseline",
10
+ btm: "bottom"
11
+ };
12
+ const verticalAligns = [
13
+ [/^(?:vertical|align|v)-(baseline|top|bottom|middle|text-top|text-bottom|mid|base|btm)$/, ([, v]) => ({ "vertical-align": verticalAlignAlias[v] || v })]
14
+ ];
15
+ const textAligns = [
16
+ ["text-center", { "text-align": "center" }],
17
+ ["text-left", { "text-align": "left" }],
18
+ ["text-right", { "text-align": "right" }],
19
+ ["text-justify", { "text-align": "justify" }]
20
+ ];
21
+
22
+ const parseColorUtil = (body, theme) => {
23
+ const [main, opacity2] = body.split(/(?:\/|:)/);
24
+ const [name, no = "DEFAULT"] = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
25
+ if (!name)
26
+ return;
27
+ let color;
28
+ const bracket = index.handler.bracket(main) || main;
29
+ if (bracket.startsWith("#"))
30
+ color = bracket.slice(1);
31
+ if (bracket.startsWith("hex-"))
32
+ color = bracket.slice(4);
33
+ if (!color) {
34
+ const colorData = theme.colors?.[name];
35
+ if (typeof colorData === "string")
36
+ color = colorData;
37
+ else if (no && colorData)
38
+ color = colorData[no];
39
+ }
40
+ return {
41
+ opacity: opacity2,
42
+ name,
43
+ no,
44
+ color,
45
+ rgba: core.hex2rgba(color)
46
+ };
47
+ };
48
+ const colorResolver$1 = (attribute, varName) => ([, body], { theme }) => {
49
+ const data = parseColorUtil(body, theme);
50
+ if (!data)
51
+ return;
52
+ const { opacity: opacity2, color, rgba } = data;
53
+ if (!color)
54
+ return;
55
+ const a = opacity2 ? opacity2[0] === "[" ? index.handler.bracket.percent(opacity2) : parseFloat(opacity2) / 100 : rgba?.[3];
56
+ if (rgba) {
57
+ if (a != null && !Number.isNaN(a)) {
58
+ rgba[3] = typeof a === "string" && !a.includes("%") ? parseFloat(a) : a;
59
+ return {
60
+ [attribute]: `rgba(${rgba.join(",")})`
61
+ };
62
+ } else {
63
+ return {
64
+ [`--un-${varName}-opacity`]: 1,
65
+ [attribute]: `rgba(${rgba.slice(0, 3).join(",")},var(--un-${varName}-opacity))`
66
+ };
67
+ }
68
+ } else {
69
+ return {
70
+ [attribute]: color.replace("%alpha", `${a || 1}`)
71
+ };
72
+ }
73
+ };
74
+ const opacity = [
75
+ [/^op(?:acity)?-?(.+)$/, ([, d]) => ({ opacity: index.handler.bracket.percent.cssvar(d) })]
76
+ ];
77
+ const textColors = [
78
+ [/^(?:text|color|c)-(.+)$/, colorResolver$1("color", "text")],
79
+ [/^(?:text|color|c)-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-text-opacity": index.handler.bracket.percent.cssvar(opacity2) })]
80
+ ];
81
+ const textDecorationColors = [
82
+ [/^underline-(.+)$/, (match, ctx) => {
83
+ const result = colorResolver$1("text-decoration-color", "line")(match, ctx);
84
+ if (result) {
85
+ return {
86
+ "-webkit-text-decoration-color": result["text-decoration-color"],
87
+ ...result
88
+ };
89
+ }
90
+ }],
91
+ [/^underline-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-line-opacity": index.handler.bracket.percent(opacity2) })]
92
+ ];
93
+ const textStrokeColors = [
94
+ [/^text-stroke-(.+)$/, colorResolver$1("-webkit-text-stroke-color", "text-stroke")],
95
+ [/^text-stroke-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-text-stroke-opacity": index.handler.bracket.percent(opacity2) })]
96
+ ];
97
+ const bgColors = [
98
+ [/^bg-(.+)$/, colorResolver$1("background-color", "bg")],
99
+ [/^bg-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-bg-opacity": index.handler.bracket.percent(opacity2) })]
100
+ ];
101
+ const borderColors = [
102
+ [/^(?:border|b)-(.+)$/, colorResolver$1("border-color", "border")],
103
+ [/^(?:border|b)-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-border-opacity": index.handler.bracket.percent(opacity2) })]
104
+ ];
105
+ const ringColors = [
106
+ [/^ring-(.+)$/, colorResolver$1("--un-ring-color", "ring")],
107
+ [/^ring-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-ring-opacity": index.handler.bracket.percent(opacity2) })]
108
+ ];
109
+ const ringOffsetColors = [
110
+ [/^ring-offset-(.+)$/, colorResolver$1("--un-ring-offset-color", "ring-offset")],
111
+ [/^ring-offset-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-ring-offset-opacity": index.handler.bracket.percent(opacity2) })]
112
+ ];
113
+ const fillColors = [
114
+ ["fill-none", { fill: "none" }],
115
+ [/^fill-(.+)$/, colorResolver$1("fill", "fill")],
116
+ [/^fill-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-fill-opacity": index.handler.bracket.percent(opacity2) })]
117
+ ];
118
+
119
+ const outlineStyle = ["none", "auto", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset", "inherit", "initial", "revert", "unset"];
120
+ const parseOutlineSize = (s) => {
121
+ const propName = ["width", "offset"].find((item) => s.startsWith(item)) || "width";
122
+ const size = index.handler.bracket.fraction.rem(s.replace(/^(offset\-|width\-)/, ""));
123
+ if (size) {
124
+ return {
125
+ [`outline-${propName}`]: size
126
+ };
127
+ }
128
+ };
129
+ const outline = [
130
+ ["outline-none", { "outline": "2px solid transparent", "outline-offset": "2px" }],
131
+ ["outline", { "outline-style": "solid" }],
132
+ [
133
+ /^outline-(.+)$/,
134
+ (match, config) => {
135
+ const [, d] = match;
136
+ if (d === "none") {
137
+ return {
138
+ "outline": "2px solid transparent",
139
+ "outline-offset": "2px"
140
+ };
141
+ }
142
+ if (outlineStyle.includes(d)) {
143
+ return {
144
+ "outline-style": d
145
+ };
146
+ }
147
+ const sizeSheet = parseOutlineSize(d);
148
+ if (sizeSheet)
149
+ return sizeSheet;
150
+ const colorSheet = colorResolver$1("outline-color", "outline-color")([
151
+ match[0],
152
+ match[1].replace(/^color-/, "")
153
+ ], config);
154
+ if (colorSheet)
155
+ return colorSheet;
156
+ }
157
+ ]
158
+ ];
159
+ const appearance = [
160
+ ["appearance-none", {
161
+ "appearance": "none",
162
+ "-webkit-appearance": "none"
163
+ }]
164
+ ];
165
+ const placeholder = [
166
+ [
167
+ /^placeholder-opacity-(\d+)$/,
168
+ ([, d]) => ({
169
+ "placeholder-opacity": index.handler.bracket.percent(d)
170
+ })
171
+ ],
172
+ [
173
+ /^placeholder-(?!opacity)(.+)$/,
174
+ (match, config) => {
175
+ match[1] = match[1].replace(/^color-/, "");
176
+ return colorResolver$1("placeholder-color", "placeholder-color")(match, config);
177
+ }
178
+ ]
179
+ ];
180
+
181
+ const borderSizes = [
182
+ [/^border$/, handlerBorder],
183
+ [/^(?:border|b)(?:-([^-]+))?$/, handlerBorder],
184
+ [/^(?:border|b)(?:-([^-]+))?(?:-([^-]+))?$/, handlerBorder]
185
+ ];
186
+ const borderRadius = [
187
+ [/^(?:border-)?(?:rounded|rd)$/, handlerRounded],
188
+ [/^(?:border-)?(?:rounded|rd)(?:-([^-]+))?$/, handlerRounded],
189
+ [/^(?:border-)?(?:rounded|rd)(?:-([^-]+))?(?:-([^-]+))?$/, handlerRounded]
190
+ ];
191
+ const borderStyles = [
192
+ ["border-solid", { "border-style": "solid" }],
193
+ ["border-dashed", { "border-style": "dashed" }],
194
+ ["border-dotted", { "border-style": "dotted" }],
195
+ ["border-double", { "border-style": "double" }],
196
+ ["border-none", { "border-style": "none" }]
197
+ ];
198
+ const borders = [
199
+ borderSizes,
200
+ borderColors,
201
+ borderStyles,
202
+ borderRadius
203
+ ].flat(1);
204
+ function handlerBorder([, a, b]) {
205
+ const [d, s = "1"] = index.directionMap[a] ? [a, b] : ["", a];
206
+ const v = index.handler.bracket.px(s);
207
+ if (v != null) {
208
+ return [
209
+ ...index.directionMap[d].map((i) => [`border${i}-width`, v]),
210
+ ["border-style", "solid"]
211
+ ];
212
+ }
213
+ }
214
+ function handlerRounded([, a, b], { theme }) {
215
+ const [d, s = "DEFAULT"] = index.cornerMap[a] ? [a, b] : ["", a];
216
+ const v = theme.borderRadius?.[s] || index.handler.bracket.fraction.rem(s);
217
+ if (v != null)
218
+ return index.cornerMap[d].map((i) => [`border${i}-radius`, v]);
219
+ }
220
+
221
+ const transitionBasicProps = [
222
+ "color",
223
+ "border-color",
224
+ "background-color",
225
+ "flex-grow",
226
+ "flex",
227
+ "flex-shrink",
228
+ "caret-color",
229
+ "font",
230
+ "gap",
231
+ "opacity",
232
+ "visibility",
233
+ "z-index",
234
+ "font-weight",
235
+ "zoom",
236
+ "text-shadow",
237
+ "transform",
238
+ "box-shadow"
239
+ ];
240
+ const transitionPositionProps = [
241
+ "backround-position",
242
+ "left",
243
+ "right",
244
+ "top",
245
+ "bottom",
246
+ "object-position"
247
+ ];
248
+ const transitionSizeProps = [
249
+ "max-height",
250
+ "min-height",
251
+ "max-width",
252
+ "min-width",
253
+ "height",
254
+ "width",
255
+ "border-width",
256
+ "margin",
257
+ "padding",
258
+ "outline-width",
259
+ "outline-offset",
260
+ "font-size",
261
+ "line-height",
262
+ "text-indent",
263
+ "vertical-align",
264
+ "border-spacing",
265
+ "letter-spacing",
266
+ "word-spacing"
267
+ ];
268
+ const transitionSwitchProps = ["all", "none"];
269
+ const transitionEnhanceProps = ["stroke", "filter", "backdrop-filter", "fill", "mask", "mask-size", "mask-border", "clip-path", "clip"];
270
+ const transitionProps = [
271
+ ...transitionBasicProps,
272
+ ...transitionPositionProps,
273
+ ...transitionSizeProps,
274
+ ...transitionEnhanceProps
275
+ ];
276
+ const transitionPropsStr = transitionProps.join(", ");
277
+ const validateProperty = (prop) => {
278
+ if (prop && ![...transitionProps, ...transitionSwitchProps].includes(prop))
279
+ return;
280
+ return prop || transitionPropsStr;
281
+ };
282
+ const transitions = [
283
+ [/^transition(?:-([a-z-]+))?(?:-(\d+))?$/, ([, prop, duration = "150"]) => {
284
+ const transitionProperty = validateProperty(prop);
285
+ if (!transitionProperty)
286
+ return;
287
+ return {
288
+ "transition-property": transitionProperty,
289
+ "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)",
290
+ "transition-duration": `${duration}ms`
291
+ };
292
+ }],
293
+ [/^duration-(\d+)$/, ([, duration = "150"]) => {
294
+ return {
295
+ "transition-duration": `${duration}ms`
296
+ };
297
+ }],
298
+ ["ease", { "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)" }],
299
+ ["ease-in", { "transition-timing-function": "cubic-bezier(0.4, 0, 1, 1)" }],
300
+ ["ease-out", { "transition-timing-function": "cubic-bezier(0, 0, 0.2, 1)" }],
301
+ ["ease-in-out", { "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)" }],
302
+ [/^transition-delay-(\d+)$/, ([, v]) => ({ "transition-delay": `${v}ms` })],
303
+ [/^transition-duration-(\d+)$/, ([, v]) => ({ "transition-duration": `${v}ms` })],
304
+ [/^(?:transition-)?property-([a-z-]+)$/, ([, v]) => {
305
+ const transitionProperty = validateProperty(v);
306
+ if (transitionProperty)
307
+ return { "transition-property": transitionProperty };
308
+ }]
309
+ ];
310
+
311
+ const flex = [
312
+ ["flex-col", { "flex-direction": "column" }],
313
+ ["flex-col-reverse", { "flex-direction": "column-reverse" }],
314
+ ["flex-row", { "flex-direction": "row" }],
315
+ ["flex-row-reverse", { "flex-direction": "row-reverse" }],
316
+ ["flex-wrap", { "flex-wrap": "wrap" }],
317
+ ["flex-wrap-reverse", { "flex-wrap": "wrap-reverse" }],
318
+ ["flex-nowrap", { "flex-wrap": "nowrap" }],
319
+ ["flex-1", { flex: "1 1 0%" }],
320
+ ["flex-auto", { flex: "1 1 auto" }],
321
+ ["flex-initial", { flex: "0 1 auto" }],
322
+ ["flex-none", { flex: "none" }],
323
+ [/^flex-\[(.+)\]$/, ([, d]) => ({ flex: d })],
324
+ ["flex-grow", { "flex-grow": 1 }],
325
+ ["flex-grow-0", { "flex-grow": 0 }],
326
+ ["flex-shrink", { "flex-shrink": 1 }],
327
+ ["flex-shrink-0", { "flex-shrink": 0 }],
328
+ ["flex", { display: "flex" }],
329
+ ["inline-flex", { display: "inline-flex" }],
330
+ ["flex-inline", { display: "inline-flex" }]
331
+ ];
332
+
333
+ const fontsFamilies = [
334
+ [/^font-(\w+)$/, ([, d], { theme }) => {
335
+ const font = theme.fontFamily?.[d];
336
+ if (font) {
337
+ return {
338
+ "font-family": font
339
+ };
340
+ }
341
+ }]
342
+ ];
343
+ const weightMap = {
344
+ thin: "100",
345
+ extralight: "200",
346
+ light: "300",
347
+ normal: "400",
348
+ medium: "500",
349
+ semibold: "600",
350
+ bold: "700",
351
+ extrabold: "800",
352
+ black: "900"
353
+ };
354
+ const fontSizes = [
355
+ [/^text-([^-]+)$/, ([, s = "base"], { theme }) => {
356
+ const result = core.toArray(theme.fontSize?.[s] || index.handler.bracket.rem(s));
357
+ if (result?.[0]) {
358
+ const [size, height = "1"] = result;
359
+ return {
360
+ "font-size": size,
361
+ "line-height": height
362
+ };
363
+ }
364
+ }]
365
+ ];
366
+ const fontWeights = [
367
+ [/^(?:font|fw)-?([^-]+)$/, ([, s]) => {
368
+ const v = weightMap[s] || index.handler.number(s);
369
+ if (v)
370
+ return { "font-weight": v };
371
+ }]
372
+ ];
373
+ const leadings = [
374
+ [/^(?:leading|lh)-([^-]+)$/, ([, s], { theme }) => {
375
+ const v = theme.lineHeight?.[s] || index.handler.bracket.rem(s);
376
+ if (v !== null)
377
+ return { "line-height": v };
378
+ }]
379
+ ];
380
+ const trackings = [
381
+ [/^tracking-([^-]+)$/, ([, s], { theme }) => {
382
+ const v = theme.letterSpacing?.[s] || index.handler.bracket.rem(s);
383
+ if (v !== null)
384
+ return { "letter-spacing": v };
385
+ }]
386
+ ];
387
+ const wordSpacings = [
388
+ [/^word-spacing-([^-]+)$/, ([, s], { theme }) => {
389
+ const v = theme.wordSpacing?.[s] || index.handler.bracket.rem(s);
390
+ if (v !== null)
391
+ return { "word-spacing": v };
392
+ }]
393
+ ];
394
+ const tabSizes = [
395
+ [/^tab-?([^-]*)$/, ([, s]) => {
396
+ s = s || "4";
397
+ const v = index.handler.bracket.global.number(s);
398
+ if (v !== null) {
399
+ return {
400
+ "-moz-tab-size": v,
401
+ "-o-tab-size": v,
402
+ "tab-size": v
403
+ };
404
+ }
405
+ }]
406
+ ];
407
+ const textDecorationLengths = [
408
+ [/^underline-([^-]+)$/, ([, s]) => {
409
+ const v = s === "auto" ? s : index.handler.bracket.px(s);
410
+ if (v != null)
411
+ return { "text-decoration-thickness": v };
412
+ }]
413
+ ];
414
+ const textDecorationOffsets = [
415
+ [/^underline-offset-([^-]+)$/, ([, s]) => {
416
+ const v = s === "auto" ? s : index.handler.bracket.px(s);
417
+ if (v != null)
418
+ return { "text-underline-offset": v };
419
+ }]
420
+ ];
421
+ const textIndents = [
422
+ [/^indent(?:-(.+))?$/, ([, s], { theme }) => {
423
+ const v = theme.textIndent?.[s || "DEFAULT"] || index.handler.bracket.cssvar.fraction.rem(s);
424
+ if (v != null)
425
+ return { "text-indent": v };
426
+ }]
427
+ ];
428
+ const textStrokeWidths = [
429
+ [/^text-stroke(?:-(.+))?$/, ([, s], { theme }) => {
430
+ const v = theme.textStrokeWidth?.[s || "DEFAULT"] || index.handler.bracket.cssvar.px(s);
431
+ if (v != null)
432
+ return { "-webkit-text-stroke-width": v };
433
+ }]
434
+ ];
435
+ const textShadows = [
436
+ [/^text-shadow(?:-(.+))?$/, ([, s], { theme }) => {
437
+ const v = theme.textShadow?.[s || "DEFAULT"] || index.handler.bracket.cssvar(s);
438
+ if (v != null)
439
+ return { "text-shadow": v };
440
+ }]
441
+ ];
442
+ const fonts = [
443
+ fontsFamilies,
444
+ fontSizes,
445
+ fontWeights
446
+ ].flat(1);
447
+
448
+ const gaps = [
449
+ [/^(?:flex-|grid-)?gap-([^-]+)$/, ([, s]) => {
450
+ const v = index.handler.bracket.rem(s);
451
+ if (v != null) {
452
+ return {
453
+ "grid-gap": v,
454
+ "gap": v
455
+ };
456
+ }
457
+ }],
458
+ [/^(?:flex-|grid-)?gap-x-([^-]+)$/, ([, s]) => {
459
+ const v = index.handler.bracket.rem(s);
460
+ if (v != null) {
461
+ return {
462
+ "grid-column-gap": v,
463
+ "column-gap": v
464
+ };
465
+ }
466
+ }],
467
+ [/^(?:flex-|grid-)?gap-y-([^-]+)$/, ([, s]) => {
468
+ const v = index.handler.bracket.rem(s);
469
+ if (v != null) {
470
+ return {
471
+ "grid-row-gap": v,
472
+ "row-gap": v
473
+ };
474
+ }
475
+ }]
476
+ ];
477
+
478
+ const calSize = (s, theme) => core.toArray(theme.fontSize?.[s] || index.handler.bracket.rem(s))[0];
479
+ const autoDirection = (selector, theme) => {
480
+ if (selector === "min")
481
+ return "min-content";
482
+ else if (selector === "max")
483
+ return "max-content";
484
+ else if (selector === "fr")
485
+ return "minmax(0,1fr)";
486
+ return calSize(selector, theme);
487
+ };
488
+ const grids = [
489
+ ["grid", { display: "grid" }],
490
+ ["inline-grid", { display: "inline-grid" }],
491
+ [/^grid-cols-minmax-([\w.-]+)$/, ([, d]) => ({ "grid-template-columns": `repeat(auto-fill, minmax(${d}, 1fr))` })],
492
+ [/^grid-rows-minmax-([\w.-]+)$/, ([, d]) => ({ "grid-template-rows": `repeat(auto-fill, minmax(${d}, 1fr))` })],
493
+ [/^grid-cols-(\d+)$/, ([, d]) => ({ "grid-template-columns": `repeat(${d},minmax(0,1fr))` })],
494
+ [/^grid-rows-(\d+)$/, ([, d]) => ({ "grid-template-rows": `repeat(${d},minmax(0,1fr))` })],
495
+ [/^grid-cols-\[(.+)\]$/, ([, v]) => ({ "grid-template-columns": v.replace(/,/g, " ") })],
496
+ [/^grid-rows-\[(.+)\]$/, ([, v]) => ({ "grid-template-rows": v.replace(/,/g, " ") })],
497
+ [/^(?:grid-)?(row|col)-(.+)$/, ([, d, v]) => {
498
+ const key = d === "row" ? "grid-row" : "grid-column";
499
+ let raw = index.handler.bracket(v);
500
+ if (raw)
501
+ return { [key]: raw };
502
+ const parts = v.split("-");
503
+ if (parts.length === 1 && parts[0] === "auto")
504
+ return { [key]: parts[0] };
505
+ if (parts[0] === "span") {
506
+ if (parts[1] === "full")
507
+ return { [key]: "1/-1" };
508
+ raw = index.handler.number.bracket(parts[1])?.toString().replace(/_/g, " ");
509
+ if (raw)
510
+ return { [key]: `span ${raw}/span ${raw}` };
511
+ }
512
+ }],
513
+ [/^(?:grid-)?auto-flow-([\w.-]+)$/, ([, v]) => ({ "grid-auto-flow": `${v.replace("col", "column").split("-").join(" ")}` })],
514
+ [/^(?:grid-)?row-start-([\w.-]+)$/, ([, v]) => ({ "grid-row-start": `${v}` })],
515
+ [/^(?:grid-)?row-end-([\w.-]+)$/, ([, v]) => ({ "grid-row-end": `${v}` })],
516
+ [/^(?:grid-)?col-start-([\w.-]+)$/, ([, v]) => ({ "grid-column-start": `${v}` })],
517
+ [/^(?:grid-)?col-end-([\w.]+)$/, ([, v]) => ({ "grid-column-end": `${v}` })],
518
+ [/^(?:grid-)?auto-rows-([\w.-]+)$/, ([, v], { theme }) => ({ "grid-auto-rows": `${autoDirection(v, theme)}` })],
519
+ [/^(?:grid-)?auto-cols-([\w.-]+)$/, ([, v], { theme }) => ({ "grid-auto-columns": `${autoDirection(v, theme)}` })]
520
+ ];
521
+
522
+ const overflowValues = [
523
+ "auto",
524
+ "hidden",
525
+ "visible",
526
+ "scroll"
527
+ ];
528
+ const overflows = [
529
+ [/^(?:overflow|of)-(.+)$/, ([, v]) => overflowValues.includes(v) ? { overflow: v } : void 0],
530
+ [/^(?:overflow|of)-([xy])-(.+)$/, ([, d, v]) => overflowValues.includes(v) ? { [`overflow-${d}`]: v } : void 0]
531
+ ];
532
+
533
+ const positions = [
534
+ ["relative", { position: "relative" }],
535
+ ["absolute", { position: "absolute" }],
536
+ ["fixed", { position: "fixed" }],
537
+ ["sticky", { position: "sticky" }],
538
+ ["static", { position: "static" }]
539
+ ];
540
+ const justifies = [
541
+ ["justify-start", { "justify-content": "flex-start" }],
542
+ ["justify-end", { "justify-content": "flex-end" }],
543
+ ["justify-center", { "justify-content": "center" }],
544
+ ["justify-between", { "justify-content": "space-between" }],
545
+ ["justify-around", { "justify-content": "space-around" }],
546
+ ["justify-evenly", { "justify-content": "space-evenly" }]
547
+ ];
548
+ const orders = [
549
+ [/^order-(.+)$/, ([, v]) => ({ order: { first: "-9999", last: "9999", none: "0" }[v] || index.handler.bracket.number(v) })]
550
+ ];
551
+ const basicSet = ["auto", "start", "end", "center", "stretch"];
552
+ const justifyItems = basicSet.map((i) => [`justify-items-${i}`, { "justify-items": i }]);
553
+ const justifySelfs = basicSet.map((i) => [`justify-self-${i}`, { "justify-self": i }]);
554
+ const alignContents = [
555
+ ["content-start", { "align-content": "flex-start" }],
556
+ ["content-end", { "align-content": "flex-end" }],
557
+ ["content-center", { "align-content": "center" }],
558
+ ["content-between", { "align-content": "space-between" }],
559
+ ["content-around", { "align-content": "space-around" }],
560
+ ["content-evenly", { "align-content": "space-evenly" }]
561
+ ];
562
+ const alignItems = [
563
+ ["items-start", { "align-items": "flex-start" }],
564
+ ["items-end", { "align-items": "flex-end" }],
565
+ ["items-center", { "align-items": "center" }],
566
+ ["items-baseline", { "align-items": "baseline" }],
567
+ ["items-stretch", { "align-items": "stretch" }]
568
+ ];
569
+ const alignSelfs = [
570
+ ["self-auto", { "align-self": "auto" }],
571
+ ["self-start", { "align-self": "flex-start" }],
572
+ ["self-end", { "align-self": "flex-end" }],
573
+ ["self-center", { "align-self": "center" }],
574
+ ["self-stretch", { "align-items": "stretch" }]
575
+ ];
576
+ const placeContents = [
577
+ ["place-content-start", { "place-content": "start" }],
578
+ ["place-content-end", { "place-content": "end" }],
579
+ ["place-content-center", { "place-content": "center" }],
580
+ ["place-content-between", { "place-content": "space-between" }],
581
+ ["place-content-around", { "place-content": "space-around" }],
582
+ ["place-content-evenly", { "place-content": "space-evenly" }],
583
+ ["place-content-stretch", { "place-content": "stretch" }]
584
+ ];
585
+ const placeItems = basicSet.map((i) => [`place-items-${i}`, { "place-items": i }]);
586
+ const placeSelfs = basicSet.map((i) => [`place-self-${i}`, { "place-self": i }]);
587
+ function handleInsetValue(v) {
588
+ return { auto: "auto", full: "100%" }[v] ?? index.handler.bracket.fraction.cssvar.rem(v);
589
+ }
590
+ const insets = [
591
+ [/^(top|left|right|bottom|inset)-(.+)$/, ([, d, v]) => ({ [d]: handleInsetValue(v) })],
592
+ [/^inset-([xy])-(.+)$/, ([, d, v]) => {
593
+ const r = handleInsetValue(v);
594
+ if (r != null && d in index.directionMap)
595
+ return index.directionMap[d].map((i) => [i.slice(1), r]);
596
+ }]
597
+ ];
598
+ const floats = [
599
+ [/^float-(left|right|none)$/, ([, value]) => ({ float: value })],
600
+ [/^clear-(left|right|both|none)$/, ([, value]) => ({ clear: value })]
601
+ ];
602
+ const zIndexes = [
603
+ ["z-auto", { "z-index": "auto" }],
604
+ [/^z-([^-]+)$/, ([, v]) => ({ "z-index": index.handler.number(v) })]
605
+ ];
606
+ const boxSizing = [
607
+ [
608
+ /^box-(border|content)$/,
609
+ ([, value]) => ({
610
+ "box-sizing": `${value}-box`
611
+ })
612
+ ]
613
+ ];
614
+
615
+ const rings = [
616
+ [/^ring-?(.*)$/, ([, d]) => {
617
+ const value = index.handler.px(d || "1");
618
+ if (value) {
619
+ return {
620
+ "--un-ring-inset": "var(--un-empty, )",
621
+ "--un-ring-offset-width": "0px",
622
+ "--un-ring-offset-color": "#fff",
623
+ "--un-ring-color": "rgba(59, 130, 246, .5)",
624
+ "--un-ring-offset-shadow": "var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color)",
625
+ "--un-ring-shadow": `var(--un-ring-inset) 0 0 0 calc(${value} + var(--un-ring-offset-width)) var(--un-ring-color)`,
626
+ "-webkit-box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow, 0 0 #0000);",
627
+ "box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow, 0 0 #0000);"
628
+ };
629
+ }
630
+ }],
631
+ [/^ring-offset-?(.*)$/, ([, d]) => {
632
+ const value = index.handler.px(d || "1");
633
+ if (value) {
634
+ return {
635
+ "--un-ring-offset-width": value
636
+ };
637
+ }
638
+ }],
639
+ ["ring-inset", { "--un-ring-inset": "inset" }],
640
+ ...ringColors,
641
+ ...ringOffsetColors
642
+ ];
643
+
644
+ const colorResolver = (body, theme) => {
645
+ const data = parseColorUtil(body, theme);
646
+ if (!data)
647
+ return;
648
+ const { color, rgba } = data;
649
+ if (!color)
650
+ return;
651
+ if (rgba) {
652
+ return {
653
+ "--un-shadow-color": `${rgba.slice(0, 3).join(",")}`
654
+ };
655
+ } else {
656
+ return {
657
+ "--un-shadow-color": color
658
+ };
659
+ }
660
+ };
661
+ const boxShadows = [
662
+ [/^shadow-?(.*)$/, ([, d], { theme }) => {
663
+ const value = theme?.boxShadow?.[d || "DEFAULT"];
664
+ if (value) {
665
+ return {
666
+ "--un-shadow-color": "0,0,0",
667
+ "--un-shadow": value,
668
+ "box-shadow": "var(--un-ring-offset-shadow, 0 0 #0000), var(--un-ring-shadow, 0 0 #0000), var(--un-shadow)"
669
+ };
670
+ }
671
+ const color = colorResolver(d, theme);
672
+ if (color)
673
+ return color;
674
+ }]
675
+ ];
676
+
677
+ function getPropName(minmax, hw) {
678
+ return `${minmax ? `${minmax}-` : ""}${hw === "h" ? "height" : "width"}`;
679
+ }
680
+ function getThemeValue(minmax, hw, theme, prop) {
681
+ let str = `${hw === "h" ? "height" : "width"}`;
682
+ if (minmax)
683
+ str = `${minmax}${index.capitalize(str)}`;
684
+ return theme[str]?.[prop];
685
+ }
686
+ const sizes = [
687
+ [/^(?:(min|max)-)?(w|h)-(.+)$/, ([, m, w, s], { theme }) => {
688
+ const v = getThemeValue(m, w, theme, s) || index.handler.bracket.cssvar.fraction.rem(s);
689
+ if (v != null)
690
+ return { [getPropName(m, w)]: v };
691
+ }],
692
+ [/^(?:(min|max)-)?(w)-screen-(.+)$/, ([, m, w, s], { theme }) => {
693
+ const v = theme.breakpoints?.[s];
694
+ if (v != null)
695
+ return { [getPropName(m, w)]: v };
696
+ }]
697
+ ];
698
+ const aspectRatio = [
699
+ ["aspect-ratio-auto", { "aspect-ratio": "auto" }],
700
+ [/^aspect-ratio-(.+)$/, ([, d]) => {
701
+ const v = (/^\d+\/\d+$/.test(d) ? d : null) || index.handler.bracket.cssvar.number(d);
702
+ if (v != null)
703
+ return { "aspect-ratio": v };
704
+ }]
705
+ ];
706
+
707
+ const directionSize = (prefix) => ([_, direction, size]) => {
708
+ const v = index.handler.bracket.rem.fraction.cssvar(size);
709
+ if (v)
710
+ return index.directionMap[direction].map((i) => [prefix + i, v]);
711
+ };
712
+ const paddings = [
713
+ [/^pa?()-?(-?.+)$/, directionSize("padding")],
714
+ [/^p-?([xy])-?(-?.+)$/, directionSize("padding")],
715
+ [/^p-?([rltbse])-?(-?.+)$/, directionSize("padding")]
716
+ ];
717
+ const margins = [
718
+ [/^ma?()-?(-?.+)$/, directionSize("margin")],
719
+ [/^m-?([xy])-?(-?.+)$/, directionSize("margin")],
720
+ [/^m-?([rltbse])-?(-?.+)$/, directionSize("margin")]
721
+ ];
722
+
723
+ const varEmpty = "var(--un-empty,/*!*/ /*!*/)";
724
+ const displays = [
725
+ ["inline", { display: "inline" }],
726
+ ["block", { display: "block" }],
727
+ ["inline-block", { display: "inline-block" }],
728
+ ["contents", { display: "contents" }],
729
+ ["flow-root", { display: "flow-root" }],
730
+ ["list-item", { display: "list-item" }],
731
+ ["hidden", { display: "none" }]
732
+ ];
733
+ const appearances = [
734
+ ["visible", { visibility: "visible" }],
735
+ ["invisible", { visibility: "hidden" }],
736
+ ["backface-visible", { "backface-visibility": "visible" }],
737
+ ["backface-hidden", { "backface-visibility": "hidden" }]
738
+ ];
739
+ const cursors = [
740
+ [/^cursor-(.+)$/, ([, c]) => ({ cursor: c })]
741
+ ];
742
+ const pointerEvents = [
743
+ ["pointer-events-none", { "pointer-events": "none" }],
744
+ ["pointer-events-auto", { "pointer-events": "auto" }]
745
+ ];
746
+ const resizes = [
747
+ ["resize-none", { resize: "none" }],
748
+ ["resize-x", { resize: "horizontal" }],
749
+ ["resize-y", { resize: "vertical" }],
750
+ ["resize", { resize: "both" }]
751
+ ];
752
+ const userSelects = [
753
+ [/^select-(none|text|all|auto)$/, ([, v]) => ({ "user-select": v })]
754
+ ];
755
+ const whitespaces = [
756
+ [/^(?:whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)$/, ([, v]) => ({ "white-space": v })]
757
+ ];
758
+ const contents = [
759
+ ["content-empty", { content: '""' }]
760
+ ];
761
+ const breaks = [
762
+ ["break-normal", { "overflow-wrap": "normal", "word-break": "normal" }],
763
+ ["break-word", { "overflow-wrap": "break-word" }],
764
+ ["break-all", { "word-break": "break-all" }]
765
+ ];
766
+ const textOverflows = [
767
+ ["truncate", { "overflow": "hidden", "text-overflow": "ellipsis", "white-space": "nowrap" }],
768
+ ["text-ellipsis", { "text-overflow": "ellipsis" }],
769
+ ["text-clip", { "text-overflow": "clip" }]
770
+ ];
771
+ const textTransforms = [
772
+ ["case-upper", { "text-transform": "uppercase" }],
773
+ ["case-lower", { "text-transform": "lowercase" }],
774
+ ["case-capital", { "text-transform": "capitalize" }],
775
+ ["case-normal", { "text-transform": "none" }]
776
+ ];
777
+ const textDecorations = [
778
+ ["underline", { "text-decoration": "underline" }],
779
+ ["line-through", { "text-decoration": "line-through" }],
780
+ ["no-underline", { "text-decoration": "none" }]
781
+ ];
782
+ const textDecorationStyles = [
783
+ ["underline-solid", { "text-decoration-style": "solid" }],
784
+ ["underline-double", { "text-decoration-style": "double" }],
785
+ ["underline-dotted", { "text-decoration-style": "dotted" }],
786
+ ["underline-dashed", { "text-decoration-style": "dashed" }]
787
+ ];
788
+ const fontStyles = [
789
+ ["italic", { "font-style": "italic" }],
790
+ ["not-italic", { "font-style": "normal" }]
791
+ ];
792
+ const fontSmoothings = [
793
+ ["antialiased", {
794
+ "-webkit-font-smoothing": "antialiased",
795
+ "-moz-osx-font-smoothing": "grayscale",
796
+ "font-smoothing": "grayscale"
797
+ }],
798
+ ["subpixel-antialiased", {
799
+ "-webkit-font-smoothing": "auto",
800
+ "-moz-osx-font-smoothing": "auto",
801
+ "font-smoothing": "auto"
802
+ }]
803
+ ];
804
+
805
+ const transformBase = {
806
+ "--un-rotate": 0,
807
+ "--un-scale-x": 1,
808
+ "--un-scale-y": 1,
809
+ "--un-scale-z": 1,
810
+ "--un-skew-x": 0,
811
+ "--un-skew-y": 0,
812
+ "--un-translate-x": 0,
813
+ "--un-translate-y": 0,
814
+ "--un-translate-z": 0,
815
+ "transform": "rotate(var(--un-rotate)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) translateX(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z))",
816
+ [pseudo.CONTROL_BYPASS_PSEUDO]: ""
817
+ };
818
+ const transforms = [
819
+ ["transform", transformBase],
820
+ [/^preserve-(3d|flat)$/, ([, value]) => ({ "transform-style": value === "3d" ? `preserve-${value}` : value })],
821
+ [/^translate()-([^-]+)$/, handleTranslate],
822
+ [/^translate-([xyz])-([^-]+)$/, handleTranslate],
823
+ [/^scale()-([^-]+)$/, handleScale],
824
+ [/^scale-([xyz])-([^-]+)$/, handleScale],
825
+ [/^rotate-([^-]+)(?:deg)?$/, handleRotate],
826
+ ["origin-center", { "transform-origin": "center" }],
827
+ ["origin-top", { "transform-origin": "top" }],
828
+ ["origin-top-right", { "transform-origin": "top right" }],
829
+ ["origin-right", { "transform-origin": "right" }],
830
+ ["origin-bottom-right", { "transform-origin": "bottom right" }],
831
+ ["origin-bottom", { "transform-origin": "bottom" }],
832
+ ["origin-bottom-left", { "transform-origin": "bottom left" }],
833
+ ["origin-left", { "transform-origin": "left" }],
834
+ ["origin-top-left", { "transform-origin": "top left" }]
835
+ ];
836
+ function handleTranslate([, d, b]) {
837
+ const v = index.handler.bracket.fraction.rem(b);
838
+ if (v != null) {
839
+ return [
840
+ transformBase,
841
+ [
842
+ ...index.xyzMap[d].map((i) => [`--un-translate${i}`, v])
843
+ ]
844
+ ];
845
+ }
846
+ }
847
+ function handleScale([, d, b]) {
848
+ const v = index.handler.bracket.fraction.percent(b);
849
+ if (v != null) {
850
+ return [
851
+ transformBase,
852
+ [
853
+ ...index.xyzMap[d].map((i) => [`--un-scale${i}`, v])
854
+ ]
855
+ ];
856
+ }
857
+ }
858
+ function handleRotate([, b]) {
859
+ const v = index.handler.bracket.number(b);
860
+ if (v != null) {
861
+ return [
862
+ transformBase,
863
+ { "--un-rotate": `${v}deg` }
864
+ ];
865
+ }
866
+ }
867
+
868
+ const variablesAbbrMap = {
869
+ "visible": "visibility",
870
+ "select": "user-select",
871
+ "vertical": "vertical-align",
872
+ "backface": "backface-visibility",
873
+ "whitespace": "white-space",
874
+ "break": "word-break",
875
+ "color": "color",
876
+ "case": "text-transform",
877
+ "write": "writing-mode",
878
+ "write-orient": "text-orientation",
879
+ "origin": "transform-origin",
880
+ "bg": "background-color",
881
+ "bg-blend": "background-blend-mode",
882
+ "bg-clip": "-webkit-background-clip",
883
+ "bg-gradient": "linear-gradient",
884
+ "bg-origin-border": "background-origin",
885
+ "bg-position": "background-position",
886
+ "bg-repeat": "background-repeat",
887
+ "bg-size": "background-size",
888
+ "bg-opacity": "background-opacity",
889
+ "tab": "tab-size",
890
+ "underline": "text-decoration-thickness",
891
+ "underline-offset": "text-underline-offset",
892
+ "text": "color",
893
+ "grid-cols": "grid-template-columns",
894
+ "grid-rows": "grid-template-rows",
895
+ "auto-flow": "grid-auto-flow",
896
+ "row-start": "grid-row-start",
897
+ "row-end": "grid-row-end",
898
+ "justify": "justify-content",
899
+ "content": "align-content",
900
+ "items": "align-items",
901
+ "self": "align-self",
902
+ "object": "object-fit",
903
+ "mix-blend": "mix-blend-mode",
904
+ "animate-speed": "animation-speed"
905
+ };
906
+ const cssVariables = [[
907
+ /^(.+)-\$(.+)$/,
908
+ ([, name, varname]) => {
909
+ const prop = variablesAbbrMap[name];
910
+ if (prop) {
911
+ return {
912
+ [prop]: `var(--${varname})`
913
+ };
914
+ }
915
+ }
916
+ ]];
917
+
918
+ const questionMark = [
919
+ [
920
+ /^(where|\?)$/,
921
+ (_, { constructCSS, generator }) => {
922
+ if (generator.config.envMode === "dev")
923
+ 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}}
924
+ ${constructCSS({ animation: "__un_qm 0.5s ease-in-out alternate infinite" })}`;
925
+ }
926
+ ]
927
+ ];
928
+
929
+ const rules = [
930
+ cssVariables,
931
+ paddings,
932
+ margins,
933
+ displays,
934
+ opacity,
935
+ bgColors,
936
+ fillColors,
937
+ borders,
938
+ contents,
939
+ fonts,
940
+ tabSizes,
941
+ textIndents,
942
+ textOverflows,
943
+ textDecorations,
944
+ textDecorationStyles,
945
+ textDecorationColors,
946
+ textDecorationLengths,
947
+ textDecorationOffsets,
948
+ textStrokeWidths,
949
+ textStrokeColors,
950
+ textShadows,
951
+ textTransforms,
952
+ textAligns,
953
+ textColors,
954
+ fontStyles,
955
+ fontSmoothings,
956
+ boxShadows,
957
+ rings,
958
+ flex,
959
+ grids,
960
+ gaps,
961
+ positions,
962
+ sizes,
963
+ aspectRatio,
964
+ cursors,
965
+ appearances,
966
+ pointerEvents,
967
+ resizes,
968
+ verticalAligns,
969
+ userSelects,
970
+ whitespaces,
971
+ breaks,
972
+ trackings,
973
+ wordSpacings,
974
+ leadings,
975
+ overflows,
976
+ outline,
977
+ appearance,
978
+ placeholder,
979
+ positions,
980
+ orders,
981
+ justifies,
982
+ justifyItems,
983
+ justifySelfs,
984
+ alignContents,
985
+ alignItems,
986
+ alignSelfs,
987
+ placeContents,
988
+ placeItems,
989
+ placeSelfs,
990
+ insets,
991
+ floats,
992
+ zIndexes,
993
+ boxSizing,
994
+ transitions,
995
+ transforms,
996
+ questionMark
997
+ ].flat(1);
998
+
999
+ exports.alignContents = alignContents;
1000
+ exports.alignItems = alignItems;
1001
+ exports.alignSelfs = alignSelfs;
1002
+ exports.appearance = appearance;
1003
+ exports.appearances = appearances;
1004
+ exports.aspectRatio = aspectRatio;
1005
+ exports.bgColors = bgColors;
1006
+ exports.borderColors = borderColors;
1007
+ exports.borderRadius = borderRadius;
1008
+ exports.borderSizes = borderSizes;
1009
+ exports.borderStyles = borderStyles;
1010
+ exports.borders = borders;
1011
+ exports.boxShadows = boxShadows;
1012
+ exports.boxSizing = boxSizing;
1013
+ exports.breaks = breaks;
1014
+ exports.colorResolver = colorResolver$1;
1015
+ exports.contents = contents;
1016
+ exports.cssVariables = cssVariables;
1017
+ exports.cursors = cursors;
1018
+ exports.displays = displays;
1019
+ exports.fillColors = fillColors;
1020
+ exports.flex = flex;
1021
+ exports.floats = floats;
1022
+ exports.fontSizes = fontSizes;
1023
+ exports.fontSmoothings = fontSmoothings;
1024
+ exports.fontStyles = fontStyles;
1025
+ exports.fontWeights = fontWeights;
1026
+ exports.fonts = fonts;
1027
+ exports.fontsFamilies = fontsFamilies;
1028
+ exports.gaps = gaps;
1029
+ exports.grids = grids;
1030
+ exports.insets = insets;
1031
+ exports.justifies = justifies;
1032
+ exports.justifyItems = justifyItems;
1033
+ exports.justifySelfs = justifySelfs;
1034
+ exports.leadings = leadings;
1035
+ exports.margins = margins;
1036
+ exports.opacity = opacity;
1037
+ exports.orders = orders;
1038
+ exports.outline = outline;
1039
+ exports.overflows = overflows;
1040
+ exports.paddings = paddings;
1041
+ exports.parseColorUtil = parseColorUtil;
1042
+ exports.placeContents = placeContents;
1043
+ exports.placeItems = placeItems;
1044
+ exports.placeSelfs = placeSelfs;
1045
+ exports.placeholder = placeholder;
1046
+ exports.pointerEvents = pointerEvents;
1047
+ exports.positions = positions;
1048
+ exports.questionMark = questionMark;
1049
+ exports.resizes = resizes;
1050
+ exports.ringColors = ringColors;
1051
+ exports.ringOffsetColors = ringOffsetColors;
1052
+ exports.rings = rings;
1053
+ exports.rules = rules;
1054
+ exports.sizes = sizes;
1055
+ exports.tabSizes = tabSizes;
1056
+ exports.textAligns = textAligns;
1057
+ exports.textColors = textColors;
1058
+ exports.textDecorationColors = textDecorationColors;
1059
+ exports.textDecorationLengths = textDecorationLengths;
1060
+ exports.textDecorationOffsets = textDecorationOffsets;
1061
+ exports.textDecorationStyles = textDecorationStyles;
1062
+ exports.textDecorations = textDecorations;
1063
+ exports.textIndents = textIndents;
1064
+ exports.textOverflows = textOverflows;
1065
+ exports.textShadows = textShadows;
1066
+ exports.textStrokeColors = textStrokeColors;
1067
+ exports.textStrokeWidths = textStrokeWidths;
1068
+ exports.textTransforms = textTransforms;
1069
+ exports.trackings = trackings;
1070
+ exports.transforms = transforms;
1071
+ exports.transitions = transitions;
1072
+ exports.userSelects = userSelects;
1073
+ exports.varEmpty = varEmpty;
1074
+ exports.verticalAligns = verticalAligns;
1075
+ exports.whitespaces = whitespaces;
1076
+ exports.wordSpacings = wordSpacings;
1077
+ exports.zIndexes = zIndexes;