@unocss/preset-mini 0.22.6 → 0.24.1

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.
@@ -37,12 +37,28 @@ const variantBreakpoints = (matcher, { theme }) => {
37
37
  }
38
38
  };
39
39
 
40
+ const scopeMatcher = (strict, name, template) => {
41
+ const re = strict ? new RegExp(`^${name}(?:-\\[(.+?)\\])[:-]`) : new RegExp(`^${name}(?:-\\[(.+?)\\])?[:-]`);
42
+ return (matcher) => {
43
+ const match = matcher.match(re);
44
+ if (match) {
45
+ return {
46
+ matcher: matcher.slice(match[0].length),
47
+ selector: (s) => template.replace("&&-s", s).replace("&&-c", match[1] ?? "*")
48
+ };
49
+ }
50
+ };
51
+ };
40
52
  const variantCombinators = [
41
- variants$1.variantMatcher("all", (input) => `${input} *`),
42
- variants$1.variantMatcher("children", (input) => `${input}>*`),
43
- variants$1.variantMatcher("next", (input) => `${input}+*`),
44
- variants$1.variantMatcher("sibling", (input) => `${input}+*`),
45
- variants$1.variantMatcher("siblings", (input) => `${input}~*`),
53
+ scopeMatcher(false, "all", "&&-s &&-c"),
54
+ scopeMatcher(false, "children", "&&-s>&&-c"),
55
+ scopeMatcher(false, "next", "&&-s+&&-c"),
56
+ scopeMatcher(false, "sibling", "&&-s+&&-c"),
57
+ scopeMatcher(false, "siblings", "&&-s~&&-c"),
58
+ scopeMatcher(true, "group", "&&-c &&-s"),
59
+ scopeMatcher(true, "parent", "&&-c>&&-s"),
60
+ scopeMatcher(true, "previous", "&&-c+&&-s"),
61
+ scopeMatcher(true, "peer", "&&-c~&&-s"),
46
62
  variants$1.variantMatcher("svg", (input) => `${input} svg`)
47
63
  ];
48
64
 
@@ -74,6 +90,17 @@ const variantLanguageDirections = [
74
90
  variants$1.variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
75
91
  ];
76
92
 
93
+ const variantLayer = {
94
+ match(matcher) {
95
+ const match = matcher.match(/layer-([\d\w]+)[:-]/);
96
+ if (match) {
97
+ return {
98
+ matcher: matcher.slice(match[0].length),
99
+ layer: match[1]
100
+ };
101
+ }
102
+ }
103
+ };
77
104
  const variantImportant = {
78
105
  match(matcher) {
79
106
  if (matcher.startsWith("!")) {
@@ -170,6 +197,10 @@ const PartClassesRE = /(part-\[(.+)]:)(.+)/;
170
197
  const PseudoElementsRE = new RegExp(`^(${PseudoElementsStr})[:-]`);
171
198
  const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
172
199
  const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
200
+ const sortValue = (pseudo) => {
201
+ if (pseudo === "active")
202
+ return 1;
203
+ };
173
204
  const taggedPseudoClassMatcher = (tag, parent, combinator) => {
174
205
  const re = new RegExp(`^${tag}-((?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))[:-]`);
175
206
  const rawRe = new RegExp(`^${core.escapeRegExp(parent)}:`);
@@ -180,8 +211,9 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
180
211
  if (match[2])
181
212
  pseudo = `:${match[2]}(${pseudo})`;
182
213
  return {
183
- matcher: input.slice(match[1].length + tag.length + 2),
184
- selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`
214
+ matcher: input.slice(match[0].length),
215
+ selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`,
216
+ sort: sortValue(match[3])
185
217
  };
186
218
  }
187
219
  };
@@ -191,7 +223,7 @@ const variantPseudoElements = (input) => {
191
223
  if (match) {
192
224
  const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
193
225
  return {
194
- matcher: input.slice(match[1].length + 1),
226
+ matcher: input.slice(match[0].length),
195
227
  selector: (s) => `${s}${pseudo}`
196
228
  };
197
229
  }
@@ -202,8 +234,9 @@ const variantPseudoClasses = {
202
234
  if (match) {
203
235
  const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
204
236
  return {
205
- matcher: input.slice(match[1].length + 1),
206
- selector: (s) => `${s}${pseudo}`
237
+ matcher: input.slice(match[0].length),
238
+ selector: (s) => `${s}${pseudo}`,
239
+ sort: sortValue(match[1])
207
240
  };
208
241
  }
209
242
  },
@@ -216,7 +249,7 @@ const variantPseudoClassFunctions = {
216
249
  const fn = match[1];
217
250
  const pseudo = PseudoClasses[match[2]] || `:${match[2]}`;
218
251
  return {
219
- matcher: input.slice(match[1].length + match[2].length + 2),
252
+ matcher: input.slice(match[0].length),
220
253
  selector: (s) => `${s}:${fn}(${pseudo})`
221
254
  };
222
255
  }
@@ -233,6 +266,14 @@ const variantTaggedPseudoClasses = (options = {}) => {
233
266
  {
234
267
  match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
235
268
  multiPass: true
269
+ },
270
+ {
271
+ match: taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
272
+ multiPass: true
273
+ },
274
+ {
275
+ match: taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
276
+ multiPass: true
236
277
  }
237
278
  ];
238
279
  };
@@ -251,6 +292,7 @@ const partClasses = {
251
292
  };
252
293
 
253
294
  const variants = (options) => [
295
+ variantLayer,
254
296
  variantNegative,
255
297
  variantImportant,
256
298
  variantPrint,
@@ -273,6 +315,7 @@ exports.variantColorsMediaOrClass = variantColorsMediaOrClass;
273
315
  exports.variantCombinators = variantCombinators;
274
316
  exports.variantImportant = variantImportant;
275
317
  exports.variantLanguageDirections = variantLanguageDirections;
318
+ exports.variantLayer = variantLayer;
276
319
  exports.variantMotions = variantMotions;
277
320
  exports.variantNegative = variantNegative;
278
321
  exports.variantOrientations = variantOrientations;
@@ -35,12 +35,28 @@ const variantBreakpoints = (matcher, { theme }) => {
35
35
  }
36
36
  };
37
37
 
38
+ const scopeMatcher = (strict, name, template) => {
39
+ const re = strict ? new RegExp(`^${name}(?:-\\[(.+?)\\])[:-]`) : new RegExp(`^${name}(?:-\\[(.+?)\\])?[:-]`);
40
+ return (matcher) => {
41
+ const match = matcher.match(re);
42
+ if (match) {
43
+ return {
44
+ matcher: matcher.slice(match[0].length),
45
+ selector: (s) => template.replace("&&-s", s).replace("&&-c", match[1] ?? "*")
46
+ };
47
+ }
48
+ };
49
+ };
38
50
  const variantCombinators = [
39
- variantMatcher("all", (input) => `${input} *`),
40
- variantMatcher("children", (input) => `${input}>*`),
41
- variantMatcher("next", (input) => `${input}+*`),
42
- variantMatcher("sibling", (input) => `${input}+*`),
43
- variantMatcher("siblings", (input) => `${input}~*`),
51
+ scopeMatcher(false, "all", "&&-s &&-c"),
52
+ scopeMatcher(false, "children", "&&-s>&&-c"),
53
+ scopeMatcher(false, "next", "&&-s+&&-c"),
54
+ scopeMatcher(false, "sibling", "&&-s+&&-c"),
55
+ scopeMatcher(false, "siblings", "&&-s~&&-c"),
56
+ scopeMatcher(true, "group", "&&-c &&-s"),
57
+ scopeMatcher(true, "parent", "&&-c>&&-s"),
58
+ scopeMatcher(true, "previous", "&&-c+&&-s"),
59
+ scopeMatcher(true, "peer", "&&-c~&&-s"),
44
60
  variantMatcher("svg", (input) => `${input} svg`)
45
61
  ];
46
62
 
@@ -72,6 +88,17 @@ const variantLanguageDirections = [
72
88
  variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
73
89
  ];
74
90
 
91
+ const variantLayer = {
92
+ match(matcher) {
93
+ const match = matcher.match(/layer-([\d\w]+)[:-]/);
94
+ if (match) {
95
+ return {
96
+ matcher: matcher.slice(match[0].length),
97
+ layer: match[1]
98
+ };
99
+ }
100
+ }
101
+ };
75
102
  const variantImportant = {
76
103
  match(matcher) {
77
104
  if (matcher.startsWith("!")) {
@@ -168,6 +195,10 @@ const PartClassesRE = /(part-\[(.+)]:)(.+)/;
168
195
  const PseudoElementsRE = new RegExp(`^(${PseudoElementsStr})[:-]`);
169
196
  const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
170
197
  const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
198
+ const sortValue = (pseudo) => {
199
+ if (pseudo === "active")
200
+ return 1;
201
+ };
171
202
  const taggedPseudoClassMatcher = (tag, parent, combinator) => {
172
203
  const re = new RegExp(`^${tag}-((?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))[:-]`);
173
204
  const rawRe = new RegExp(`^${escapeRegExp(parent)}:`);
@@ -178,8 +209,9 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
178
209
  if (match[2])
179
210
  pseudo = `:${match[2]}(${pseudo})`;
180
211
  return {
181
- matcher: input.slice(match[1].length + tag.length + 2),
182
- selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`
212
+ matcher: input.slice(match[0].length),
213
+ selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`,
214
+ sort: sortValue(match[3])
183
215
  };
184
216
  }
185
217
  };
@@ -189,7 +221,7 @@ const variantPseudoElements = (input) => {
189
221
  if (match) {
190
222
  const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
191
223
  return {
192
- matcher: input.slice(match[1].length + 1),
224
+ matcher: input.slice(match[0].length),
193
225
  selector: (s) => `${s}${pseudo}`
194
226
  };
195
227
  }
@@ -200,8 +232,9 @@ const variantPseudoClasses = {
200
232
  if (match) {
201
233
  const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
202
234
  return {
203
- matcher: input.slice(match[1].length + 1),
204
- selector: (s) => `${s}${pseudo}`
235
+ matcher: input.slice(match[0].length),
236
+ selector: (s) => `${s}${pseudo}`,
237
+ sort: sortValue(match[1])
205
238
  };
206
239
  }
207
240
  },
@@ -214,7 +247,7 @@ const variantPseudoClassFunctions = {
214
247
  const fn = match[1];
215
248
  const pseudo = PseudoClasses[match[2]] || `:${match[2]}`;
216
249
  return {
217
- matcher: input.slice(match[1].length + match[2].length + 2),
250
+ matcher: input.slice(match[0].length),
218
251
  selector: (s) => `${s}:${fn}(${pseudo})`
219
252
  };
220
253
  }
@@ -231,6 +264,14 @@ const variantTaggedPseudoClasses = (options = {}) => {
231
264
  {
232
265
  match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
233
266
  multiPass: true
267
+ },
268
+ {
269
+ match: taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
270
+ multiPass: true
271
+ },
272
+ {
273
+ match: taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
274
+ multiPass: true
234
275
  }
235
276
  ];
236
277
  };
@@ -249,6 +290,7 @@ const partClasses = {
249
290
  };
250
291
 
251
292
  const variants = (options) => [
293
+ variantLayer,
252
294
  variantNegative,
253
295
  variantImportant,
254
296
  variantPrint,
@@ -265,4 +307,4 @@ const variants = (options) => [
265
307
  ...variantLanguageDirections
266
308
  ];
267
309
 
268
- export { variantBreakpoints as a, variantCombinators as b, variantMotions as c, variantOrientations as d, variantPrint as e, variantColorsMediaOrClass as f, variantLanguageDirections as g, variantImportant as h, variantNegative as i, variantPseudoElements as j, variantPseudoClasses as k, variantPseudoClassFunctions as l, variantTaggedPseudoClasses as m, partClasses as p, variants as v };
310
+ export { variantBreakpoints as a, variantCombinators as b, variantMotions as c, variantOrientations as d, variantPrint as e, variantColorsMediaOrClass as f, variantLanguageDirections as g, variantLayer as h, variantImportant as i, variantNegative as j, variantPseudoElements as k, variantPseudoClasses as l, variantPseudoClassFunctions as m, variantTaggedPseudoClasses as n, partClasses as p, variants as v };
@@ -2,6 +2,221 @@
2
2
 
3
3
  const core = require('@unocss/core');
4
4
 
5
+ const cssColorFunctions = ["hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "rgb", "rgba"];
6
+ function hex2rgba(hex = "") {
7
+ const color = parseHexColor(hex);
8
+ if (color != null) {
9
+ const { components, alpha } = color;
10
+ if (alpha === void 0)
11
+ return components;
12
+ return [...components, alpha];
13
+ }
14
+ }
15
+ function parseCssColor(str = "") {
16
+ const color = parseColor$1(str);
17
+ if (color == null)
18
+ return;
19
+ const { type: casedType, components, alpha } = color;
20
+ const type = casedType.toLowerCase();
21
+ if (components.length === 0)
22
+ return;
23
+ if (["rgba", "hsla"].includes(type) && alpha === void 0)
24
+ return;
25
+ if (cssColorFunctions.includes(type) && components.length !== 3)
26
+ return;
27
+ return { type, components, alpha };
28
+ }
29
+ function colorToString(color, alphaOverride) {
30
+ const { components } = color;
31
+ let { alpha, type } = color;
32
+ alpha = alphaOverride ?? alpha;
33
+ type = type.toLowerCase();
34
+ if (["hsla", "hsl", "rgba", "rgb"].includes(type))
35
+ return `${type.replace("a", "")}a(${components.join(",")}${alpha == null ? "" : `,${alpha}`})`;
36
+ alpha = alpha == null ? "" : ` / ${alpha}`;
37
+ if (cssColorFunctions.includes(type))
38
+ return `${type}(${components.join(" ")}${alpha})`;
39
+ return `color(${type} ${components.join(" ")}${alpha})`;
40
+ }
41
+ function parseColor$1(str) {
42
+ if (!str)
43
+ return;
44
+ let color = parseHexColor(str);
45
+ if (color != null)
46
+ return color;
47
+ color = cssColorKeyword(str);
48
+ if (color != null)
49
+ return color;
50
+ color = parseCssCommaColorFunction(str);
51
+ if (color != null)
52
+ return color;
53
+ color = parseCssSpaceColorFunction(str);
54
+ if (color != null)
55
+ return color;
56
+ color = parseCssColorFunction(str);
57
+ if (color != null)
58
+ return color;
59
+ }
60
+ function parseHexColor(str) {
61
+ const [, body] = str.match(/^#?([\da-f]+)$/i) || [];
62
+ if (!body)
63
+ return;
64
+ switch (body.length) {
65
+ case 3:
66
+ case 4:
67
+ const digits = Array.from(body, (s) => Number.parseInt(s, 16)).map((n) => n << 4 | n);
68
+ return {
69
+ type: "rgb",
70
+ components: digits.slice(0, 3),
71
+ alpha: body.length === 3 ? void 0 : Math.round(digits[3] / 255 * 100) / 100
72
+ };
73
+ case 6:
74
+ case 8:
75
+ const value = Number.parseInt(body, 16);
76
+ return {
77
+ type: "rgb",
78
+ components: body.length === 6 ? [value >> 16 & 255, value >> 8 & 255, value & 255] : [value >> 24 & 255, value >> 16 & 255, value >> 8 & 255],
79
+ alpha: body.length === 6 ? void 0 : Math.round((value & 255) / 255 * 100) / 100
80
+ };
81
+ }
82
+ }
83
+ function cssColorKeyword(str) {
84
+ const color = {
85
+ rebeccapurple: [102, 51, 153, 1]
86
+ }[str];
87
+ if (color != null) {
88
+ return {
89
+ type: "rgb",
90
+ components: color.slice(0, 3),
91
+ alpha: color[3]
92
+ };
93
+ }
94
+ }
95
+ function parseCssCommaColorFunction(color) {
96
+ const match = color.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);
97
+ if (!match)
98
+ return;
99
+ const [, type, componentString] = match;
100
+ const components = getComponents(componentString, ",", 5);
101
+ if (components && [3, 4].includes(components.length)) {
102
+ return {
103
+ type,
104
+ components: components.slice(0, 3),
105
+ alpha: components[3]
106
+ };
107
+ }
108
+ }
109
+ const cssColorFunctionsRe = new RegExp(`^(${cssColorFunctions.join("|")})\\((.+)\\)$`, "i");
110
+ function parseCssSpaceColorFunction(color) {
111
+ const match = color.match(cssColorFunctionsRe);
112
+ if (!match)
113
+ return;
114
+ const [, fn, componentString] = match;
115
+ const parsed = parseCssSpaceColorValues(`${fn} ${componentString}`);
116
+ if (parsed) {
117
+ const { alpha, components: [type, ...components] } = parsed;
118
+ return {
119
+ type,
120
+ components,
121
+ alpha
122
+ };
123
+ }
124
+ }
125
+ function parseCssColorFunction(color) {
126
+ const match = color.match(/^color\((.+)\)$/);
127
+ if (!match)
128
+ return;
129
+ const parsed = parseCssSpaceColorValues(match[1]);
130
+ if (parsed) {
131
+ const { alpha, components: [type, ...components] } = parsed;
132
+ return {
133
+ type,
134
+ components,
135
+ alpha
136
+ };
137
+ }
138
+ }
139
+ function parseCssSpaceColorValues(componentString) {
140
+ const components = getComponents(componentString);
141
+ if (!components)
142
+ return;
143
+ let totalComponents = components.length;
144
+ if (components[totalComponents - 2] === "/") {
145
+ return {
146
+ components: components.slice(0, totalComponents - 2),
147
+ alpha: components[totalComponents - 1]
148
+ };
149
+ }
150
+ if (components[totalComponents - 2] != null && (components[totalComponents - 2].endsWith("/") || components[totalComponents - 1].startsWith("/"))) {
151
+ const removed = components.splice(totalComponents - 2);
152
+ components.push(removed.join(" "));
153
+ --totalComponents;
154
+ }
155
+ const withAlpha = getComponents(components[totalComponents - 1], "/", 3);
156
+ if (!withAlpha)
157
+ return;
158
+ if (withAlpha.length === 1 || withAlpha[withAlpha.length - 1] === "")
159
+ return { components };
160
+ const alpha = withAlpha.pop();
161
+ components[totalComponents - 1] = withAlpha.join("/");
162
+ return {
163
+ components,
164
+ alpha
165
+ };
166
+ }
167
+ function getComponent(str, separator) {
168
+ str = str.trim();
169
+ if (str === "")
170
+ return;
171
+ const l = str.length;
172
+ let parenthesis = 0;
173
+ for (let i = 0; i < l; i++) {
174
+ switch (str[i]) {
175
+ case "(":
176
+ parenthesis++;
177
+ break;
178
+ case ")":
179
+ if (--parenthesis < 0)
180
+ return;
181
+ break;
182
+ case separator:
183
+ if (parenthesis === 0) {
184
+ const component = str.slice(0, i).trim();
185
+ if (component === "")
186
+ return;
187
+ return [
188
+ component,
189
+ str.slice(i + 1).trim()
190
+ ];
191
+ }
192
+ }
193
+ }
194
+ return [
195
+ str,
196
+ ""
197
+ ];
198
+ }
199
+ function getComponents(str, separator, limit) {
200
+ separator = separator ?? " ";
201
+ if (separator.length !== 1)
202
+ return;
203
+ limit = limit ?? 10;
204
+ const components = [];
205
+ let i = 0;
206
+ while (str !== "") {
207
+ if (++i > limit)
208
+ return;
209
+ const componentPair = getComponent(str, separator);
210
+ if (!componentPair)
211
+ return;
212
+ const [component, rest] = componentPair;
213
+ components.push(component);
214
+ str = rest;
215
+ }
216
+ if (components.length > 0)
217
+ return components;
218
+ }
219
+
5
220
  const directionMap = {
6
221
  "l": ["-left"],
7
222
  "r": ["-right"],
@@ -141,7 +356,7 @@ const cssProps = [
141
356
  "clip-path",
142
357
  "clip"
143
358
  ];
144
- const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
359
+ const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax|rpx)?$/i;
145
360
  const numberRE = /^(-?[0-9.]+)$/i;
146
361
  const unitOnlyRE = /^(px)$/i;
147
362
  function round(n) {
@@ -306,58 +521,65 @@ const parseColor = (body, theme) => {
306
521
  else if (no && colorData)
307
522
  color = colorData[no];
308
523
  }
309
- const rgba = core.hex2rgba(color);
310
- const alpha = opacity ? opacity[0] === "[" ? handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba?.[3];
311
- const hasAlpha = alpha != null && !Number.isNaN(alpha);
312
- if (rgba) {
313
- if (hasAlpha) {
314
- rgba[3] = typeof alpha === "string" && !alpha.includes("%") ? parseFloat(alpha) : alpha;
315
- } else {
316
- rgba.splice(3);
317
- }
318
- }
319
524
  return {
320
525
  opacity,
321
526
  name,
322
527
  no,
323
528
  color,
324
- rgba,
325
- alpha: hasAlpha ? alpha : void 0
529
+ cssColor: parseCssColor(color),
530
+ alpha: handler.bracket.cssvar.percent(opacity ?? "")
326
531
  };
327
532
  };
328
533
  const colorResolver = (property, varName) => ([, body], { theme }) => {
329
534
  const data = parseColor(body, theme);
330
535
  if (!data)
331
536
  return;
332
- const { alpha, opacity, color, rgba } = data;
333
- if (!color)
334
- return;
335
- if (rgba) {
537
+ const { alpha, color, cssColor } = data;
538
+ if (cssColor) {
336
539
  if (alpha != null) {
337
540
  return {
338
- [property]: `rgba(${rgba.join(",")})`
541
+ [property]: colorToString(cssColor, alpha)
339
542
  };
340
543
  } else {
341
544
  return {
342
- [`--un-${varName}-opacity`]: (opacity && handler.cssvar(opacity)) ?? 1,
343
- [property]: `rgba(${rgba.join(",")},var(--un-${varName}-opacity))`
545
+ [`--un-${varName}-opacity`]: cssColor.alpha ?? 1,
546
+ [property]: colorToString(cssColor, `var(--un-${varName}-opacity)`)
344
547
  };
345
548
  }
346
- } else {
549
+ } else if (color) {
347
550
  return {
348
- [property]: color.replace("%alpha", `${alpha || 1}`)
551
+ [property]: color.replace("%alpha", `${alpha ?? 1}`)
349
552
  };
350
553
  }
351
554
  };
555
+ const colorableShadows = (shadows, colorVar) => {
556
+ const colored = [];
557
+ shadows = core.toArray(shadows);
558
+ for (let i = 0; i < shadows.length; i++) {
559
+ const components = getComponents(shadows[i], " ", 6);
560
+ if (!components || components.length < 3)
561
+ return shadows;
562
+ const color = parseCssColor(components.pop());
563
+ if (color == null)
564
+ return shadows;
565
+ colored.push(`${components.join(" ")} var(${colorVar}, ${colorToString(color)})`);
566
+ }
567
+ return colored;
568
+ };
352
569
 
353
570
  exports.colorResolver = colorResolver;
571
+ exports.colorToString = colorToString;
572
+ exports.colorableShadows = colorableShadows;
354
573
  exports.cornerMap = cornerMap;
355
574
  exports.directionMap = directionMap;
356
575
  exports.directionSize = directionSize;
576
+ exports.getComponents = getComponents;
357
577
  exports.h = h;
358
578
  exports.handler = handler;
579
+ exports.hex2rgba = hex2rgba;
359
580
  exports.insetMap = insetMap;
360
581
  exports.parseColor = parseColor;
582
+ exports.parseCssColor = parseCssColor;
361
583
  exports.positionMap = positionMap;
362
584
  exports.valueHandlers = valueHandlers;
363
585
  exports.xyzMap = xyzMap;