@unocss/preset-mini 0.19.0 → 0.20.4

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,5 +1,5 @@
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';
2
- import { toArray, cacheFunction } from '@unocss/core';
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
+ import { toArray } from '@unocss/core';
3
3
  import { C as CONTROL_BYPASS_PSEUDO_CLASS } from './pseudo.mjs';
4
4
 
5
5
  const verticalAlignAlias = {
@@ -19,7 +19,7 @@ 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
25
  [/^outline-(auto|dotted|dashed|solid|double|groove|ridge|inset|outset|inherit|initial|revert|unset)$/, ([, c]) => ({ "outline-style": c })],
@@ -36,63 +36,61 @@ const willChange = [
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], { options: { variablePrefix: p } }) => ({ [`--${p}border-opacity`]: handler.bracket.percent(opacity) })],
47
- [/^(?:border|b)-([^-]+)-op(?:acity)?-?(.+)$/, ([, a, opacity], { options: { variablePrefix: p } }) => {
48
- const v = handler.bracket.percent(opacity);
49
- const d = directionMap[a];
50
- if (v !== void 0 && d)
51
- return d.map((i) => [`--${p}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 }) => {
63
63
  return color !== void 0 && !!parseColor(color, theme)?.color;
64
64
  };
65
- const borderColorResolver = (direction) => ([, body], { theme, options: { variablePrefix: p } }) => {
65
+ 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
- [`--${p}border-opacity`]: 1,
83
- [`border${direction}-color`]: `rgba(${rgba.slice(0, 3).join(",")},var(--${p}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
- [`--${p}border-opacity`]: 1,
88
- [`--${p}border${direction}-opacity`]: `var(--${p}border-opacity)`,
89
- [`border${direction}-color`]: `rgba(${rgba.slice(0, 3).join(",")},var(--${p}border${direction}-opacity))`
85
+ "--un-border-opacity": (opacity && handler.cssvar(opacity)) ?? 1,
86
+ [`--un-border${direction}-opacity`]: "var(--un-border-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" }],
@@ -176,6 +184,7 @@ const flex = [
176
184
  ["flex-shrink-0", { "flex-shrink": 0 }],
177
185
  ["flex-grow", { "flex-grow": 1 }],
178
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
230
  [/^tab-?([^-]*)$/, ([, s]) => {
249
- s = s || "4";
250
- const v = handler.bracket.global.number(s);
251
- if (v !== null) {
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,44 +239,34 @@ 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
272
  const calSize = (s, theme) => toArray(theme.fontSize?.[s] || handler.bracket.auto.rem(s))[0];
@@ -353,7 +324,6 @@ const overflows = [
353
324
  [/^(?:overflow|of)-([xy])-(.+)$/, ([, d, v]) => overflowValues.includes(v) ? { [`overflow-${d}`]: v } : void 0]
354
325
  ];
355
326
 
356
- const basicSet = ["auto", "start", "end", "center", "stretch"];
357
327
  const positions = [
358
328
  [/^(?:position-|pos-)?(relative|absolute|fixed|sticky)$/, ([, v]) => ({ position: v })],
359
329
  [/^(?:position-|pos-)?(static)$/, ([, v]) => ({ position: v })]
@@ -365,8 +335,15 @@ const justifies = [
365
335
  ["justify-between", { "justify-content": "space-between" }],
366
336
  ["justify-around", { "justify-content": "space-around" }],
367
337
  ["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 }])
338
+ ["justify-items-start", { "justify-items": "start" }],
339
+ ["justify-items-end", { "justify-items": "end" }],
340
+ ["justify-items-center", { "justify-items": "center" }],
341
+ ["justify-items-stretch", { "justify-items": "stretch" }],
342
+ ["justify-self-auto", { "justify-self": "auto" }],
343
+ ["justify-self-start", { "justify-self": "start" }],
344
+ ["justify-self-end", { "justify-self": "end" }],
345
+ ["justify-self-center", { "justify-self": "center" }],
346
+ ["justify-self-stretch", { "justify-self": "stretch" }]
370
347
  ];
371
348
  const orders = [
372
349
  [/^order-(.+)$/, ([, v]) => ({ order: handler.bracket.number(v) })],
@@ -375,9 +352,9 @@ const orders = [
375
352
  ["order-none", { order: "0" }]
376
353
  ];
377
354
  const alignments = [
355
+ ["content-center", { "align-content": "center" }],
378
356
  ["content-start", { "align-content": "flex-start" }],
379
357
  ["content-end", { "align-content": "flex-end" }],
380
- ["content-center", { "align-content": "center" }],
381
358
  ["content-between", { "align-content": "space-between" }],
382
359
  ["content-around", { "align-content": "space-around" }],
383
360
  ["content-evenly", { "align-content": "space-evenly" }],
@@ -390,29 +367,39 @@ const alignments = [
390
367
  ["self-start", { "align-self": "flex-start" }],
391
368
  ["self-end", { "align-self": "flex-end" }],
392
369
  ["self-center", { "align-self": "center" }],
393
- ["self-stretch", { "align-self": "stretch" }]
370
+ ["self-stretch", { "align-self": "stretch" }],
371
+ ["self-baseline", { "align-self": "baseline" }]
394
372
  ];
395
373
  const placements = [
374
+ ["place-content-center", { "place-content": "center" }],
396
375
  ["place-content-start", { "place-content": "start" }],
397
376
  ["place-content-end", { "place-content": "end" }],
398
- ["place-content-center", { "place-content": "center" }],
399
377
  ["place-content-between", { "place-content": "space-between" }],
400
378
  ["place-content-around", { "place-content": "space-around" }],
401
379
  ["place-content-evenly", { "place-content": "space-evenly" }],
402
380
  ["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 }])
381
+ ["place-items-start", { "place-items": "start" }],
382
+ ["place-items-end", { "place-items": "end" }],
383
+ ["place-items-center", { "place-items": "center" }],
384
+ ["place-items-stretch", { "place-items": "stretch" }],
385
+ ["place-self-auto", { "place-self": "auto" }],
386
+ ["place-self-start", { "place-self": "start" }],
387
+ ["place-self-end", { "place-self": "end" }],
388
+ ["place-self-center", { "place-self": "center" }],
389
+ ["place-self-stretch", { "place-self": "stretch" }]
405
390
  ];
406
391
  function handleInsetValue(v) {
407
392
  return { auto: "auto", full: "100%" }[v] ?? handler.bracket.fraction.cssvar.auto.rem(v);
408
393
  }
394
+ function handleInsetValues([, d, v]) {
395
+ const r = handleInsetValue(v);
396
+ if (r != null && d in directionMap)
397
+ return directionMap[d].map((i) => [i.slice(1), r]);
398
+ }
409
399
  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
- }]
400
+ [/^(?:position-|pos-)?inset-()(.+)$/, handleInsetValues],
401
+ [/^(?:position-|pos-)?inset-([xy])-(.+)$/, handleInsetValues],
402
+ [/^(?:position-|pos-)?(top|left|right|bottom)-(.+)$/, ([, d, v]) => ({ [d]: handleInsetValue(v) })]
416
403
  ];
417
404
  const floats = [
418
405
  ["float-left", { float: "left" }],
@@ -432,7 +419,6 @@ const boxSizing = [
432
419
  ["box-content", { "box-sizing": "content-box" }]
433
420
  ];
434
421
 
435
- const varEmptyFn = cacheFunction((prefix) => `var(--${prefix}empty,/*!*/ /*!*/)`);
436
422
  const varEmpty = "var(--un-empty,/*!*/ /*!*/)";
437
423
  const displays = [
438
424
  ["inline", { display: "inline" }],
@@ -508,31 +494,30 @@ const fontSmoothings = [
508
494
  ];
509
495
 
510
496
  const rings = [
511
- [/^ring-?(.*)$/, ([, d], { options: { variablePrefix: p } }) => {
497
+ [/^ring-?(.*)$/, ([, d]) => {
512
498
  const value = handler.px(d || "1");
513
499
  if (value) {
514
500
  return {
515
- [`--${p}ring-inset`]: varEmptyFn(p),
516
- [`--${p}ring-offset-width`]: "0px",
517
- [`--${p}ring-offset-color`]: "#fff",
518
- [`--${p}ring-color`]: "rgba(59, 130, 246, .5)",
519
- [`--${p}ring-offset-shadow`]: `var(--${p}ring-inset) 0 0 0 var(--${p}ring-offset-width) var(--${p}ring-offset-color)`,
520
- [`--${p}ring-shadow`]: `var(--${p}ring-inset) 0 0 0 calc(${value} + var(--${p}ring-offset-width)) var(--${p}ring-color)`,
521
- "-webkit-box-shadow": `var(--${p}ring-offset-shadow), var(--${p}ring-shadow), var(--${p}shadow, 0 0 #0000)`,
522
- "box-shadow": `var(--${p}ring-offset-shadow), var(--${p}ring-shadow), var(--${p}shadow, 0 0 #0000)`
501
+ "--un-ring-inset": varEmpty,
502
+ "--un-ring-offset-width": "0px",
503
+ "--un-ring-offset-color": "#fff",
504
+ "--un-ring-color": "rgba(59, 130, 246, .5)",
505
+ "--un-ring-offset-shadow": "var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color)",
506
+ "--un-ring-shadow": `var(--un-ring-inset) 0 0 0 calc(${value} + var(--un-ring-offset-width)) var(--un-ring-color)`,
507
+ "box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow, 0 0 #0000)"
523
508
  };
524
509
  }
525
510
  }],
526
- [/^ring-offset$/, (_, { options: { variablePrefix: p } }) => ({ [`--${p}ring-offset-width`]: "1px" })],
527
- [/^ring-offset-(.+)$/, ([, d], { options: { variablePrefix: p } }) => ({ [`--${p}ring-offset-width`]: handler.px(d || "1") })],
528
- [/^ring-(.+)$/, (m, ctx) => colorResolver$1(`--${ctx.options.variablePrefix}ring-color`, "ring")(m, ctx)],
529
- [/^ring-op(?:acity)?-?(.+)$/, ([, opacity], { options: { variablePrefix: p } }) => ({ [`--${p}ring-opacity`]: handler.bracket.percent(opacity) })],
530
- [/^ring-offset-(.+)$/, (m, ctx) => colorResolver$1(`--${ctx.options.variablePrefix}ring-offset-color`, "ring-offset")(m, ctx)],
531
- [/^ring-offset-op(?:acity)?-?(.+)$/, ([, opacity], { options: { variablePrefix: p } }) => ({ [`--${p}ring-offset-opacity`]: handler.bracket.percent(opacity) })],
532
- [/^ring-inset$/, (_, { options: { variablePrefix: p } }) => ({ [`--${p}ring-inset`]: "inset" })]
511
+ ["ring-offset", { "--un-ring-offset-width": "1px" }],
512
+ [/^ring-offset-(.+)$/, ([, d]) => ({ "--un-ring-offset-width": handler.px(d || "1") })],
513
+ [/^ring-(.+)$/, colorResolver("--un-ring-color", "ring")],
514
+ [/^ring-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-ring-opacity": handler.bracket.percent(opacity) })],
515
+ [/^ring-offset-(.+)$/, colorResolver("--un-ring-offset-color", "ring-offset")],
516
+ [/^ring-offset-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-ring-offset-opacity": handler.bracket.percent(opacity) })],
517
+ ["ring-inset", { "--un-ring-inset": "inset" }]
533
518
  ];
534
519
 
535
- const colorResolver = (body, theme) => {
520
+ const shadowColorResolver = (body, theme) => {
536
521
  const data = parseColor(body, theme);
537
522
  if (!data)
538
523
  return;
@@ -554,13 +539,15 @@ const boxShadows = [
554
539
  const value = theme.boxShadow?.[d || "DEFAULT"];
555
540
  if (value) {
556
541
  return {
542
+ "--un-shadow-inset": varEmpty,
557
543
  "--un-shadow-color": "0,0,0",
558
544
  "--un-shadow": value,
559
545
  "box-shadow": "var(--un-ring-offset-shadow, 0 0 #0000), var(--un-ring-shadow, 0 0 #0000), var(--un-shadow)"
560
546
  };
561
547
  }
562
548
  }],
563
- [/^shadow-(.+)$/, ([, d], { theme }) => colorResolver(d, theme)]
549
+ [/^shadow-(.+)$/, ([, d], { theme }) => shadowColorResolver(d, theme)],
550
+ ["shadow-inset", { "--un-shadow-inset": "inset" }]
564
551
  ];
565
552
 
566
553
  function getPropName(minmax, hw) {
@@ -585,11 +572,17 @@ const sizes = [
585
572
  }]
586
573
  ];
587
574
  const aspectRatio = [
588
- ["aspect-ratio-auto", { "aspect-ratio": "auto" }],
589
- [/^aspect-ratio-(.+)$/, ([, d]) => {
590
- const v = (/^\d+\/\d+$/.test(d) ? d : null) || handler.bracket.cssvar.number(d);
575
+ [/^aspect-(?:ratio-)?(.+)$/, ([, d]) => {
576
+ if (/^\d+\/\d+$/.test(d))
577
+ return { "aspect-ratio": d };
578
+ const v = {
579
+ auto: "auto",
580
+ square: "1/1",
581
+ video: "16/9"
582
+ }[d];
591
583
  if (v != null)
592
584
  return { "aspect-ratio": v };
585
+ return { "aspect-ratio": handler.bracket.cssvar.number(d) };
593
586
  }]
594
587
  ];
595
588
 
@@ -638,24 +631,14 @@ const transforms = [
638
631
  ["transform-gpu", transformGpu],
639
632
  ["transform-cpu", transformCpu],
640
633
  ["transform-none", { transform: "none" }],
641
- ["origin-center", { "transform-origin": "center" }],
642
- ["origin-top", { "transform-origin": "top" }],
643
- ["origin-top-right", { "transform-origin": "top right" }],
644
- ["origin-right", { "transform-origin": "right" }],
645
- ["origin-bottom-right", { "transform-origin": "bottom right" }],
646
- ["origin-bottom", { "transform-origin": "bottom" }],
647
- ["origin-bottom-left", { "transform-origin": "bottom left" }],
648
- ["origin-left", { "transform-origin": "left" }],
649
- ["origin-top-left", { "transform-origin": "top left" }]
634
+ [/^origin-([-\w]{3,})$/, ([, s]) => ({ "transform-origin": positionMap[s] })]
650
635
  ];
651
636
  function handleTranslate([, d, b]) {
652
637
  const v = handler.bracket.fraction.auto.rem(b);
653
638
  if (v != null) {
654
639
  return [
655
640
  transformBase,
656
- [
657
- ...xyzMap[d].map((i) => [`--un-translate${i}`, v])
658
- ]
641
+ xyzMap[d].map((i) => [`--un-translate${i}`, v])
659
642
  ];
660
643
  }
661
644
  }
@@ -664,9 +647,7 @@ function handleScale([, d, b]) {
664
647
  if (v != null) {
665
648
  return [
666
649
  transformBase,
667
- [
668
- ...xyzMap[d].map((i) => [`--un-scale${i}`, v])
669
- ]
650
+ xyzMap[d].map((i) => [`--un-scale${i}`, v])
670
651
  ];
671
652
  }
672
653
  }
@@ -714,17 +695,12 @@ const variablesAbbrMap = {
714
695
  "backface": "backface-visibility",
715
696
  "whitespace": "white-space",
716
697
  "break": "word-break",
717
- "b": "border-color",
718
- "border": "border-color",
719
- "color": "color",
720
698
  "case": "text-transform",
721
699
  "origin": "transform-origin",
722
- "bg": "background-color",
723
700
  "bg-opacity": "background-opacity",
724
701
  "tab": "tab-size",
725
702
  "underline": "text-decoration-thickness",
726
703
  "underline-offset": "text-underline-offset",
727
- "text": "color",
728
704
  "grid-cols": "grid-template-columns",
729
705
  "grid-rows": "grid-template-rows",
730
706
  "auto-flow": "grid-auto-flow",
@@ -739,15 +715,8 @@ const variablesAbbrMap = {
739
715
  const cssVariables = [
740
716
  [/^(.+)-\$(.+)$/, ([, name, varname]) => {
741
717
  const prop = variablesAbbrMap[name];
742
- if (prop) {
743
- return {
744
- [prop]: `var(--${varname})`
745
- };
746
- }
747
- }],
748
- [/^(?:border|b)-([^-]+)-\$(.+)$/, ([, a, v]) => {
749
- if (a in directionMap)
750
- return directionMap[a].map((i) => [`border${i}-color`, `var(--${v})`]);
718
+ if (prop)
719
+ return { [prop]: `var(--${varname})` };
751
720
  }]
752
721
  ];
753
722
 
@@ -770,7 +739,7 @@ const textDecorations = [
770
739
  [/^(?:underline|decoration)-(?:size-)?(.+)$/, ([, s]) => ({ "text-decoration-thickness": handler.bracket.px(s) })],
771
740
  [/^(?:underline|decoration)-(auto|from-font)$/, ([, s]) => ({ "text-decoration-thickness": s })],
772
741
  [/^(?:underline|decoration)-(.+)$/, (match, ctx) => {
773
- const result = colorResolver$1("text-decoration-color", "line")(match, ctx);
742
+ const result = colorResolver("text-decoration-color", "line")(match, ctx);
774
743
  if (result) {
775
744
  return {
776
745
  "-webkit-text-decoration-color": result["text-decoration-color"],
@@ -786,15 +755,11 @@ const textDecorations = [
786
755
  ];
787
756
 
788
757
  const svgUtilities = [
789
- [/^fill-(.+)$/, colorResolver$1("fill", "fill")],
758
+ [/^fill-(.+)$/, colorResolver("fill", "fill")],
790
759
  [/^fill-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-fill-opacity": handler.bracket.percent(opacity) })],
791
760
  ["fill-none", { fill: "none" }],
792
- [/^stroke-(?:size-|width-)?(.+)$/, ([, s]) => {
793
- const v = handler.bracket.fraction.px.number(s);
794
- if (v)
795
- return { "stroke-width": v };
796
- }],
797
- [/^stroke-(.+)$/, colorResolver$1("stroke", "stroke")],
761
+ [/^stroke-(?:size-|width-)?(.+)$/, ([, s]) => ({ "stroke-width": handler.bracket.fraction.px.number(s) })],
762
+ [/^stroke-(.+)$/, colorResolver("stroke", "stroke")],
798
763
  [/^stroke-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-stroke-opacity": handler.bracket.percent(opacity) })],
799
764
  ["stroke-none", { stroke: "none" }]
800
765
  ];
@@ -855,4 +820,4 @@ const rules = [
855
820
  questionMark
856
821
  ].flat(1);
857
822
 
858
- export { cssVariables as $, sizes as A, aspectRatio as B, paddings as C, margins as D, varEmptyFn as E, varEmpty as F, displays as G, appearances as H, cursors as I, pointerEvents as J, resizes as K, userSelects as L, whitespaces as M, contents as N, breaks as O, textOverflows as P, textTransforms as Q, fontStyles as R, fontSmoothings as S, svgUtilities as T, transforms as U, transitions as V, fonts as W, tabSizes as X, textIndents as Y, textStrokes as Z, textShadows as _, appearance as a, textDecorations as a0, borders as b, opacity as c, textColors as d, bgColors as e, flex as f, gaps as g, grids as h, overflows as i, justifies as j, orders as k, alignments as l, placements as m, insets as n, outline as o, positions as p, floats as q, rules as r, boxSizing as s, textAligns as t, questionMark as u, verticalAligns as v, willChange as w, rings as x, boxShadows as y, zIndexes as z };
823
+ export { textDecorations as $, sizes as A, aspectRatio as B, paddings as C, margins as D, varEmpty as E, displays as F, appearances as G, cursors as H, pointerEvents as I, resizes as J, userSelects as K, whitespaces as L, contents as M, breaks as N, textOverflows as O, textTransforms as P, fontStyles as Q, fontSmoothings as R, svgUtilities as S, transforms as T, transitions as U, fonts as V, tabSizes as W, textIndents as X, textStrokes as Y, textShadows as Z, cssVariables as _, appearance as a, borders as b, opacity as c, textColors as d, bgColors as e, flex as f, gaps as g, grids as h, overflows as i, justifies as j, orders as k, alignments as l, placements as m, insets as n, outline as o, positions as p, floats as q, rules as r, boxSizing as s, textAligns as t, questionMark as u, verticalAligns as v, willChange as w, rings as x, boxShadows as y, zIndexes as z };