@unocss/preset-mini 0.20.0 → 0.21.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,4 +1,4 @@
1
- import { h as handler, c as colorResolver$1, d as directionMap, p as parseColor, a as cornerMap, b as capitalize, e as directionSize, x as xyzMap } from './utilities.mjs';
1
+ import { h as handler, c as colorResolver, d as directionMap, p as parseColor, a as cornerMap, b as capitalize, e as directionSize, f as positionMap, x as xyzMap } from './utilities.mjs';
2
2
  import { toArray } from '@unocss/core';
3
3
  import { C as CONTROL_BYPASS_PSEUDO_CLASS } from './pseudo.mjs';
4
4
 
@@ -8,7 +8,7 @@ const verticalAlignAlias = {
8
8
  btm: "bottom"
9
9
  };
10
10
  const verticalAligns = [
11
- [/^(?:vertical|align|v)-(baseline|top|bottom|middle|text-top|text-bottom|mid|base|btm)$/, ([, v]) => ({ "vertical-align": verticalAlignAlias[v] || v })]
11
+ [/^(?:vertical|align|v)-(baseline|top|middle|bottom|text-top|text-bottom|sub|super|mid|base|btm)$/, ([, v]) => ({ "vertical-align": verticalAlignAlias[v] || v })]
12
12
  ];
13
13
  const textAligns = [
14
14
  ["text-center", { "text-align": "center" }],
@@ -19,10 +19,10 @@ const textAligns = [
19
19
 
20
20
  const outline = [
21
21
  [/^outline-(?:width-|size-)?(.+)$/, ([, d]) => ({ "outline-width": handler.bracket.fraction.auto.rem(d) })],
22
- [/^outline-(?:color-)?(.+)$/, colorResolver$1("outline-color", "outline-color")],
22
+ [/^outline-(?:color-)?(.+)$/, colorResolver("outline-color", "outline-color")],
23
23
  [/^outline-offset-(.+)$/, ([, d]) => ({ "outline-offset": handler.bracket.fraction.auto.rem(d) })],
24
24
  ["outline", { "outline-style": "solid" }],
25
- [/^outline-(auto|dotted|dashed|solid|double|groove|ridge|inset|outset|inherit|initial|revert|unset)$/, ([, c]) => ({ "outline-style": c })],
25
+ [/^outline-(auto|dashed|dotted|double|hidden|solid|groove|ridge|inset|outset|inherit|initial|revert|unset)$/, ([, c]) => ({ "outline-style": c })],
26
26
  ["outline-none", { "outline": "2px solid transparent", "outline-offset": "2px" }]
27
27
  ];
28
28
  const appearance = [
@@ -32,31 +32,31 @@ const appearance = [
32
32
  }]
33
33
  ];
34
34
  const willChange = [
35
- [/^will-change-(.+)/, ([, p]) => ({ "will-change": handler.properties.global(p) })]
35
+ [/^will-change-(.+)/, ([, p]) => ({ "will-change": handler.properties.auto.global(p) })]
36
36
  ];
37
37
 
38
38
  const borders = [
39
- [/^border$/, handlerBorder],
40
- [/^(?:border|b)()-(.+)$/, handlerBorder],
41
- [/^(?:border|b)-([^-]+)(?:-(.+))?$/, handlerBorder],
42
- [/^(?:border|b)()-size-(.+)$/, handlerBorderSize],
43
- [/^(?:border|b)-([^-]+)-size-(.+)$/, handlerBorderSize],
44
- [/^(?:border|b)()-(.+)$/, handlerBorderColor],
45
- [/^(?:border|b)-([^-]+)(?:-(.+))?$/, handlerBorderColor],
46
- [/^(?:border|b)-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-border-opacity": handler.bracket.percent(opacity) })],
47
- [/^(?:border|b)-([^-]+)-op(?:acity)?-?(.+)$/, ([, a, opacity]) => {
48
- const v = handler.bracket.percent(opacity);
49
- const d = directionMap[a];
50
- if (v !== void 0 && d)
51
- return d.map((i) => [`--un-border${i}-opacity`, v]);
52
- }],
53
- [/^(?:border-)?(?:rounded|rd)$/, handlerRounded],
54
- [/^(?:border-)?(?:rounded|rd)(?:-(.+))?$/, handlerRounded],
55
- [/^(?:border-)?(?:rounded|rd)(?:-([^-]+))?(?:-(.+))?$/, handlerRounded],
39
+ [/^(?:border|b)()(?:-(.+))?$/, handlerBorder],
40
+ [/^(?:border|b)-([xy])(?:-(.+))?$/, handlerBorder],
41
+ [/^(?:border|b)-([rltbse])(?:-(.+))?$/, handlerBorder],
42
+ [/^(?:border|b)-()size-(.+)$/, handlerBorderSize],
43
+ [/^(?:border|b)-([xy])-size-(.+)$/, handlerBorderSize],
44
+ [/^(?:border|b)-([rltbse])-size-(.+)$/, handlerBorderSize],
45
+ [/^(?:border|b)-()(?:color-)?(.+)$/, handlerBorderColor],
46
+ [/^(?:border|b)-([xy])-(?:color-)?(.+)$/, handlerBorderColor],
47
+ [/^(?:border|b)-([rltbse])-(?:color-)?(.+)$/, handlerBorderColor],
48
+ [/^(?:border|b)-()op(?:acity)?-?(.+)$/, handlerBorderOpacity],
49
+ [/^(?:border|b)-([xy])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
50
+ [/^(?:border|b)-([rltbse])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
51
+ [/^(?:border-)?(?:rounded|rd)()(?:-(.+))?$/, handlerRounded],
52
+ [/^(?:border-)?(?:rounded|rd)-([xy])(?:-(.+))?$/, handlerRounded],
53
+ [/^(?:border-)?(?:rounded|rd)-([rltb])(?:-(.+))?$/, handlerRounded],
54
+ [/^(?:border-)?(?:rounded|rd)-([rltb]{2})(?:-(.+))?$/, handlerRounded],
56
55
  ["border-solid", { "border-style": "solid" }],
57
56
  ["border-dashed", { "border-style": "dashed" }],
58
57
  ["border-dotted", { "border-style": "dotted" }],
59
58
  ["border-double", { "border-style": "double" }],
59
+ ["border-hidden", { "border-style": "hidden" }],
60
60
  ["border-none", { "border-style": "none" }]
61
61
  ];
62
62
  const borderHasColor = (color, { theme }) => {
@@ -66,33 +66,31 @@ const borderColorResolver = (direction) => ([, body], { theme }) => {
66
66
  const data = parseColor(body, theme);
67
67
  if (!data)
68
68
  return;
69
- const { opacity, color, rgba } = data;
69
+ const { alpha, opacity, color, rgba } = data;
70
70
  if (!color)
71
71
  return;
72
- const a = opacity ? opacity[0] === "[" ? handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba?.[3];
73
72
  if (rgba) {
74
- if (a != null && !Number.isNaN(a)) {
75
- rgba[3] = typeof a === "string" && !a.includes("%") ? parseFloat(a) : a;
73
+ if (alpha != null) {
76
74
  return {
77
75
  [`border${direction}-color`]: `rgba(${rgba.join(",")})`
78
76
  };
79
77
  } else {
80
78
  if (direction === "") {
81
79
  return {
82
- "--un-border-opacity": 1,
83
- [`border${direction}-color`]: `rgba(${rgba.slice(0, 3).join(",")},var(--un-border${direction}-opacity))`
80
+ "--un-border-opacity": (opacity && handler.cssvar(opacity)) ?? 1,
81
+ [`border${direction}-color`]: `rgba(${rgba.join(",")},var(--un-border${direction}-opacity))`
84
82
  };
85
83
  } else {
86
84
  return {
87
- "--un-border-opacity": 1,
85
+ "--un-border-opacity": (opacity && handler.cssvar(opacity)) ?? 1,
88
86
  [`--un-border${direction}-opacity`]: "var(--un-border-opacity)",
89
- [`border${direction}-color`]: `rgba(${rgba.slice(0, 3).join(",")},var(--un-border${direction}-opacity))`
87
+ [`border${direction}-color`]: `rgba(${rgba.join(",")},var(--un-border${direction}-opacity))`
90
88
  };
91
89
  }
92
90
  }
93
91
  } else {
94
92
  return {
95
- [`border${direction}-color`]: color.replace("%alpha", `${a || 1}`)
93
+ [`border${direction}-color`]: color.replace("%alpha", `${alpha || 1}`)
96
94
  };
97
95
  }
98
96
  };
@@ -105,42 +103,52 @@ function handlerBorder(m) {
105
103
  ];
106
104
  }
107
105
  }
108
- function handlerBorderSize([, a, b]) {
109
- const [d, s = "1"] = directionMap[a] ? [a, b] : ["", a];
110
- const v = handler.bracket.px(s);
111
- if (v !== void 0)
112
- return directionMap[d].map((i) => [`border${i}-width`, v]);
106
+ function handlerBorderSize([, a = "", b = "1"]) {
107
+ const v = handler.bracket.px(b);
108
+ if (a in directionMap && v != null)
109
+ return directionMap[a].map((i) => [`border${i}-width`, v]);
113
110
  }
114
- function handlerBorderColor([, a, c], ctx) {
115
- if (borderHasColor(c, ctx)) {
116
- return Object.assign({}, ...directionMap[directionMap[a] ? a : ""].map((i) => borderColorResolver(i)(["", c], ctx)));
111
+ function handlerBorderColor([, a = "", c], ctx) {
112
+ if (a in directionMap && borderHasColor(c, ctx)) {
113
+ return Object.assign({}, ...directionMap[a].map((i) => borderColorResolver(i)(["", c], ctx)));
117
114
  }
118
115
  }
119
- function handlerRounded([, a, b], { theme }) {
120
- const [d, s = "DEFAULT"] = cornerMap[a] ? [a, b] : ["", a];
116
+ function handlerBorderOpacity([, a = "", opacity]) {
117
+ const v = handler.bracket.percent(opacity);
118
+ if (a in directionMap && v != null)
119
+ return directionMap[a].map((i) => [`--un-border${i}-opacity`, v]);
120
+ }
121
+ function handlerRounded([, a = "", s = "DEFAULT"], { theme }) {
121
122
  const v = theme.borderRadius?.[s] || handler.auto.rem.fraction.bracket.cssvar(s);
122
- if (v !== void 0)
123
- return cornerMap[d].map((i) => [`border${i}-radius`, v]);
123
+ if (a in cornerMap && v != null)
124
+ return cornerMap[a].map((i) => [`border${i}-radius`, v]);
124
125
  }
125
126
 
126
127
  const opacity = [
127
128
  [/^op(?:acity)?-?(.+)$/, ([, d]) => ({ opacity: handler.bracket.percent.cssvar(d) })]
128
129
  ];
129
130
  const textColors = [
130
- [/^(?:text|color|c)-(.+)$/, colorResolver$1("color", "text")],
131
+ [/^(?:text|color|c)-(.+)$/, colorResolver("color", "text")],
131
132
  [/^(?:text|color|c)-op(?:acity)?-?(.+)$/, ([, opacity2]) => ({ "--un-text-opacity": handler.bracket.percent.cssvar(opacity2) })]
132
133
  ];
133
134
  const bgColors = [
134
- [/^bg-(.+)$/, colorResolver$1("background-color", "bg")],
135
+ [/^bg-(.+)$/, colorResolver("background-color", "bg")],
135
136
  [/^bg-op(?:acity)?-?(.+)$/, ([, opacity2]) => ({ "--un-bg-opacity": handler.bracket.percent(opacity2) })]
136
137
  ];
137
138
 
139
+ const transitionPropertyGroup = {
140
+ all: "all",
141
+ colors: ["color", "background-color", "border-color", "text-decoration-color", "fill", "stroke"].join(","),
142
+ opacity: "opacity",
143
+ shadow: "box-shadow",
144
+ transform: "transform"
145
+ };
138
146
  const transitionProperty = (prop) => {
139
- return handler.properties(prop) || (prop === "all" ? prop : void 0);
147
+ return handler.properties(prop) ?? transitionPropertyGroup[prop];
140
148
  };
141
149
  const transitions = [
142
- [/^transition(?:-([a-z-]+(?:,[a-z-]+)*))?(?:-(\d+))?$/, ([, prop = "all", duration = "150"]) => {
143
- const p = transitionProperty(prop);
150
+ [/^transition(?:-([a-z-]+(?:,[a-z-]+)*))?(?:-(\d+))?$/, ([, prop, duration = "150"]) => {
151
+ const p = prop != null ? transitionProperty(prop) : [transitionPropertyGroup.colors, "opacity", "box-shadow", "transform", "filter", "backdrop-filter"].join(",");
144
152
  if (p) {
145
153
  return {
146
154
  "transition-property": p,
@@ -149,14 +157,14 @@ const transitions = [
149
157
  };
150
158
  }
151
159
  }],
152
- [/^duration-(\d+)$/, ([, duration = "150"]) => ({ "transition-duration": `${duration}ms` })],
160
+ [/^(?:transition-)?delay-(.+)(?:s|ms)?$/, ([, d]) => ({ "transition-delay": handler.bracket.time(d) })],
161
+ [/^(?:transition-)?duration-(.+)(?:s|ms)?$/, ([, d]) => ({ "transition-duration": handler.bracket.time(d) })],
162
+ [/^ease-(.+)$/, ([, d]) => ({ "transition-timing-function": handler.bracket(d) })],
153
163
  ["ease", { "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)" }],
154
164
  ["ease-linear", { "transition-timing-function": "linear" }],
155
165
  ["ease-in", { "transition-timing-function": "cubic-bezier(0.4, 0, 1, 1)" }],
156
166
  ["ease-out", { "transition-timing-function": "cubic-bezier(0, 0, 0.2, 1)" }],
157
167
  ["ease-in-out", { "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)" }],
158
- [/^transition-delay-(\d+)$/, ([, v]) => ({ "transition-delay": `${v}ms` })],
159
- [/^transition-duration-(\d+)$/, ([, v]) => ({ "transition-duration": `${v}ms` })],
160
168
  [/^(?:transition-)?property-(.+)$/, ([, v]) => ({ "transition-property": handler.global(v) || transitionProperty(v) })],
161
169
  ["transition-property-none", { "transition-property": "none" }],
162
170
  ["property-none", { "transition-property": "none" }],
@@ -172,10 +180,11 @@ const flex = [
172
180
  ["flex-initial", { flex: "0 1 auto" }],
173
181
  ["flex-none", { flex: "none" }],
174
182
  [/^flex-(\[.+\])$/, ([, d]) => ({ flex: handler.bracket(d).replace(/\d+\/\d+/, ($1) => handler.fraction($1)) })],
175
- ["flex-shrink", { "flex-shrink": 1 }],
176
- ["flex-shrink-0", { "flex-shrink": 0 }],
177
- ["flex-grow", { "flex-grow": 1 }],
178
- ["flex-grow-0", { "flex-grow": 0 }],
183
+ [/^(?:flex-)?shrink$/, () => ({ "flex-shrink": 1 })],
184
+ [/^(?:flex-)?shrink-0$/, () => ({ "flex-shrink": 0 })],
185
+ [/^(?:flex-)?grow$/, () => ({ "flex-grow": 1 })],
186
+ [/^(?:flex-)?grow-0$/, () => ({ "flex-grow": 0 })],
187
+ [/^(?:flex-)?basis-(.+)$/, ([, d]) => ({ "flex-basis": handler.bracket.fraction.auto.rem(d) })],
179
188
  ["flex-row", { "flex-direction": "row" }],
180
189
  ["flex-row-reverse", { "flex-direction": "row-reverse" }],
181
190
  ["flex-col", { "flex-direction": "column" }],
@@ -197,14 +206,7 @@ const weightMap = {
197
206
  black: "900"
198
207
  };
199
208
  const fonts = [
200
- [/^font-(\w+)$/, ([, d], { theme }) => {
201
- const font = theme.fontFamily?.[d];
202
- if (font) {
203
- return {
204
- "font-family": font
205
- };
206
- }
207
- }],
209
+ [/^font-(\w+)$/, ([, d], { theme }) => ({ "font-family": theme.fontFamily?.[d] })],
208
210
  [/^text-(.+)$/, ([, s = "base"], { theme }) => {
209
211
  const size = handler.bracket.auto.rem(s);
210
212
  if (size)
@@ -218,37 +220,16 @@ const fonts = [
218
220
  };
219
221
  }
220
222
  }],
221
- [/^text-size-(.+)$/, ([, s]) => {
222
- const raw = handler.bracket.auto.rem(s);
223
- if (raw)
224
- return { "font-size": raw };
225
- }],
226
- [/^(?:font|fw)-?([^-]+)$/, ([, s]) => {
227
- const v = weightMap[s] || handler.number(s);
228
- if (v)
229
- return { "font-weight": v };
230
- }],
231
- [/^(?:leading|lh)-([^-]+)$/, ([, s], { theme }) => {
232
- const v = theme.lineHeight?.[s] || handler.bracket.auto.rem(s);
233
- if (v !== null)
234
- return { "line-height": v };
235
- }],
236
- [/^tracking-([^-]+)$/, ([, s], { theme }) => {
237
- const v = theme.letterSpacing?.[s] || handler.bracket.auto.rem(s);
238
- if (v !== null)
239
- return { "letter-spacing": v };
240
- }],
241
- [/^word-spacing-([^-]+)$/, ([, s], { theme }) => {
242
- const v = theme.wordSpacing?.[s] || handler.bracket.auto.rem(s);
243
- if (v !== null)
244
- return { "word-spacing": v };
245
- }]
223
+ [/^text-size-(.+)$/, ([, s]) => ({ "font-size": handler.bracket.auto.rem(s) })],
224
+ [/^(?:font|fw)-?([^-]+)$/, ([, s]) => ({ "font-weight": weightMap[s] || handler.number(s) })],
225
+ [/^(?:leading|lh)-([^-]+)$/, ([, s], { theme }) => ({ "line-height": theme.lineHeight?.[s] || handler.bracket.auto.rem(s) })],
226
+ [/^tracking-([^-]+)$/, ([, s], { theme }) => ({ "letter-spacing": theme.letterSpacing?.[s] || handler.bracket.auto.rem(s) })],
227
+ [/^word-spacing-([^-]+)$/, ([, s], { theme }) => ({ "word-spacing": theme.wordSpacing?.[s] || handler.bracket.auto.rem(s) })]
246
228
  ];
247
229
  const tabSizes = [
248
- [/^tab-?([^-]*)$/, ([, s]) => {
249
- s = s || "4";
250
- const v = handler.bracket.global.number(s);
251
- if (v !== null) {
230
+ [/^tab(?:-([^-]+))?$/, ([, s]) => {
231
+ const v = handler.bracket.global.number(s || "4");
232
+ if (v != null) {
252
233
  return {
253
234
  "-moz-tab-size": v,
254
235
  "-o-tab-size": v,
@@ -258,93 +239,77 @@ const tabSizes = [
258
239
  }]
259
240
  ];
260
241
  const textIndents = [
261
- [/^indent(?:-(.+))?$/, ([, s], { theme }) => {
262
- const v = theme.textIndent?.[s || "DEFAULT"] || handler.bracket.cssvar.fraction.auto.rem(s);
263
- if (v != null)
264
- return { "text-indent": v };
265
- }]
242
+ [/^indent(?:-(.+))?$/, ([, s], { theme }) => ({ "text-indent": theme.textIndent?.[s || "DEFAULT"] || handler.bracket.cssvar.fraction.auto.rem(s) })]
266
243
  ];
267
244
  const textStrokes = [
268
- [/^text-stroke(?:-(.+))?$/, ([, s], { theme }) => {
269
- const v = theme.textStrokeWidth?.[s || "DEFAULT"] || handler.bracket.cssvar.px(s);
270
- if (v != null)
271
- return { "-webkit-text-stroke-width": v };
272
- }],
273
- [/^text-stroke-(.+)$/, colorResolver$1("-webkit-text-stroke-color", "text-stroke")],
245
+ [/^text-stroke(?:-(.+))?$/, ([, s], { theme }) => ({ "-webkit-text-stroke-width": theme.textStrokeWidth?.[s || "DEFAULT"] || handler.bracket.cssvar.px(s) })],
246
+ [/^text-stroke-(.+)$/, colorResolver("-webkit-text-stroke-color", "text-stroke")],
274
247
  [/^text-stroke-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-text-stroke-opacity": handler.bracket.percent(opacity) })]
275
248
  ];
276
249
  const textShadows = [
277
- [/^text-shadow(?:-(.+))?$/, ([, s], { theme }) => {
278
- const v = theme.textShadow?.[s || "DEFAULT"] || handler.bracket.cssvar(s);
279
- if (v != null)
280
- return { "text-shadow": v };
281
- }]
250
+ [/^text-shadow(?:-(.+))?$/, ([, s], { theme }) => ({ "text-shadow": theme.textShadow?.[s || "DEFAULT"] || handler.bracket.cssvar(s) })]
282
251
  ];
283
252
 
253
+ const directions = {
254
+ "": "",
255
+ "x": "column-",
256
+ "y": "row-"
257
+ };
258
+ const handleGap = ([, d = "", s]) => {
259
+ const v = handler.bracket.auto.rem(s);
260
+ if (v != null) {
261
+ return {
262
+ [`grid-${directions[d]}gap`]: v,
263
+ [`${directions[d]}gap`]: v
264
+ };
265
+ }
266
+ };
284
267
  const gaps = [
285
- [/^(?:flex-|grid-)?gap-(x-|y-)?([^-]+)$/, ([, d = "", s]) => {
286
- const v = handler.bracket.auto.rem(s);
287
- if (v != null) {
288
- const direction = {
289
- "": "",
290
- "x-": "column-",
291
- "y-": "row-"
292
- }[d];
293
- return {
294
- [`grid-${direction}gap`]: v,
295
- [`${direction}gap`]: v
296
- };
297
- }
298
- }]
268
+ [/^(?:flex-|grid-)?gap-()([^-]+)$/, handleGap],
269
+ [/^(?:flex-|grid-)?gap-([xy])-([^-]+)$/, handleGap]
299
270
  ];
300
271
 
301
- const calSize = (s, theme) => toArray(theme.fontSize?.[s] || handler.bracket.auto.rem(s))[0];
272
+ const rowCol = (s) => s.replace("col", "column");
302
273
  const autoDirection = (selector, theme) => {
303
- if (selector === "min")
304
- return "min-content";
305
- else if (selector === "max")
306
- return "max-content";
307
- else if (selector === "fr")
308
- return "minmax(0,1fr)";
309
- return calSize(selector, theme);
274
+ const v = theme.fontSize?.[selector];
275
+ if (v != null)
276
+ return toArray(v)[0];
277
+ switch (selector) {
278
+ case "min":
279
+ return "min-content";
280
+ case "max":
281
+ return "max-content";
282
+ case "fr":
283
+ return "minmax(0,1fr)";
284
+ }
285
+ return handler.bracket.auto.rem(selector);
310
286
  };
311
287
  const grids = [
312
288
  ["grid", { display: "grid" }],
313
289
  ["inline-grid", { display: "inline-grid" }],
314
- [/^(?:grid-)?col-start-([\w.-]+)$/, ([, v]) => ({ "grid-column-start": v })],
315
- [/^(?:grid-)?col-end-([\w.]+)$/, ([, v]) => ({ "grid-column-end": v })],
316
- [/^(?:grid-)?row-start-([\w.-]+)$/, ([, v]) => ({ "grid-row-start": v })],
317
- [/^(?:grid-)?row-end-([\w.-]+)$/, ([, v]) => ({ "grid-row-end": v })],
318
- [/^(?:grid-)?(row|col)-(.+)$/, ([, d, v]) => {
319
- const key = d === "row" ? "grid-row" : "grid-column";
320
- let raw = handler.bracket(v);
321
- if (raw)
322
- return { [key]: raw };
323
- const parts = v.split("-");
324
- if (parts.length === 1 && parts[0] === "auto")
325
- return { [key]: parts[0] };
326
- if (parts[0] === "span") {
327
- if (parts[1] === "full")
328
- return { [key]: "1/-1" };
329
- raw = handler.number.bracket(parts[1]);
330
- if (raw)
331
- return { [key]: `span ${raw}/span ${raw}` };
332
- }
290
+ [/^(?:grid-)?(row|col)-(.+)$/, ([, c, v]) => ({ [`grid-${rowCol(c)}`]: handler.bracket.auto(v) })],
291
+ [/^(?:grid-)?(row|col)-span-(.+)$/, ([, c, s]) => {
292
+ if (s === "full")
293
+ return { [`grid-${rowCol(c)}`]: "1/-1" };
294
+ const v = handler.bracket.number(s);
295
+ if (v != null)
296
+ return { [`grid-${rowCol(c)}`]: `span ${v}/span ${v}` };
333
297
  }],
334
- [/^(?:grid-)?auto-cols-([\w.-]+)$/, ([, v], { theme }) => ({ "grid-auto-columns": autoDirection(v, theme) })],
335
- [/^(?:grid-)?auto-flow-([\w.-]+)$/, ([, v]) => ({ "grid-auto-flow": v.replace("col", "column").split("-").join(" ") })],
336
- [/^(?:grid-)?auto-rows-([\w.-]+)$/, ([, v], { theme }) => ({ "grid-auto-rows": autoDirection(v, theme) })],
337
- [/^grid-cols-(.+)$/, ([, v]) => ({ "grid-template-columns": handler.bracket(v) })],
338
- [/^grid-rows-(.+)$/, ([, v]) => ({ "grid-template-rows": handler.bracket(v) })],
339
- [/^grid-cols-minmax-([\w.-]+)$/, ([, d]) => ({ "grid-template-columns": `repeat(auto-fill,minmax(${d},1fr))` })],
340
- [/^grid-rows-minmax-([\w.-]+)$/, ([, d]) => ({ "grid-template-rows": `repeat(auto-fill,minmax(${d},1fr))` })],
341
- [/^grid-cols-(\d+)$/, ([, d]) => ({ "grid-template-columns": `repeat(${d},minmax(0,1fr))` })],
342
- [/^grid-rows-(\d+)$/, ([, d]) => ({ "grid-template-rows": `repeat(${d},minmax(0,1fr))` })]
298
+ [/^(?:grid-)?(row|col)-start-([\w.-]+)$/, ([, c, v]) => ({ [`grid-${rowCol(c)}-start`]: v })],
299
+ [/^(?:grid-)?(row|col)-end-([\w.-]+)$/, ([, c, v]) => ({ [`grid-${rowCol(c)}-end`]: v })],
300
+ [/^(?:grid-)?auto-(rows|cols)-([\w.-]+)$/, ([, c, v], { theme }) => ({ [`grid-auto-${rowCol(c)}`]: autoDirection(v, theme) })],
301
+ [/^(?:grid-auto-flow|auto-flow|grid-flow)-((?:row|col)(?:-dense)?)$/, ([, v]) => ({ "grid-auto-flow": rowCol(v).replace("-", " ") })],
302
+ [/^grid-(rows|cols)-(\[.+\])$/, ([, c, v]) => ({ [`grid-template-${rowCol(c)}`]: handler.bracket(v) })],
303
+ [/^grid-(rows|cols)-minmax-([\w.-]+)$/, ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(auto-fill,minmax(${d},1fr))` })],
304
+ [/^grid-(rows|cols)-(\d+)$/, ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(${d},minmax(0,1fr))` })],
305
+ ["grid-rows-none", { "grid-template-rows": "none" }],
306
+ ["grid-cols-none", { "grid-template-columns": "none" }]
343
307
  ];
344
308
 
345
309
  const overflowValues = [
346
310
  "auto",
347
311
  "hidden",
312
+ "clip",
348
313
  "visible",
349
314
  "scroll"
350
315
  ];
@@ -353,7 +318,6 @@ const overflows = [
353
318
  [/^(?:overflow|of)-([xy])-(.+)$/, ([, d, v]) => overflowValues.includes(v) ? { [`overflow-${d}`]: v } : void 0]
354
319
  ];
355
320
 
356
- const basicSet = ["auto", "start", "end", "center", "stretch"];
357
321
  const positions = [
358
322
  [/^(?:position-|pos-)?(relative|absolute|fixed|sticky)$/, ([, v]) => ({ position: v })],
359
323
  [/^(?:position-|pos-)?(static)$/, ([, v]) => ({ position: v })]
@@ -365,8 +329,15 @@ const justifies = [
365
329
  ["justify-between", { "justify-content": "space-between" }],
366
330
  ["justify-around", { "justify-content": "space-around" }],
367
331
  ["justify-evenly", { "justify-content": "space-evenly" }],
368
- ...basicSet.map((i) => [`justify-items-${i}`, { "justify-items": i }]),
369
- ...basicSet.map((i) => [`justify-self-${i}`, { "justify-self": i }])
332
+ ["justify-items-start", { "justify-items": "start" }],
333
+ ["justify-items-end", { "justify-items": "end" }],
334
+ ["justify-items-center", { "justify-items": "center" }],
335
+ ["justify-items-stretch", { "justify-items": "stretch" }],
336
+ ["justify-self-auto", { "justify-self": "auto" }],
337
+ ["justify-self-start", { "justify-self": "start" }],
338
+ ["justify-self-end", { "justify-self": "end" }],
339
+ ["justify-self-center", { "justify-self": "center" }],
340
+ ["justify-self-stretch", { "justify-self": "stretch" }]
370
341
  ];
371
342
  const orders = [
372
343
  [/^order-(.+)$/, ([, v]) => ({ order: handler.bracket.number(v) })],
@@ -375,9 +346,9 @@ const orders = [
375
346
  ["order-none", { order: "0" }]
376
347
  ];
377
348
  const alignments = [
349
+ ["content-center", { "align-content": "center" }],
378
350
  ["content-start", { "align-content": "flex-start" }],
379
351
  ["content-end", { "align-content": "flex-end" }],
380
- ["content-center", { "align-content": "center" }],
381
352
  ["content-between", { "align-content": "space-between" }],
382
353
  ["content-around", { "align-content": "space-around" }],
383
354
  ["content-evenly", { "align-content": "space-evenly" }],
@@ -390,29 +361,39 @@ const alignments = [
390
361
  ["self-start", { "align-self": "flex-start" }],
391
362
  ["self-end", { "align-self": "flex-end" }],
392
363
  ["self-center", { "align-self": "center" }],
393
- ["self-stretch", { "align-self": "stretch" }]
364
+ ["self-stretch", { "align-self": "stretch" }],
365
+ ["self-baseline", { "align-self": "baseline" }]
394
366
  ];
395
367
  const placements = [
368
+ ["place-content-center", { "place-content": "center" }],
396
369
  ["place-content-start", { "place-content": "start" }],
397
370
  ["place-content-end", { "place-content": "end" }],
398
- ["place-content-center", { "place-content": "center" }],
399
371
  ["place-content-between", { "place-content": "space-between" }],
400
372
  ["place-content-around", { "place-content": "space-around" }],
401
373
  ["place-content-evenly", { "place-content": "space-evenly" }],
402
374
  ["place-content-stretch", { "place-content": "stretch" }],
403
- ...basicSet.map((i) => [`place-items-${i}`, { "place-items": i }]),
404
- ...basicSet.map((i) => [`place-self-${i}`, { "place-self": i }])
375
+ ["place-items-start", { "place-items": "start" }],
376
+ ["place-items-end", { "place-items": "end" }],
377
+ ["place-items-center", { "place-items": "center" }],
378
+ ["place-items-stretch", { "place-items": "stretch" }],
379
+ ["place-self-auto", { "place-self": "auto" }],
380
+ ["place-self-start", { "place-self": "start" }],
381
+ ["place-self-end", { "place-self": "end" }],
382
+ ["place-self-center", { "place-self": "center" }],
383
+ ["place-self-stretch", { "place-self": "stretch" }]
405
384
  ];
406
385
  function handleInsetValue(v) {
407
386
  return { auto: "auto", full: "100%" }[v] ?? handler.bracket.fraction.cssvar.auto.rem(v);
408
387
  }
388
+ function handleInsetValues([, d, v]) {
389
+ const r = handleInsetValue(v);
390
+ if (r != null && d in directionMap)
391
+ return directionMap[d].map((i) => [i.slice(1), r]);
392
+ }
409
393
  const insets = [
410
- [/^(?:position-|pos-)?(top|left|right|bottom|inset)-(.+)$/, ([, d, v]) => ({ [d]: handleInsetValue(v) })],
411
- [/^(?:position-|pos-)?inset-([xy])-(.+)$/, ([, d, v]) => {
412
- const r = handleInsetValue(v);
413
- if (r != null && d in directionMap)
414
- return directionMap[d].map((i) => [i.slice(1), r]);
415
- }]
394
+ [/^(?:position-|pos-)?inset-(.+)$/, ([, v]) => ({ inset: handleInsetValue(v) })],
395
+ [/^(?:position-|pos-)?inset-([xy])-(.+)$/, handleInsetValues],
396
+ [/^(?:position-|pos-)?(top|left|right|bottom)-(.+)$/, ([, d, v]) => ({ [d]: handleInsetValue(v) })]
416
397
  ];
417
398
  const floats = [
418
399
  ["float-left", { float: "left" }],
@@ -475,7 +456,7 @@ const contents = [
475
456
  ];
476
457
  const breaks = [
477
458
  ["break-normal", { "overflow-wrap": "normal", "word-break": "normal" }],
478
- ["break-word", { "overflow-wrap": "break-word" }],
459
+ ["break-words", { "overflow-wrap": "break-word" }],
479
460
  ["break-all", { "word-break": "break-all" }]
480
461
  ];
481
462
  const textOverflows = [
@@ -507,35 +488,30 @@ const fontSmoothings = [
507
488
  ];
508
489
 
509
490
  const rings = [
510
- [/^ring-?(.*)$/, ([, d]) => {
491
+ [/^ring(?:-(.+))?$/, ([, d]) => {
511
492
  const value = handler.px(d || "1");
512
493
  if (value) {
513
494
  return {
514
495
  "--un-ring-inset": varEmpty,
515
496
  "--un-ring-offset-width": "0px",
516
497
  "--un-ring-offset-color": "#fff",
517
- "--un-ring-color": "rgba(59, 130, 246, .5)",
498
+ "--un-ring-color": "rgba(147, 197, 253, .5)",
518
499
  "--un-ring-offset-shadow": "var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color)",
519
500
  "--un-ring-shadow": `var(--un-ring-inset) 0 0 0 calc(${value} + var(--un-ring-offset-width)) var(--un-ring-color)`,
520
- "-webkit-box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow, 0 0 #0000)",
521
501
  "box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow, 0 0 #0000)"
522
502
  };
523
503
  }
524
504
  }],
525
505
  ["ring-offset", { "--un-ring-offset-width": "1px" }],
526
- [/^ring-offset-(.+)$/, ([, d]) => {
527
- const value = handler.px(d || "1");
528
- if (value)
529
- return { "--un-ring-offset-width": value };
530
- }],
531
- [/^ring-(.+)$/, colorResolver$1("--un-ring-color", "ring")],
506
+ [/^ring-offset-(.+)$/, ([, d]) => ({ "--un-ring-offset-width": handler.px(d || "1") })],
507
+ [/^ring-(.+)$/, colorResolver("--un-ring-color", "ring")],
532
508
  [/^ring-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-ring-opacity": handler.bracket.percent(opacity) })],
533
- [/^ring-offset-(.+)$/, colorResolver$1("--un-ring-offset-color", "ring-offset")],
509
+ [/^ring-offset-(.+)$/, colorResolver("--un-ring-offset-color", "ring-offset")],
534
510
  [/^ring-offset-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-ring-offset-opacity": handler.bracket.percent(opacity) })],
535
511
  ["ring-inset", { "--un-ring-inset": "inset" }]
536
512
  ];
537
513
 
538
- const colorResolver = (body, theme) => {
514
+ const shadowColorResolver = (body, theme) => {
539
515
  const data = parseColor(body, theme);
540
516
  if (!data)
541
517
  return;
@@ -553,47 +529,56 @@ const colorResolver = (body, theme) => {
553
529
  }
554
530
  };
555
531
  const boxShadows = [
556
- [/^shadow-?(.*)$/, ([, d], { theme }) => {
532
+ [/^shadow(?:-(.+))?$/, ([, d], { theme }) => {
557
533
  const value = theme.boxShadow?.[d || "DEFAULT"];
558
534
  if (value) {
559
535
  return {
536
+ "--un-shadow-inset": varEmpty,
560
537
  "--un-shadow-color": "0,0,0",
561
538
  "--un-shadow": value,
562
539
  "box-shadow": "var(--un-ring-offset-shadow, 0 0 #0000), var(--un-ring-shadow, 0 0 #0000), var(--un-shadow)"
563
540
  };
564
541
  }
565
542
  }],
566
- [/^shadow-(.+)$/, ([, d], { theme }) => colorResolver(d, theme)]
543
+ [/^shadow-(.+)$/, ([, d], { theme }) => shadowColorResolver(d, theme)],
544
+ ["shadow-inset", { "--un-shadow-inset": "inset" }]
567
545
  ];
568
546
 
569
547
  function getPropName(minmax, hw) {
570
548
  return `${minmax ? `${minmax}-` : ""}${hw === "h" ? "height" : "width"}`;
571
549
  }
572
- function getThemeValue(minmax, hw, theme, prop) {
550
+ function getSizeValue(minmax, hw, theme, prop) {
573
551
  let str = `${hw === "h" ? "height" : "width"}`;
574
552
  if (minmax)
575
553
  str = `${minmax}${capitalize(str)}`;
576
- return theme[str]?.[prop];
554
+ const v = theme[str]?.[prop];
555
+ if (v != null)
556
+ return v;
557
+ switch (prop) {
558
+ case "fit":
559
+ case "max":
560
+ case "min":
561
+ return `${prop}-content`;
562
+ }
563
+ return handler.bracket.cssvar.fraction.auto.rem(prop);
577
564
  }
578
565
  const sizes = [
579
- [/^(?:(min|max)-)?(w|h)-(.+)$/, ([, m, w, s], { theme }) => {
580
- const v = getThemeValue(m, w, theme, s) || handler.bracket.cssvar.fraction.auto.rem(s);
581
- if (v != null)
582
- return { [getPropName(m, w)]: v };
583
- }],
584
- [/^(?:(min|max)-)?(w)-screen-(.+)$/, ([, m, w, s], { theme }) => {
585
- const v = theme.breakpoints?.[s];
586
- if (v != null)
587
- return { [getPropName(m, w)]: v };
588
- }]
589
- ];
566
+ [/^(?:(min|max)-)?(w|h)-(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) })],
567
+ [/^(?:(min|max)-)?(w)-screen-(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: theme.breakpoints?.[s] })]
568
+ ];
569
+ function getAspectRatio(prop) {
570
+ if (/^\d+\/\d+$/.test(prop))
571
+ return prop;
572
+ switch (prop) {
573
+ case "square":
574
+ return "1/1";
575
+ case "video":
576
+ return "16/9";
577
+ }
578
+ return handler.bracket.cssvar.auto.number(prop);
579
+ }
590
580
  const aspectRatio = [
591
- ["aspect-ratio-auto", { "aspect-ratio": "auto" }],
592
- [/^aspect-ratio-(.+)$/, ([, d]) => {
593
- const v = (/^\d+\/\d+$/.test(d) ? d : null) || handler.bracket.cssvar.number(d);
594
- if (v != null)
595
- return { "aspect-ratio": v };
596
- }]
581
+ [/^aspect-(?:ratio-)?(.+)$/, ([, d]) => ({ "aspect-ratio": getAspectRatio(d) })]
597
582
  ];
598
583
 
599
584
  const paddings = [
@@ -629,36 +614,26 @@ const transformBase = {
629
614
  };
630
615
  const transforms = [
631
616
  ["transform", transformBase],
632
- [/^preserve-(3d|flat)$/, ([, value]) => ({ "transform-style": value === "3d" ? `preserve-${value}` : value })],
633
- [/^translate()-(.+)$/, handleTranslate],
617
+ [/^origin-([-\w]{3,})$/, ([, s]) => ({ "transform-origin": positionMap[s] })],
618
+ [/^translate-()(.+)$/, handleTranslate],
634
619
  [/^translate-([xyz])-(.+)$/, handleTranslate],
635
- [/^scale()-(.+)$/, handleScale],
636
- [/^scale-([xyz])-(.+)$/, handleScale],
637
620
  [/^rotate-(.+)$/, handleRotate],
638
- [/^rotate-((?!\[)[^-]+?)(?:deg)?$/, handleRotateWithUnit],
621
+ [/^skew-()(.+)$/, handleSkew],
639
622
  [/^skew-([xy])-(.+)$/, handleSkew],
640
- [/^skew-([xy])-((?!\[)[^-]+?)(?:deg)?$/, handleSkewWithUnit],
623
+ [/^scale-()(.+)$/, handleScale],
624
+ [/^scale-([xyz])-(.+)$/, handleScale],
625
+ ["preserve-3d", { "transform-style": "preserve-3d" }],
626
+ ["preserve-flat", { "transform-style": "flat" }],
641
627
  ["transform-gpu", transformGpu],
642
628
  ["transform-cpu", transformCpu],
643
- ["transform-none", { transform: "none" }],
644
- ["origin-center", { "transform-origin": "center" }],
645
- ["origin-top", { "transform-origin": "top" }],
646
- ["origin-top-right", { "transform-origin": "top right" }],
647
- ["origin-right", { "transform-origin": "right" }],
648
- ["origin-bottom-right", { "transform-origin": "bottom right" }],
649
- ["origin-bottom", { "transform-origin": "bottom" }],
650
- ["origin-bottom-left", { "transform-origin": "bottom left" }],
651
- ["origin-left", { "transform-origin": "left" }],
652
- ["origin-top-left", { "transform-origin": "top left" }]
629
+ ["transform-none", { transform: "none" }]
653
630
  ];
654
631
  function handleTranslate([, d, b]) {
655
632
  const v = handler.bracket.fraction.auto.rem(b);
656
633
  if (v != null) {
657
634
  return [
658
635
  transformBase,
659
- [
660
- ...xyzMap[d].map((i) => [`--un-translate${i}`, v])
661
- ]
636
+ xyzMap[d].map((i) => [`--un-translate${i}`, v])
662
637
  ];
663
638
  }
664
639
  }
@@ -667,23 +642,12 @@ function handleScale([, d, b]) {
667
642
  if (v != null) {
668
643
  return [
669
644
  transformBase,
670
- [
671
- ...xyzMap[d].map((i) => [`--un-scale${i}`, v])
672
- ]
673
- ];
674
- }
675
- }
676
- function handleRotateWithUnit([, b]) {
677
- const v = handler.bracket.number(b);
678
- if (v != null) {
679
- return [
680
- transformBase,
681
- { "--un-rotate": `${v}deg` }
645
+ xyzMap[d].map((i) => [`--un-scale${i}`, v])
682
646
  ];
683
647
  }
684
648
  }
685
649
  function handleRotate([, b]) {
686
- const v = handler.bracket(b);
650
+ const v = handler.bracket.degree(b);
687
651
  if (v != null) {
688
652
  return [
689
653
  transformBase,
@@ -691,17 +655,8 @@ function handleRotate([, b]) {
691
655
  ];
692
656
  }
693
657
  }
694
- function handleSkewWithUnit([, d, b]) {
695
- const v = handler.bracket.number(b);
696
- if (v != null) {
697
- return [
698
- transformBase,
699
- { [`--un-skew-${d}`]: `${v}deg` }
700
- ];
701
- }
702
- }
703
658
  function handleSkew([, d, b]) {
704
- const v = handler.bracket(b);
659
+ const v = handler.bracket.degree(b);
705
660
  if (v != null) {
706
661
  return [
707
662
  transformBase,
@@ -717,17 +672,12 @@ const variablesAbbrMap = {
717
672
  "backface": "backface-visibility",
718
673
  "whitespace": "white-space",
719
674
  "break": "word-break",
720
- "b": "border-color",
721
- "border": "border-color",
722
- "color": "color",
723
675
  "case": "text-transform",
724
676
  "origin": "transform-origin",
725
- "bg": "background-color",
726
677
  "bg-opacity": "background-opacity",
727
678
  "tab": "tab-size",
728
679
  "underline": "text-decoration-thickness",
729
680
  "underline-offset": "text-underline-offset",
730
- "text": "color",
731
681
  "grid-cols": "grid-template-columns",
732
682
  "grid-rows": "grid-template-rows",
733
683
  "auto-flow": "grid-auto-flow",
@@ -742,15 +692,8 @@ const variablesAbbrMap = {
742
692
  const cssVariables = [
743
693
  [/^(.+)-\$(.+)$/, ([, name, varname]) => {
744
694
  const prop = variablesAbbrMap[name];
745
- if (prop) {
746
- return {
747
- [prop]: `var(--${varname})`
748
- };
749
- }
750
- }],
751
- [/^(?:border|b)-([^-]+)-\$(.+)$/, ([, a, v]) => {
752
- if (a in directionMap)
753
- return directionMap[a].map((i) => [`border${i}-color`, `var(--${v})`]);
695
+ if (prop)
696
+ return { [prop]: `var(--${varname})` };
754
697
  }]
755
698
  ];
756
699
 
@@ -766,14 +709,15 @@ ${constructCSS({ animation: "__un_qm 0.5s ease-in-out alternate infinite" })}`;
766
709
  ];
767
710
 
768
711
  const textDecorations = [
769
- ["underline", { "text-decoration": "underline" }],
770
- ["line-through", { "text-decoration": "line-through" }],
771
- ["decoration-underline", { "text-decoration": "underline" }],
772
- ["decoration-line-through", { "text-decoration": "line-through" }],
712
+ ["underline", { "text-decoration-line": "underline" }],
713
+ ["overline", { "text-decoration-line": "overline" }],
714
+ ["line-through", { "text-decoration-line": "line-through" }],
715
+ ["decoration-underline", { "text-decoration-line": "underline" }],
716
+ ["decoration-line-through", { "text-decoration-line": "line-through" }],
773
717
  [/^(?:underline|decoration)-(?:size-)?(.+)$/, ([, s]) => ({ "text-decoration-thickness": handler.bracket.px(s) })],
774
718
  [/^(?:underline|decoration)-(auto|from-font)$/, ([, s]) => ({ "text-decoration-thickness": s })],
775
719
  [/^(?:underline|decoration)-(.+)$/, (match, ctx) => {
776
- const result = colorResolver$1("text-decoration-color", "line")(match, ctx);
720
+ const result = colorResolver("text-decoration-color", "line")(match, ctx);
777
721
  if (result) {
778
722
  return {
779
723
  "-webkit-text-decoration-color": result["text-decoration-color"],
@@ -789,15 +733,11 @@ const textDecorations = [
789
733
  ];
790
734
 
791
735
  const svgUtilities = [
792
- [/^fill-(.+)$/, colorResolver$1("fill", "fill")],
736
+ [/^fill-(.+)$/, colorResolver("fill", "fill")],
793
737
  [/^fill-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-fill-opacity": handler.bracket.percent(opacity) })],
794
738
  ["fill-none", { fill: "none" }],
795
- [/^stroke-(?:size-|width-)?(.+)$/, ([, s]) => {
796
- const v = handler.bracket.fraction.px.number(s);
797
- if (v)
798
- return { "stroke-width": v };
799
- }],
800
- [/^stroke-(.+)$/, colorResolver$1("stroke", "stroke")],
739
+ [/^stroke-(?:size-|width-)?(.+)$/, ([, s]) => ({ "stroke-width": handler.bracket.fraction.px.number(s) })],
740
+ [/^stroke-(.+)$/, colorResolver("stroke", "stroke")],
801
741
  [/^stroke-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-stroke-opacity": handler.bracket.percent(opacity) })],
802
742
  ["stroke-none", { stroke: "none" }]
803
743
  ];