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