@unocss/preset-mini 0.42.0 → 0.43.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.
- package/README.md +48 -0
- package/dist/chunks/{utilities.cjs → colors2.cjs} +233 -231
- package/dist/chunks/{utilities.mjs → colors2.mjs} +233 -232
- package/dist/chunks/default.cjs +3 -3
- package/dist/chunks/default.mjs +3 -3
- package/dist/chunks/default2.cjs +141 -143
- package/dist/chunks/default2.mjs +26 -28
- package/dist/chunks/default3.cjs +25 -21
- package/dist/chunks/default3.mjs +23 -19
- package/dist/chunks/transform.cjs +46 -39
- package/dist/chunks/transform.mjs +18 -11
- package/dist/index.cjs +4 -3
- package/dist/index.d.ts +7 -1
- package/dist/index.mjs +3 -2
- package/dist/rules.cjs +1 -1
- package/dist/rules.d.ts +1 -1
- package/dist/rules.mjs +1 -1
- package/dist/theme.cjs +1 -1
- package/dist/theme.mjs +1 -1
- package/dist/{utilities-654ad3bd.d.ts → utilities-b44b330d.d.ts} +3 -1
- package/dist/utils.cjs +25 -24
- package/dist/utils.d.ts +2 -3
- package/dist/utils.mjs +1 -1
- package/dist/variants.cjs +1 -1
- package/dist/variants.d.ts +1 -1
- package/dist/variants.mjs +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { escapeSelector, createValueHandler, toArray, escapeRegExp } from '@unocss/core';
|
|
2
2
|
|
|
3
3
|
const directionMap = {
|
|
4
4
|
"l": ["-left"],
|
|
@@ -94,233 +94,6 @@ const globalKeywords = [
|
|
|
94
94
|
"unset"
|
|
95
95
|
];
|
|
96
96
|
|
|
97
|
-
const cssColorFunctions = ["hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "rgb", "rgba"];
|
|
98
|
-
const alphaPlaceholders = ["%alpha", "<alpha-value>"];
|
|
99
|
-
const alphaPlaceholdersRE = new RegExp(alphaPlaceholders.map((v) => escapeRegExp(v)).join("|"));
|
|
100
|
-
function hex2rgba(hex = "") {
|
|
101
|
-
const color = parseHexColor(hex);
|
|
102
|
-
if (color != null) {
|
|
103
|
-
const { components, alpha } = color;
|
|
104
|
-
if (alpha == null)
|
|
105
|
-
return components;
|
|
106
|
-
return [...components, alpha];
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function parseCssColor(str = "") {
|
|
110
|
-
const color = parseColor$1(str);
|
|
111
|
-
if (color == null || color === false)
|
|
112
|
-
return;
|
|
113
|
-
const { type: casedType, components, alpha } = color;
|
|
114
|
-
const type = casedType.toLowerCase();
|
|
115
|
-
if (components.length === 0)
|
|
116
|
-
return;
|
|
117
|
-
if (["rgba", "hsla"].includes(type) && alpha == null)
|
|
118
|
-
return;
|
|
119
|
-
if (cssColorFunctions.includes(type) && ![1, 3].includes(components.length))
|
|
120
|
-
return;
|
|
121
|
-
return { type, components, alpha };
|
|
122
|
-
}
|
|
123
|
-
function colorOpacityToString(color) {
|
|
124
|
-
const alpha = color.alpha ?? 1;
|
|
125
|
-
return typeof alpha === "string" && alphaPlaceholders.includes(alpha) ? 1 : alpha;
|
|
126
|
-
}
|
|
127
|
-
function colorToString(color, alphaOverride) {
|
|
128
|
-
if (typeof color === "string")
|
|
129
|
-
return color.replace(alphaPlaceholdersRE, `${alphaOverride ?? 1}`);
|
|
130
|
-
const { components } = color;
|
|
131
|
-
let { alpha, type } = color;
|
|
132
|
-
alpha = alphaOverride ?? alpha;
|
|
133
|
-
type = type.toLowerCase();
|
|
134
|
-
if (["hsla", "hsl", "rgba", "rgb"].includes(type))
|
|
135
|
-
return `${type.replace("a", "")}a(${components.join(",")}${alpha == null ? "" : `,${alpha}`})`;
|
|
136
|
-
alpha = alpha == null ? "" : ` / ${alpha}`;
|
|
137
|
-
if (cssColorFunctions.includes(type))
|
|
138
|
-
return `${type}(${components.join(" ")}${alpha})`;
|
|
139
|
-
return `color(${type} ${components.join(" ")}${alpha})`;
|
|
140
|
-
}
|
|
141
|
-
function parseColor$1(str) {
|
|
142
|
-
if (!str)
|
|
143
|
-
return;
|
|
144
|
-
let color = parseHexColor(str);
|
|
145
|
-
if (color != null)
|
|
146
|
-
return color;
|
|
147
|
-
color = cssColorKeyword(str);
|
|
148
|
-
if (color != null)
|
|
149
|
-
return color;
|
|
150
|
-
color = parseCssCommaColorFunction(str);
|
|
151
|
-
if (color != null)
|
|
152
|
-
return color;
|
|
153
|
-
color = parseCssSpaceColorFunction(str);
|
|
154
|
-
if (color != null)
|
|
155
|
-
return color;
|
|
156
|
-
color = parseCssColorFunction(str);
|
|
157
|
-
if (color != null)
|
|
158
|
-
return color;
|
|
159
|
-
}
|
|
160
|
-
function parseHexColor(str) {
|
|
161
|
-
const [, body] = str.match(/^#([\da-f]+)$/i) || [];
|
|
162
|
-
if (!body)
|
|
163
|
-
return;
|
|
164
|
-
switch (body.length) {
|
|
165
|
-
case 3:
|
|
166
|
-
case 4:
|
|
167
|
-
const digits = Array.from(body, (s) => Number.parseInt(s, 16)).map((n) => n << 4 | n);
|
|
168
|
-
return {
|
|
169
|
-
type: "rgb",
|
|
170
|
-
components: digits.slice(0, 3),
|
|
171
|
-
alpha: body.length === 3 ? void 0 : Math.round(digits[3] / 255 * 100) / 100
|
|
172
|
-
};
|
|
173
|
-
case 6:
|
|
174
|
-
case 8:
|
|
175
|
-
const value = Number.parseInt(body, 16);
|
|
176
|
-
return {
|
|
177
|
-
type: "rgb",
|
|
178
|
-
components: body.length === 6 ? [value >> 16 & 255, value >> 8 & 255, value & 255] : [value >> 24 & 255, value >> 16 & 255, value >> 8 & 255],
|
|
179
|
-
alpha: body.length === 6 ? void 0 : Math.round((value & 255) / 255 * 100) / 100
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
function cssColorKeyword(str) {
|
|
184
|
-
const color = {
|
|
185
|
-
rebeccapurple: [102, 51, 153, 1]
|
|
186
|
-
}[str];
|
|
187
|
-
if (color != null) {
|
|
188
|
-
return {
|
|
189
|
-
type: "rgb",
|
|
190
|
-
components: color.slice(0, 3),
|
|
191
|
-
alpha: color[3]
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function parseCssCommaColorFunction(color) {
|
|
196
|
-
const match = color.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);
|
|
197
|
-
if (!match)
|
|
198
|
-
return;
|
|
199
|
-
const [, type, componentString] = match;
|
|
200
|
-
const components = getComponents(componentString, ",", 5);
|
|
201
|
-
if (components) {
|
|
202
|
-
if ([3, 4].includes(components.length)) {
|
|
203
|
-
return {
|
|
204
|
-
type,
|
|
205
|
-
components: components.slice(0, 3),
|
|
206
|
-
alpha: components[3]
|
|
207
|
-
};
|
|
208
|
-
} else if (components.length !== 1) {
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
const cssColorFunctionsRe = new RegExp(`^(${cssColorFunctions.join("|")})\\((.+)\\)$`, "i");
|
|
214
|
-
function parseCssSpaceColorFunction(color) {
|
|
215
|
-
const match = color.match(cssColorFunctionsRe);
|
|
216
|
-
if (!match)
|
|
217
|
-
return;
|
|
218
|
-
const [, fn, componentString] = match;
|
|
219
|
-
const parsed = parseCssSpaceColorValues(`${fn} ${componentString}`);
|
|
220
|
-
if (parsed) {
|
|
221
|
-
const { alpha, components: [type, ...components] } = parsed;
|
|
222
|
-
return {
|
|
223
|
-
type,
|
|
224
|
-
components,
|
|
225
|
-
alpha
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
function parseCssColorFunction(color) {
|
|
230
|
-
const match = color.match(/^color\((.+)\)$/);
|
|
231
|
-
if (!match)
|
|
232
|
-
return;
|
|
233
|
-
const parsed = parseCssSpaceColorValues(match[1]);
|
|
234
|
-
if (parsed) {
|
|
235
|
-
const { alpha, components: [type, ...components] } = parsed;
|
|
236
|
-
return {
|
|
237
|
-
type,
|
|
238
|
-
components,
|
|
239
|
-
alpha
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
function parseCssSpaceColorValues(componentString) {
|
|
244
|
-
const components = getComponents(componentString);
|
|
245
|
-
if (!components)
|
|
246
|
-
return;
|
|
247
|
-
let totalComponents = components.length;
|
|
248
|
-
if (components[totalComponents - 2] === "/") {
|
|
249
|
-
return {
|
|
250
|
-
components: components.slice(0, totalComponents - 2),
|
|
251
|
-
alpha: components[totalComponents - 1]
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
if (components[totalComponents - 2] != null && (components[totalComponents - 2].endsWith("/") || components[totalComponents - 1].startsWith("/"))) {
|
|
255
|
-
const removed = components.splice(totalComponents - 2);
|
|
256
|
-
components.push(removed.join(" "));
|
|
257
|
-
--totalComponents;
|
|
258
|
-
}
|
|
259
|
-
const withAlpha = getComponents(components[totalComponents - 1], "/", 3);
|
|
260
|
-
if (!withAlpha)
|
|
261
|
-
return;
|
|
262
|
-
if (withAlpha.length === 1 || withAlpha[withAlpha.length - 1] === "")
|
|
263
|
-
return { components };
|
|
264
|
-
const alpha = withAlpha.pop();
|
|
265
|
-
components[totalComponents - 1] = withAlpha.join("/");
|
|
266
|
-
return {
|
|
267
|
-
components,
|
|
268
|
-
alpha
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
function getComponent(str, separator) {
|
|
272
|
-
str = str.trim();
|
|
273
|
-
if (str === "")
|
|
274
|
-
return;
|
|
275
|
-
const l = str.length;
|
|
276
|
-
let parenthesis = 0;
|
|
277
|
-
for (let i = 0; i < l; i++) {
|
|
278
|
-
switch (str[i]) {
|
|
279
|
-
case "(":
|
|
280
|
-
parenthesis++;
|
|
281
|
-
break;
|
|
282
|
-
case ")":
|
|
283
|
-
if (--parenthesis < 0)
|
|
284
|
-
return;
|
|
285
|
-
break;
|
|
286
|
-
case separator:
|
|
287
|
-
if (parenthesis === 0) {
|
|
288
|
-
const component = str.slice(0, i).trim();
|
|
289
|
-
if (component === "")
|
|
290
|
-
return;
|
|
291
|
-
return [
|
|
292
|
-
component,
|
|
293
|
-
str.slice(i + 1).trim()
|
|
294
|
-
];
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
return [
|
|
299
|
-
str,
|
|
300
|
-
""
|
|
301
|
-
];
|
|
302
|
-
}
|
|
303
|
-
function getComponents(str, separator, limit) {
|
|
304
|
-
separator = separator ?? " ";
|
|
305
|
-
if (separator.length !== 1)
|
|
306
|
-
return;
|
|
307
|
-
limit = limit ?? 10;
|
|
308
|
-
const components = [];
|
|
309
|
-
let i = 0;
|
|
310
|
-
while (str !== "") {
|
|
311
|
-
if (++i > limit)
|
|
312
|
-
return;
|
|
313
|
-
const componentPair = getComponent(str, separator);
|
|
314
|
-
if (!componentPair)
|
|
315
|
-
return;
|
|
316
|
-
const [component, rest] = componentPair;
|
|
317
|
-
components.push(component);
|
|
318
|
-
str = rest;
|
|
319
|
-
}
|
|
320
|
-
if (components.length > 0)
|
|
321
|
-
return components;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
97
|
const cssProps = [
|
|
325
98
|
"color",
|
|
326
99
|
"border-color",
|
|
@@ -531,7 +304,7 @@ const directionSize = (propertyPrefix) => ([_, direction, size], { theme }) => {
|
|
|
531
304
|
return directionMap[direction].map((i) => [`${propertyPrefix}${i}`, v]);
|
|
532
305
|
};
|
|
533
306
|
const getThemeColor = (theme, colors) => theme.colors?.[colors.join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase())];
|
|
534
|
-
const parseColor = (body, theme) => {
|
|
307
|
+
const parseColor$1 = (body, theme) => {
|
|
535
308
|
const split = body.split(/(?:\/|:)/);
|
|
536
309
|
let main, opacity;
|
|
537
310
|
if (split[0] === "[color") {
|
|
@@ -583,7 +356,7 @@ const parseColor = (body, theme) => {
|
|
|
583
356
|
};
|
|
584
357
|
};
|
|
585
358
|
const colorResolver = (property, varName) => ([, body], { theme }) => {
|
|
586
|
-
const data = parseColor(body, theme);
|
|
359
|
+
const data = parseColor$1(body, theme);
|
|
587
360
|
if (!data)
|
|
588
361
|
return;
|
|
589
362
|
const { alpha, color, cssColor } = data;
|
|
@@ -619,7 +392,7 @@ const colorableShadows = (shadows, colorVar) => {
|
|
|
619
392
|
return colored;
|
|
620
393
|
};
|
|
621
394
|
const hasParseableColor = (color, theme) => {
|
|
622
|
-
return color != null && !!parseColor(color, theme)?.color;
|
|
395
|
+
return color != null && !!parseColor$1(color, theme)?.color;
|
|
623
396
|
};
|
|
624
397
|
const resolveBreakpoints = ({ theme, generator }) => {
|
|
625
398
|
let breakpoints;
|
|
@@ -640,5 +413,233 @@ const resolveVerticalBreakpoints = ({ theme, generator }) => {
|
|
|
640
413
|
const makeGlobalStaticRules = (prefix, property) => {
|
|
641
414
|
return globalKeywords.map((keyword) => [`${prefix}-${keyword}`, { [property ?? prefix]: keyword }]);
|
|
642
415
|
};
|
|
416
|
+
function getComponent(str, open, close, separator) {
|
|
417
|
+
if (str === "")
|
|
418
|
+
return;
|
|
419
|
+
const l = str.length;
|
|
420
|
+
let parenthesis = 0;
|
|
421
|
+
for (let i = 0; i < l; i++) {
|
|
422
|
+
switch (str[i]) {
|
|
423
|
+
case open:
|
|
424
|
+
parenthesis++;
|
|
425
|
+
break;
|
|
426
|
+
case close:
|
|
427
|
+
if (--parenthesis < 0)
|
|
428
|
+
return;
|
|
429
|
+
break;
|
|
430
|
+
case separator:
|
|
431
|
+
if (parenthesis === 0) {
|
|
432
|
+
if (i === 0 || i === l - 1)
|
|
433
|
+
return;
|
|
434
|
+
return [
|
|
435
|
+
str.slice(0, i),
|
|
436
|
+
str.slice(i + 1)
|
|
437
|
+
];
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return [
|
|
442
|
+
str,
|
|
443
|
+
""
|
|
444
|
+
];
|
|
445
|
+
}
|
|
446
|
+
function getComponents(str, separator, limit) {
|
|
447
|
+
if (separator.length !== 1)
|
|
448
|
+
return;
|
|
449
|
+
limit = limit ?? 10;
|
|
450
|
+
const components = [];
|
|
451
|
+
let i = 0;
|
|
452
|
+
while (str !== "") {
|
|
453
|
+
if (++i > limit)
|
|
454
|
+
return;
|
|
455
|
+
const componentPair = getComponent(str, "(", ")", separator);
|
|
456
|
+
if (!componentPair)
|
|
457
|
+
return;
|
|
458
|
+
const [component, rest] = componentPair;
|
|
459
|
+
components.push(component);
|
|
460
|
+
str = rest;
|
|
461
|
+
}
|
|
462
|
+
if (components.length > 0)
|
|
463
|
+
return components;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const cssColorFunctions = ["hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "rgb", "rgba"];
|
|
467
|
+
const alphaPlaceholders = ["%alpha", "<alpha-value>"];
|
|
468
|
+
const alphaPlaceholdersRE = new RegExp(alphaPlaceholders.map((v) => escapeRegExp(v)).join("|"));
|
|
469
|
+
function hex2rgba(hex = "") {
|
|
470
|
+
const color = parseHexColor(hex);
|
|
471
|
+
if (color != null) {
|
|
472
|
+
const { components, alpha } = color;
|
|
473
|
+
if (alpha == null)
|
|
474
|
+
return components;
|
|
475
|
+
return [...components, alpha];
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
function parseCssColor(str = "") {
|
|
479
|
+
const color = parseColor(str);
|
|
480
|
+
if (color == null || color === false)
|
|
481
|
+
return;
|
|
482
|
+
const { type: casedType, components, alpha } = color;
|
|
483
|
+
const type = casedType.toLowerCase();
|
|
484
|
+
if (components.length === 0)
|
|
485
|
+
return;
|
|
486
|
+
if (["rgba", "hsla"].includes(type) && alpha == null)
|
|
487
|
+
return;
|
|
488
|
+
if (cssColorFunctions.includes(type) && ![1, 3].includes(components.length))
|
|
489
|
+
return;
|
|
490
|
+
return {
|
|
491
|
+
type,
|
|
492
|
+
components: components.map((c) => typeof c === "string" ? c.trim() : c),
|
|
493
|
+
alpha: typeof alpha === "string" ? alpha.trim() : alpha
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
function colorOpacityToString(color) {
|
|
497
|
+
const alpha = color.alpha ?? 1;
|
|
498
|
+
return typeof alpha === "string" && alphaPlaceholders.includes(alpha) ? 1 : alpha;
|
|
499
|
+
}
|
|
500
|
+
function colorToString(color, alphaOverride) {
|
|
501
|
+
if (typeof color === "string")
|
|
502
|
+
return color.replace(alphaPlaceholdersRE, `${alphaOverride ?? 1}`);
|
|
503
|
+
const { components } = color;
|
|
504
|
+
let { alpha, type } = color;
|
|
505
|
+
alpha = alphaOverride ?? alpha;
|
|
506
|
+
type = type.toLowerCase();
|
|
507
|
+
if (["hsla", "hsl", "rgba", "rgb"].includes(type))
|
|
508
|
+
return `${type.replace("a", "")}a(${components.join(",")}${alpha == null ? "" : `,${alpha}`})`;
|
|
509
|
+
alpha = alpha == null ? "" : ` / ${alpha}`;
|
|
510
|
+
if (cssColorFunctions.includes(type))
|
|
511
|
+
return `${type}(${components.join(" ")}${alpha})`;
|
|
512
|
+
return `color(${type} ${components.join(" ")}${alpha})`;
|
|
513
|
+
}
|
|
514
|
+
function parseColor(str) {
|
|
515
|
+
if (!str)
|
|
516
|
+
return;
|
|
517
|
+
let color = parseHexColor(str);
|
|
518
|
+
if (color != null)
|
|
519
|
+
return color;
|
|
520
|
+
color = cssColorKeyword(str);
|
|
521
|
+
if (color != null)
|
|
522
|
+
return color;
|
|
523
|
+
color = parseCssCommaColorFunction(str);
|
|
524
|
+
if (color != null)
|
|
525
|
+
return color;
|
|
526
|
+
color = parseCssSpaceColorFunction(str);
|
|
527
|
+
if (color != null)
|
|
528
|
+
return color;
|
|
529
|
+
color = parseCssColorFunction(str);
|
|
530
|
+
if (color != null)
|
|
531
|
+
return color;
|
|
532
|
+
}
|
|
533
|
+
function parseHexColor(str) {
|
|
534
|
+
const [, body] = str.match(/^#([\da-f]+)$/i) || [];
|
|
535
|
+
if (!body)
|
|
536
|
+
return;
|
|
537
|
+
switch (body.length) {
|
|
538
|
+
case 3:
|
|
539
|
+
case 4:
|
|
540
|
+
const digits = Array.from(body, (s) => Number.parseInt(s, 16)).map((n) => n << 4 | n);
|
|
541
|
+
return {
|
|
542
|
+
type: "rgb",
|
|
543
|
+
components: digits.slice(0, 3),
|
|
544
|
+
alpha: body.length === 3 ? void 0 : Math.round(digits[3] / 255 * 100) / 100
|
|
545
|
+
};
|
|
546
|
+
case 6:
|
|
547
|
+
case 8:
|
|
548
|
+
const value = Number.parseInt(body, 16);
|
|
549
|
+
return {
|
|
550
|
+
type: "rgb",
|
|
551
|
+
components: body.length === 6 ? [value >> 16 & 255, value >> 8 & 255, value & 255] : [value >> 24 & 255, value >> 16 & 255, value >> 8 & 255],
|
|
552
|
+
alpha: body.length === 6 ? void 0 : Math.round((value & 255) / 255 * 100) / 100
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
function cssColorKeyword(str) {
|
|
557
|
+
const color = {
|
|
558
|
+
rebeccapurple: [102, 51, 153, 1]
|
|
559
|
+
}[str];
|
|
560
|
+
if (color != null) {
|
|
561
|
+
return {
|
|
562
|
+
type: "rgb",
|
|
563
|
+
components: color.slice(0, 3),
|
|
564
|
+
alpha: color[3]
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function parseCssCommaColorFunction(color) {
|
|
569
|
+
const match = color.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);
|
|
570
|
+
if (!match)
|
|
571
|
+
return;
|
|
572
|
+
const [, type, componentString] = match;
|
|
573
|
+
const components = getComponents(componentString, ",", 5);
|
|
574
|
+
if (components) {
|
|
575
|
+
if ([3, 4].includes(components.length)) {
|
|
576
|
+
return {
|
|
577
|
+
type,
|
|
578
|
+
components: components.slice(0, 3),
|
|
579
|
+
alpha: components[3]
|
|
580
|
+
};
|
|
581
|
+
} else if (components.length !== 1) {
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
const cssColorFunctionsRe = new RegExp(`^(${cssColorFunctions.join("|")})\\((.+)\\)$`, "i");
|
|
587
|
+
function parseCssSpaceColorFunction(color) {
|
|
588
|
+
const match = color.match(cssColorFunctionsRe);
|
|
589
|
+
if (!match)
|
|
590
|
+
return;
|
|
591
|
+
const [, fn, componentString] = match;
|
|
592
|
+
const parsed = parseCssSpaceColorValues(`${fn} ${componentString}`);
|
|
593
|
+
if (parsed) {
|
|
594
|
+
const { alpha, components: [type, ...components] } = parsed;
|
|
595
|
+
return {
|
|
596
|
+
type,
|
|
597
|
+
components,
|
|
598
|
+
alpha
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
function parseCssColorFunction(color) {
|
|
603
|
+
const match = color.match(/^color\((.+)\)$/);
|
|
604
|
+
if (!match)
|
|
605
|
+
return;
|
|
606
|
+
const parsed = parseCssSpaceColorValues(match[1]);
|
|
607
|
+
if (parsed) {
|
|
608
|
+
const { alpha, components: [type, ...components] } = parsed;
|
|
609
|
+
return {
|
|
610
|
+
type,
|
|
611
|
+
components,
|
|
612
|
+
alpha
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
function parseCssSpaceColorValues(componentString) {
|
|
617
|
+
const components = getComponents(componentString, " ");
|
|
618
|
+
if (!components)
|
|
619
|
+
return;
|
|
620
|
+
let totalComponents = components.length;
|
|
621
|
+
if (components[totalComponents - 2] === "/") {
|
|
622
|
+
return {
|
|
623
|
+
components: components.slice(0, totalComponents - 2),
|
|
624
|
+
alpha: components[totalComponents - 1]
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
if (components[totalComponents - 2] != null && (components[totalComponents - 2].endsWith("/") || components[totalComponents - 1].startsWith("/"))) {
|
|
628
|
+
const removed = components.splice(totalComponents - 2);
|
|
629
|
+
components.push(removed.join(" "));
|
|
630
|
+
--totalComponents;
|
|
631
|
+
}
|
|
632
|
+
const withAlpha = getComponents(components[totalComponents - 1], "/", 2);
|
|
633
|
+
if (!withAlpha)
|
|
634
|
+
return;
|
|
635
|
+
if (withAlpha.length === 1 || withAlpha[withAlpha.length - 1] === "")
|
|
636
|
+
return { components };
|
|
637
|
+
const alpha = withAlpha.pop();
|
|
638
|
+
components[totalComponents - 1] = withAlpha.join("/");
|
|
639
|
+
return {
|
|
640
|
+
components,
|
|
641
|
+
alpha
|
|
642
|
+
};
|
|
643
|
+
}
|
|
643
644
|
|
|
644
|
-
export { CONTROL_MINI_NO_NEGATIVE as C, hasParseableColor as a, colorToString as b, colorResolver as c, directionMap as d, colorOpacityToString as e, cornerMap as f, globalKeywords as g, handler as h, colorableShadows as i, insetMap as j, resolveBreakpoints as k, directionSize as l, makeGlobalStaticRules as m,
|
|
645
|
+
export { CONTROL_MINI_NO_NEGATIVE as C, hasParseableColor as a, colorToString as b, colorResolver as c, directionMap as d, colorOpacityToString as e, cornerMap as f, globalKeywords as g, handler as h, colorableShadows as i, insetMap as j, resolveBreakpoints as k, directionSize as l, makeGlobalStaticRules as m, getComponent as n, positionMap as o, parseColor$1 as p, hex2rgba as q, resolveVerticalBreakpoints as r, parseCssColor as s, h as t, getComponents as u, valueHandlers as v, xyzMap as x };
|
package/dist/chunks/default.cjs
CHANGED
|
@@ -73,7 +73,7 @@ const textStrokeWidth = {
|
|
|
73
73
|
};
|
|
74
74
|
const textShadow = {
|
|
75
75
|
DEFAULT: ["0 0 1px rgba(0,0,0,0.2)", "0 0 1px rgba(1,0,5,0.1)"],
|
|
76
|
-
none: "0 0
|
|
76
|
+
none: "0 0 rgba(0,0,0,0)",
|
|
77
77
|
sm: "1px 1px 3px rgba(36,37,47,0.25)",
|
|
78
78
|
md: ["0 1px 2px rgba(30,29,39,0.19)", "1px 2px 4px rgba(54,64,147,0.18)"],
|
|
79
79
|
lg: ["3px 3px 6px rgba(0,0,0,0.26)", "0 0 5px rgba(15,3,86,0.22)"],
|
|
@@ -150,7 +150,7 @@ const borderRadius = {
|
|
|
150
150
|
};
|
|
151
151
|
const boxShadow = {
|
|
152
152
|
"DEFAULT": ["var(--un-shadow-inset) 0 1px 3px 0 rgba(0,0,0,0.1)", "var(--un-shadow-inset) 0 1px 2px -1px rgba(0,0,0,0.1)"],
|
|
153
|
-
"none": "0 0
|
|
153
|
+
"none": "0 0 rgba(0,0,0,0)",
|
|
154
154
|
"sm": "var(--un-shadow-inset) 0 1px 2px 0 rgba(0,0,0,0.05)",
|
|
155
155
|
"md": ["var(--un-shadow-inset) 0 4px 6px -1px rgba(0,0,0,0.1)", "var(--un-shadow-inset) 0 2px 4px -2px rgba(0,0,0,0.1)"],
|
|
156
156
|
"lg": ["var(--un-shadow-inset) 0 10px 15px -3px rgba(0,0,0,0.1)", "var(--un-shadow-inset) 0 4px 6px -4px rgba(0,0,0,0.1)"],
|
|
@@ -187,7 +187,7 @@ const dropShadow = {
|
|
|
187
187
|
"lg": ["0 10px 8px rgba(0,0,0,0.04)", "0 4px 3px rgba(0,0,0,0.1)"],
|
|
188
188
|
"xl": ["0 20px 13px rgba(0,0,0,0.03)", "0 8px 5px rgba(0,0,0,0.08)"],
|
|
189
189
|
"2xl": "0 25px 25px rgba(0,0,0,0.15)",
|
|
190
|
-
"none": "0 0
|
|
190
|
+
"none": "0 0 rgba(0,0,0,0)"
|
|
191
191
|
};
|
|
192
192
|
|
|
193
193
|
const baseSize = {
|
package/dist/chunks/default.mjs
CHANGED
|
@@ -71,7 +71,7 @@ const textStrokeWidth = {
|
|
|
71
71
|
};
|
|
72
72
|
const textShadow = {
|
|
73
73
|
DEFAULT: ["0 0 1px rgba(0,0,0,0.2)", "0 0 1px rgba(1,0,5,0.1)"],
|
|
74
|
-
none: "0 0
|
|
74
|
+
none: "0 0 rgba(0,0,0,0)",
|
|
75
75
|
sm: "1px 1px 3px rgba(36,37,47,0.25)",
|
|
76
76
|
md: ["0 1px 2px rgba(30,29,39,0.19)", "1px 2px 4px rgba(54,64,147,0.18)"],
|
|
77
77
|
lg: ["3px 3px 6px rgba(0,0,0,0.26)", "0 0 5px rgba(15,3,86,0.22)"],
|
|
@@ -148,7 +148,7 @@ const borderRadius = {
|
|
|
148
148
|
};
|
|
149
149
|
const boxShadow = {
|
|
150
150
|
"DEFAULT": ["var(--un-shadow-inset) 0 1px 3px 0 rgba(0,0,0,0.1)", "var(--un-shadow-inset) 0 1px 2px -1px rgba(0,0,0,0.1)"],
|
|
151
|
-
"none": "0 0
|
|
151
|
+
"none": "0 0 rgba(0,0,0,0)",
|
|
152
152
|
"sm": "var(--un-shadow-inset) 0 1px 2px 0 rgba(0,0,0,0.05)",
|
|
153
153
|
"md": ["var(--un-shadow-inset) 0 4px 6px -1px rgba(0,0,0,0.1)", "var(--un-shadow-inset) 0 2px 4px -2px rgba(0,0,0,0.1)"],
|
|
154
154
|
"lg": ["var(--un-shadow-inset) 0 10px 15px -3px rgba(0,0,0,0.1)", "var(--un-shadow-inset) 0 4px 6px -4px rgba(0,0,0,0.1)"],
|
|
@@ -185,7 +185,7 @@ const dropShadow = {
|
|
|
185
185
|
"lg": ["0 10px 8px rgba(0,0,0,0.04)", "0 4px 3px rgba(0,0,0,0.1)"],
|
|
186
186
|
"xl": ["0 20px 13px rgba(0,0,0,0.03)", "0 8px 5px rgba(0,0,0,0.08)"],
|
|
187
187
|
"2xl": "0 25px 25px rgba(0,0,0,0.15)",
|
|
188
|
-
"none": "0 0
|
|
188
|
+
"none": "0 0 rgba(0,0,0,0)"
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
const baseSize = {
|