@unocss/preset-mini 0.36.0 → 0.37.2
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/dist/chunks/default.cjs +3 -1
- package/dist/chunks/default.mjs +4 -2
- package/dist/chunks/default2.cjs +86 -243
- package/dist/chunks/default2.mjs +4 -145
- package/dist/chunks/default3.mjs +1 -1
- package/dist/chunks/transform.cjs +165 -10
- package/dist/chunks/transform.mjs +139 -2
- package/dist/chunks/utilities.cjs +311 -6
- package/dist/chunks/utilities.mjs +299 -3
- package/dist/index.cjs +0 -1
- package/dist/index.mjs +0 -1
- package/dist/rules.cjs +19 -18
- package/dist/rules.d.ts +15 -1
- package/dist/rules.mjs +3 -4
- package/dist/theme.cjs +1 -1
- package/dist/theme.d.ts +9 -0
- package/dist/theme.mjs +1 -1
- package/dist/utils.cjs +9 -10
- package/dist/utils.mjs +1 -2
- package/dist/variants.cjs +0 -1
- package/dist/variants.mjs +0 -1
- package/package.json +2 -2
- package/dist/chunks/index.cjs +0 -310
- package/dist/chunks/index.mjs +0 -300
|
@@ -1,7 +1,100 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const core = require('@unocss/core');
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const directionMap = {
|
|
6
|
+
"l": ["-left"],
|
|
7
|
+
"r": ["-right"],
|
|
8
|
+
"t": ["-top"],
|
|
9
|
+
"b": ["-bottom"],
|
|
10
|
+
"s": ["-inline-start"],
|
|
11
|
+
"e": ["-inline-end"],
|
|
12
|
+
"x": ["-left", "-right"],
|
|
13
|
+
"y": ["-top", "-bottom"],
|
|
14
|
+
"": [""],
|
|
15
|
+
"bs": ["-block-start"],
|
|
16
|
+
"be": ["-block-end"],
|
|
17
|
+
"is": ["-inline-start"],
|
|
18
|
+
"ie": ["-inline-end"],
|
|
19
|
+
"block": ["-block-start", "-block-end"],
|
|
20
|
+
"inline": ["-inline-start", "-inline-end"]
|
|
21
|
+
};
|
|
22
|
+
const insetMap = {
|
|
23
|
+
...directionMap,
|
|
24
|
+
s: ["-inset-inline-start"],
|
|
25
|
+
e: ["-inset-inline-end"],
|
|
26
|
+
bs: ["-inset-block-start"],
|
|
27
|
+
be: ["-inset-block-end"],
|
|
28
|
+
is: ["-inset-inline-start"],
|
|
29
|
+
ie: ["-inset-inline-end"],
|
|
30
|
+
block: ["-inset-block-start", "-inset-block-end"],
|
|
31
|
+
inline: ["-inset-inline-start", "-inset-inline-end"]
|
|
32
|
+
};
|
|
33
|
+
const cornerMap = {
|
|
34
|
+
"l": ["-top-left", "-bottom-left"],
|
|
35
|
+
"r": ["-top-right", "-bottom-right"],
|
|
36
|
+
"t": ["-top-left", "-top-right"],
|
|
37
|
+
"b": ["-bottom-left", "-bottom-right"],
|
|
38
|
+
"tl": ["-top-left"],
|
|
39
|
+
"lt": ["-top-left"],
|
|
40
|
+
"tr": ["-top-right"],
|
|
41
|
+
"rt": ["-top-right"],
|
|
42
|
+
"bl": ["-bottom-left"],
|
|
43
|
+
"lb": ["-bottom-left"],
|
|
44
|
+
"br": ["-bottom-right"],
|
|
45
|
+
"rb": ["-bottom-right"],
|
|
46
|
+
"": [""],
|
|
47
|
+
"bs": ["-start-start", "-start-end"],
|
|
48
|
+
"be": ["-end-start", "-end-end"],
|
|
49
|
+
"is": ["-end-start", "-start-start"],
|
|
50
|
+
"ie": ["-start-end", "-end-end"],
|
|
51
|
+
"bs-is": ["-start-start"],
|
|
52
|
+
"is-bs": ["-start-start"],
|
|
53
|
+
"bs-ie": ["-start-end"],
|
|
54
|
+
"ie-bs": ["-start-end"],
|
|
55
|
+
"be-is": ["-end-start"],
|
|
56
|
+
"is-be": ["-end-start"],
|
|
57
|
+
"be-ie": ["-end-end"],
|
|
58
|
+
"ie-be": ["-end-end"]
|
|
59
|
+
};
|
|
60
|
+
const xyzMap = {
|
|
61
|
+
"x": ["-x"],
|
|
62
|
+
"y": ["-y"],
|
|
63
|
+
"z": ["-z"],
|
|
64
|
+
"": ["-x", "-y"]
|
|
65
|
+
};
|
|
66
|
+
const basePositionMap = [
|
|
67
|
+
"top",
|
|
68
|
+
"top center",
|
|
69
|
+
"top left",
|
|
70
|
+
"top right",
|
|
71
|
+
"bottom",
|
|
72
|
+
"bottom center",
|
|
73
|
+
"bottom left",
|
|
74
|
+
"bottom right",
|
|
75
|
+
"left",
|
|
76
|
+
"left center",
|
|
77
|
+
"left top",
|
|
78
|
+
"left bottom",
|
|
79
|
+
"right",
|
|
80
|
+
"right center",
|
|
81
|
+
"right top",
|
|
82
|
+
"right bottom",
|
|
83
|
+
"center",
|
|
84
|
+
"center top",
|
|
85
|
+
"center bottom",
|
|
86
|
+
"center left",
|
|
87
|
+
"center right",
|
|
88
|
+
"center center"
|
|
89
|
+
];
|
|
90
|
+
const positionMap = Object.assign({}, ...basePositionMap.map((p) => ({ [p.replace(/ /, "-")]: p })), ...basePositionMap.map((p) => ({ [p.replace(/\b(\w)\w+/g, "$1").replace(/ /, "")]: p })));
|
|
91
|
+
const globalKeywords = [
|
|
92
|
+
"inherit",
|
|
93
|
+
"initial",
|
|
94
|
+
"revert",
|
|
95
|
+
"revert-layer",
|
|
96
|
+
"unset"
|
|
97
|
+
];
|
|
5
98
|
|
|
6
99
|
const cssColorFunctions = ["hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "rgb", "rgba"];
|
|
7
100
|
function hex2rgba(hex = "") {
|
|
@@ -222,11 +315,214 @@ function getComponents(str, separator, limit) {
|
|
|
222
315
|
return components;
|
|
223
316
|
}
|
|
224
317
|
|
|
318
|
+
const cssProps = [
|
|
319
|
+
"color",
|
|
320
|
+
"border-color",
|
|
321
|
+
"background-color",
|
|
322
|
+
"flex-grow",
|
|
323
|
+
"flex",
|
|
324
|
+
"flex-shrink",
|
|
325
|
+
"caret-color",
|
|
326
|
+
"font",
|
|
327
|
+
"gap",
|
|
328
|
+
"opacity",
|
|
329
|
+
"visibility",
|
|
330
|
+
"z-index",
|
|
331
|
+
"font-weight",
|
|
332
|
+
"zoom",
|
|
333
|
+
"text-shadow",
|
|
334
|
+
"transform",
|
|
335
|
+
"box-shadow",
|
|
336
|
+
"backround-position",
|
|
337
|
+
"left",
|
|
338
|
+
"right",
|
|
339
|
+
"top",
|
|
340
|
+
"bottom",
|
|
341
|
+
"object-position",
|
|
342
|
+
"max-height",
|
|
343
|
+
"min-height",
|
|
344
|
+
"max-width",
|
|
345
|
+
"min-width",
|
|
346
|
+
"height",
|
|
347
|
+
"width",
|
|
348
|
+
"border-width",
|
|
349
|
+
"margin",
|
|
350
|
+
"padding",
|
|
351
|
+
"outline-width",
|
|
352
|
+
"outline-offset",
|
|
353
|
+
"font-size",
|
|
354
|
+
"line-height",
|
|
355
|
+
"text-indent",
|
|
356
|
+
"vertical-align",
|
|
357
|
+
"border-spacing",
|
|
358
|
+
"letter-spacing",
|
|
359
|
+
"word-spacing",
|
|
360
|
+
"stroke",
|
|
361
|
+
"filter",
|
|
362
|
+
"backdrop-filter",
|
|
363
|
+
"fill",
|
|
364
|
+
"mask",
|
|
365
|
+
"mask-size",
|
|
366
|
+
"mask-border",
|
|
367
|
+
"clip-path",
|
|
368
|
+
"clip",
|
|
369
|
+
"border-radius"
|
|
370
|
+
];
|
|
371
|
+
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax|rpx)?$/i;
|
|
372
|
+
const numberRE = /^(-?[0-9.]+)$/i;
|
|
373
|
+
const unitOnlyRE = /^(px)$/i;
|
|
374
|
+
function round(n) {
|
|
375
|
+
return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
|
|
376
|
+
}
|
|
377
|
+
function numberWithUnit(str) {
|
|
378
|
+
const match = str.match(numberWithUnitRE);
|
|
379
|
+
if (!match)
|
|
380
|
+
return;
|
|
381
|
+
const [, n, unit] = match;
|
|
382
|
+
const num = parseFloat(n);
|
|
383
|
+
if (unit && !Number.isNaN(num))
|
|
384
|
+
return `${round(num)}${unit}`;
|
|
385
|
+
}
|
|
386
|
+
function auto(str) {
|
|
387
|
+
if (str === "auto" || str === "a")
|
|
388
|
+
return "auto";
|
|
389
|
+
}
|
|
390
|
+
function rem(str) {
|
|
391
|
+
if (str.match(unitOnlyRE))
|
|
392
|
+
return `1${str}`;
|
|
393
|
+
const match = str.match(numberWithUnitRE);
|
|
394
|
+
if (!match)
|
|
395
|
+
return;
|
|
396
|
+
const [, n, unit] = match;
|
|
397
|
+
const num = parseFloat(n);
|
|
398
|
+
if (!Number.isNaN(num))
|
|
399
|
+
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
400
|
+
}
|
|
401
|
+
function px(str) {
|
|
402
|
+
if (str.match(unitOnlyRE))
|
|
403
|
+
return `1${str}`;
|
|
404
|
+
const match = str.match(numberWithUnitRE);
|
|
405
|
+
if (!match)
|
|
406
|
+
return;
|
|
407
|
+
const [, n, unit] = match;
|
|
408
|
+
const num = parseFloat(n);
|
|
409
|
+
if (!Number.isNaN(num))
|
|
410
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
411
|
+
}
|
|
412
|
+
function number(str) {
|
|
413
|
+
if (!numberRE.test(str))
|
|
414
|
+
return;
|
|
415
|
+
const num = parseFloat(str);
|
|
416
|
+
if (!Number.isNaN(num))
|
|
417
|
+
return round(num);
|
|
418
|
+
}
|
|
419
|
+
function percent(str) {
|
|
420
|
+
if (str.endsWith("%"))
|
|
421
|
+
str = str.slice(0, -1);
|
|
422
|
+
const num = parseFloat(str);
|
|
423
|
+
if (!Number.isNaN(num))
|
|
424
|
+
return `${round(num / 100)}`;
|
|
425
|
+
}
|
|
426
|
+
function fraction(str) {
|
|
427
|
+
if (str === "full")
|
|
428
|
+
return "100%";
|
|
429
|
+
const [left, right] = str.split("/");
|
|
430
|
+
const num = parseFloat(left) / parseFloat(right);
|
|
431
|
+
if (!Number.isNaN(num))
|
|
432
|
+
return `${round(num * 100)}%`;
|
|
433
|
+
}
|
|
434
|
+
const bracketTypeRe = /^\[(color|length|position):/i;
|
|
435
|
+
function bracketWithType(str, type) {
|
|
436
|
+
if (str && str.startsWith("[") && str.endsWith("]")) {
|
|
437
|
+
let base;
|
|
438
|
+
const match = str.match(bracketTypeRe);
|
|
439
|
+
if (!match)
|
|
440
|
+
base = str.slice(1, -1);
|
|
441
|
+
else if (type && match[1] === type)
|
|
442
|
+
base = str.slice(match[0].length, -1);
|
|
443
|
+
if (base !== void 0) {
|
|
444
|
+
return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/([^\\])_/g, "$1 ").replace(/calc\((.*)/g, (v) => {
|
|
445
|
+
return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
function bracket(str) {
|
|
451
|
+
return bracketWithType(str);
|
|
452
|
+
}
|
|
453
|
+
function bracketOfColor(str) {
|
|
454
|
+
return bracketWithType(str, "color");
|
|
455
|
+
}
|
|
456
|
+
function bracketOfLength(str) {
|
|
457
|
+
return bracketWithType(str, "length");
|
|
458
|
+
}
|
|
459
|
+
function bracketOfPosition(str) {
|
|
460
|
+
return bracketWithType(str, "position");
|
|
461
|
+
}
|
|
462
|
+
function cssvar(str) {
|
|
463
|
+
if (str.match(/^\$\S/))
|
|
464
|
+
return `var(--${core.escapeSelector(str.slice(1))})`;
|
|
465
|
+
}
|
|
466
|
+
function time(str) {
|
|
467
|
+
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
468
|
+
if (!match)
|
|
469
|
+
return;
|
|
470
|
+
const [, n, unit] = match;
|
|
471
|
+
const num = parseFloat(n);
|
|
472
|
+
if (!Number.isNaN(num))
|
|
473
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
474
|
+
}
|
|
475
|
+
function degree(str) {
|
|
476
|
+
const match = str.match(/^(-?[0-9.]+)(deg|rad|grad|turn)?$/i);
|
|
477
|
+
if (!match)
|
|
478
|
+
return;
|
|
479
|
+
const [, n, unit] = match;
|
|
480
|
+
const num = parseFloat(n);
|
|
481
|
+
if (!Number.isNaN(num))
|
|
482
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
|
|
483
|
+
}
|
|
484
|
+
function global(str) {
|
|
485
|
+
if (globalKeywords.includes(str))
|
|
486
|
+
return str;
|
|
487
|
+
}
|
|
488
|
+
function properties(str) {
|
|
489
|
+
if (str.split(",").every((prop) => cssProps.includes(prop)))
|
|
490
|
+
return str;
|
|
491
|
+
}
|
|
492
|
+
function position(str) {
|
|
493
|
+
if (["top", "left", "right", "bottom", "center"].includes(str))
|
|
494
|
+
return str;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
const valueHandlers = {
|
|
498
|
+
__proto__: null,
|
|
499
|
+
numberWithUnit: numberWithUnit,
|
|
500
|
+
auto: auto,
|
|
501
|
+
rem: rem,
|
|
502
|
+
px: px,
|
|
503
|
+
number: number,
|
|
504
|
+
percent: percent,
|
|
505
|
+
fraction: fraction,
|
|
506
|
+
bracket: bracket,
|
|
507
|
+
bracketOfColor: bracketOfColor,
|
|
508
|
+
bracketOfLength: bracketOfLength,
|
|
509
|
+
bracketOfPosition: bracketOfPosition,
|
|
510
|
+
cssvar: cssvar,
|
|
511
|
+
time: time,
|
|
512
|
+
degree: degree,
|
|
513
|
+
global: global,
|
|
514
|
+
properties: properties,
|
|
515
|
+
position: position
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
const handler = core.createValueHandler(valueHandlers);
|
|
519
|
+
const h = handler;
|
|
520
|
+
|
|
225
521
|
const CONTROL_MINI_NO_NEGATIVE = "$$mini-no-negative";
|
|
226
522
|
const directionSize = (propertyPrefix) => ([_, direction, size], { theme }) => {
|
|
227
|
-
const v = theme.spacing?.[size || "DEFAULT"] ??
|
|
523
|
+
const v = theme.spacing?.[size || "DEFAULT"] ?? handler.bracket.cssvar.auto.fraction.rem(size);
|
|
228
524
|
if (v != null)
|
|
229
|
-
return
|
|
525
|
+
return directionMap[direction].map((i) => [`${propertyPrefix}${i}`, v]);
|
|
230
526
|
};
|
|
231
527
|
const getThemeColor = (theme, colors) => theme.colors?.[colors.join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase())];
|
|
232
528
|
const parseColor = (body, theme) => {
|
|
@@ -243,14 +539,14 @@ const parseColor = (body, theme) => {
|
|
|
243
539
|
if (!name)
|
|
244
540
|
return;
|
|
245
541
|
let color;
|
|
246
|
-
const bracket =
|
|
542
|
+
const bracket = handler.bracketOfColor(main);
|
|
247
543
|
const bracketOrMain = bracket || main;
|
|
248
544
|
if (bracketOrMain.startsWith("#"))
|
|
249
545
|
color = bracketOrMain;
|
|
250
546
|
else if (bracketOrMain.startsWith("hex-"))
|
|
251
547
|
color = `#${bracketOrMain.slice(4)}`;
|
|
252
548
|
else if (main.startsWith("$"))
|
|
253
|
-
color =
|
|
549
|
+
color = handler.cssvar(main);
|
|
254
550
|
color = color || bracket;
|
|
255
551
|
let no = "DEFAULT";
|
|
256
552
|
if (!color) {
|
|
@@ -277,7 +573,7 @@ const parseColor = (body, theme) => {
|
|
|
277
573
|
no,
|
|
278
574
|
color,
|
|
279
575
|
cssColor: parseCssColor(color),
|
|
280
|
-
alpha:
|
|
576
|
+
alpha: handler.bracket.cssvar.percent(opacity ?? "")
|
|
281
577
|
};
|
|
282
578
|
};
|
|
283
579
|
const colorResolver = (property, varName) => ([, body], { theme }) => {
|
|
@@ -340,11 +636,20 @@ exports.CONTROL_MINI_NO_NEGATIVE = CONTROL_MINI_NO_NEGATIVE;
|
|
|
340
636
|
exports.colorResolver = colorResolver;
|
|
341
637
|
exports.colorToString = colorToString;
|
|
342
638
|
exports.colorableShadows = colorableShadows;
|
|
639
|
+
exports.cornerMap = cornerMap;
|
|
640
|
+
exports.directionMap = directionMap;
|
|
343
641
|
exports.directionSize = directionSize;
|
|
344
642
|
exports.getComponents = getComponents;
|
|
643
|
+
exports.globalKeywords = globalKeywords;
|
|
644
|
+
exports.h = h;
|
|
645
|
+
exports.handler = handler;
|
|
345
646
|
exports.hasParseableColor = hasParseableColor;
|
|
346
647
|
exports.hex2rgba = hex2rgba;
|
|
648
|
+
exports.insetMap = insetMap;
|
|
347
649
|
exports.parseColor = parseColor;
|
|
348
650
|
exports.parseCssColor = parseCssColor;
|
|
651
|
+
exports.positionMap = positionMap;
|
|
349
652
|
exports.resolveBreakpoints = resolveBreakpoints;
|
|
350
653
|
exports.resolveVerticalBreakpoints = resolveVerticalBreakpoints;
|
|
654
|
+
exports.valueHandlers = valueHandlers;
|
|
655
|
+
exports.xyzMap = xyzMap;
|
|
@@ -1,5 +1,98 @@
|
|
|
1
|
-
import { toArray } from '@unocss/core';
|
|
2
|
-
|
|
1
|
+
import { escapeSelector, createValueHandler, toArray } from '@unocss/core';
|
|
2
|
+
|
|
3
|
+
const directionMap = {
|
|
4
|
+
"l": ["-left"],
|
|
5
|
+
"r": ["-right"],
|
|
6
|
+
"t": ["-top"],
|
|
7
|
+
"b": ["-bottom"],
|
|
8
|
+
"s": ["-inline-start"],
|
|
9
|
+
"e": ["-inline-end"],
|
|
10
|
+
"x": ["-left", "-right"],
|
|
11
|
+
"y": ["-top", "-bottom"],
|
|
12
|
+
"": [""],
|
|
13
|
+
"bs": ["-block-start"],
|
|
14
|
+
"be": ["-block-end"],
|
|
15
|
+
"is": ["-inline-start"],
|
|
16
|
+
"ie": ["-inline-end"],
|
|
17
|
+
"block": ["-block-start", "-block-end"],
|
|
18
|
+
"inline": ["-inline-start", "-inline-end"]
|
|
19
|
+
};
|
|
20
|
+
const insetMap = {
|
|
21
|
+
...directionMap,
|
|
22
|
+
s: ["-inset-inline-start"],
|
|
23
|
+
e: ["-inset-inline-end"],
|
|
24
|
+
bs: ["-inset-block-start"],
|
|
25
|
+
be: ["-inset-block-end"],
|
|
26
|
+
is: ["-inset-inline-start"],
|
|
27
|
+
ie: ["-inset-inline-end"],
|
|
28
|
+
block: ["-inset-block-start", "-inset-block-end"],
|
|
29
|
+
inline: ["-inset-inline-start", "-inset-inline-end"]
|
|
30
|
+
};
|
|
31
|
+
const cornerMap = {
|
|
32
|
+
"l": ["-top-left", "-bottom-left"],
|
|
33
|
+
"r": ["-top-right", "-bottom-right"],
|
|
34
|
+
"t": ["-top-left", "-top-right"],
|
|
35
|
+
"b": ["-bottom-left", "-bottom-right"],
|
|
36
|
+
"tl": ["-top-left"],
|
|
37
|
+
"lt": ["-top-left"],
|
|
38
|
+
"tr": ["-top-right"],
|
|
39
|
+
"rt": ["-top-right"],
|
|
40
|
+
"bl": ["-bottom-left"],
|
|
41
|
+
"lb": ["-bottom-left"],
|
|
42
|
+
"br": ["-bottom-right"],
|
|
43
|
+
"rb": ["-bottom-right"],
|
|
44
|
+
"": [""],
|
|
45
|
+
"bs": ["-start-start", "-start-end"],
|
|
46
|
+
"be": ["-end-start", "-end-end"],
|
|
47
|
+
"is": ["-end-start", "-start-start"],
|
|
48
|
+
"ie": ["-start-end", "-end-end"],
|
|
49
|
+
"bs-is": ["-start-start"],
|
|
50
|
+
"is-bs": ["-start-start"],
|
|
51
|
+
"bs-ie": ["-start-end"],
|
|
52
|
+
"ie-bs": ["-start-end"],
|
|
53
|
+
"be-is": ["-end-start"],
|
|
54
|
+
"is-be": ["-end-start"],
|
|
55
|
+
"be-ie": ["-end-end"],
|
|
56
|
+
"ie-be": ["-end-end"]
|
|
57
|
+
};
|
|
58
|
+
const xyzMap = {
|
|
59
|
+
"x": ["-x"],
|
|
60
|
+
"y": ["-y"],
|
|
61
|
+
"z": ["-z"],
|
|
62
|
+
"": ["-x", "-y"]
|
|
63
|
+
};
|
|
64
|
+
const basePositionMap = [
|
|
65
|
+
"top",
|
|
66
|
+
"top center",
|
|
67
|
+
"top left",
|
|
68
|
+
"top right",
|
|
69
|
+
"bottom",
|
|
70
|
+
"bottom center",
|
|
71
|
+
"bottom left",
|
|
72
|
+
"bottom right",
|
|
73
|
+
"left",
|
|
74
|
+
"left center",
|
|
75
|
+
"left top",
|
|
76
|
+
"left bottom",
|
|
77
|
+
"right",
|
|
78
|
+
"right center",
|
|
79
|
+
"right top",
|
|
80
|
+
"right bottom",
|
|
81
|
+
"center",
|
|
82
|
+
"center top",
|
|
83
|
+
"center bottom",
|
|
84
|
+
"center left",
|
|
85
|
+
"center right",
|
|
86
|
+
"center center"
|
|
87
|
+
];
|
|
88
|
+
const positionMap = Object.assign({}, ...basePositionMap.map((p) => ({ [p.replace(/ /, "-")]: p })), ...basePositionMap.map((p) => ({ [p.replace(/\b(\w)\w+/g, "$1").replace(/ /, "")]: p })));
|
|
89
|
+
const globalKeywords = [
|
|
90
|
+
"inherit",
|
|
91
|
+
"initial",
|
|
92
|
+
"revert",
|
|
93
|
+
"revert-layer",
|
|
94
|
+
"unset"
|
|
95
|
+
];
|
|
3
96
|
|
|
4
97
|
const cssColorFunctions = ["hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "rgb", "rgba"];
|
|
5
98
|
function hex2rgba(hex = "") {
|
|
@@ -220,6 +313,209 @@ function getComponents(str, separator, limit) {
|
|
|
220
313
|
return components;
|
|
221
314
|
}
|
|
222
315
|
|
|
316
|
+
const cssProps = [
|
|
317
|
+
"color",
|
|
318
|
+
"border-color",
|
|
319
|
+
"background-color",
|
|
320
|
+
"flex-grow",
|
|
321
|
+
"flex",
|
|
322
|
+
"flex-shrink",
|
|
323
|
+
"caret-color",
|
|
324
|
+
"font",
|
|
325
|
+
"gap",
|
|
326
|
+
"opacity",
|
|
327
|
+
"visibility",
|
|
328
|
+
"z-index",
|
|
329
|
+
"font-weight",
|
|
330
|
+
"zoom",
|
|
331
|
+
"text-shadow",
|
|
332
|
+
"transform",
|
|
333
|
+
"box-shadow",
|
|
334
|
+
"backround-position",
|
|
335
|
+
"left",
|
|
336
|
+
"right",
|
|
337
|
+
"top",
|
|
338
|
+
"bottom",
|
|
339
|
+
"object-position",
|
|
340
|
+
"max-height",
|
|
341
|
+
"min-height",
|
|
342
|
+
"max-width",
|
|
343
|
+
"min-width",
|
|
344
|
+
"height",
|
|
345
|
+
"width",
|
|
346
|
+
"border-width",
|
|
347
|
+
"margin",
|
|
348
|
+
"padding",
|
|
349
|
+
"outline-width",
|
|
350
|
+
"outline-offset",
|
|
351
|
+
"font-size",
|
|
352
|
+
"line-height",
|
|
353
|
+
"text-indent",
|
|
354
|
+
"vertical-align",
|
|
355
|
+
"border-spacing",
|
|
356
|
+
"letter-spacing",
|
|
357
|
+
"word-spacing",
|
|
358
|
+
"stroke",
|
|
359
|
+
"filter",
|
|
360
|
+
"backdrop-filter",
|
|
361
|
+
"fill",
|
|
362
|
+
"mask",
|
|
363
|
+
"mask-size",
|
|
364
|
+
"mask-border",
|
|
365
|
+
"clip-path",
|
|
366
|
+
"clip",
|
|
367
|
+
"border-radius"
|
|
368
|
+
];
|
|
369
|
+
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax|rpx)?$/i;
|
|
370
|
+
const numberRE = /^(-?[0-9.]+)$/i;
|
|
371
|
+
const unitOnlyRE = /^(px)$/i;
|
|
372
|
+
function round(n) {
|
|
373
|
+
return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
|
|
374
|
+
}
|
|
375
|
+
function numberWithUnit(str) {
|
|
376
|
+
const match = str.match(numberWithUnitRE);
|
|
377
|
+
if (!match)
|
|
378
|
+
return;
|
|
379
|
+
const [, n, unit] = match;
|
|
380
|
+
const num = parseFloat(n);
|
|
381
|
+
if (unit && !Number.isNaN(num))
|
|
382
|
+
return `${round(num)}${unit}`;
|
|
383
|
+
}
|
|
384
|
+
function auto(str) {
|
|
385
|
+
if (str === "auto" || str === "a")
|
|
386
|
+
return "auto";
|
|
387
|
+
}
|
|
388
|
+
function rem(str) {
|
|
389
|
+
if (str.match(unitOnlyRE))
|
|
390
|
+
return `1${str}`;
|
|
391
|
+
const match = str.match(numberWithUnitRE);
|
|
392
|
+
if (!match)
|
|
393
|
+
return;
|
|
394
|
+
const [, n, unit] = match;
|
|
395
|
+
const num = parseFloat(n);
|
|
396
|
+
if (!Number.isNaN(num))
|
|
397
|
+
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
398
|
+
}
|
|
399
|
+
function px(str) {
|
|
400
|
+
if (str.match(unitOnlyRE))
|
|
401
|
+
return `1${str}`;
|
|
402
|
+
const match = str.match(numberWithUnitRE);
|
|
403
|
+
if (!match)
|
|
404
|
+
return;
|
|
405
|
+
const [, n, unit] = match;
|
|
406
|
+
const num = parseFloat(n);
|
|
407
|
+
if (!Number.isNaN(num))
|
|
408
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
409
|
+
}
|
|
410
|
+
function number(str) {
|
|
411
|
+
if (!numberRE.test(str))
|
|
412
|
+
return;
|
|
413
|
+
const num = parseFloat(str);
|
|
414
|
+
if (!Number.isNaN(num))
|
|
415
|
+
return round(num);
|
|
416
|
+
}
|
|
417
|
+
function percent(str) {
|
|
418
|
+
if (str.endsWith("%"))
|
|
419
|
+
str = str.slice(0, -1);
|
|
420
|
+
const num = parseFloat(str);
|
|
421
|
+
if (!Number.isNaN(num))
|
|
422
|
+
return `${round(num / 100)}`;
|
|
423
|
+
}
|
|
424
|
+
function fraction(str) {
|
|
425
|
+
if (str === "full")
|
|
426
|
+
return "100%";
|
|
427
|
+
const [left, right] = str.split("/");
|
|
428
|
+
const num = parseFloat(left) / parseFloat(right);
|
|
429
|
+
if (!Number.isNaN(num))
|
|
430
|
+
return `${round(num * 100)}%`;
|
|
431
|
+
}
|
|
432
|
+
const bracketTypeRe = /^\[(color|length|position):/i;
|
|
433
|
+
function bracketWithType(str, type) {
|
|
434
|
+
if (str && str.startsWith("[") && str.endsWith("]")) {
|
|
435
|
+
let base;
|
|
436
|
+
const match = str.match(bracketTypeRe);
|
|
437
|
+
if (!match)
|
|
438
|
+
base = str.slice(1, -1);
|
|
439
|
+
else if (type && match[1] === type)
|
|
440
|
+
base = str.slice(match[0].length, -1);
|
|
441
|
+
if (base !== void 0) {
|
|
442
|
+
return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/([^\\])_/g, "$1 ").replace(/calc\((.*)/g, (v) => {
|
|
443
|
+
return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
function bracket(str) {
|
|
449
|
+
return bracketWithType(str);
|
|
450
|
+
}
|
|
451
|
+
function bracketOfColor(str) {
|
|
452
|
+
return bracketWithType(str, "color");
|
|
453
|
+
}
|
|
454
|
+
function bracketOfLength(str) {
|
|
455
|
+
return bracketWithType(str, "length");
|
|
456
|
+
}
|
|
457
|
+
function bracketOfPosition(str) {
|
|
458
|
+
return bracketWithType(str, "position");
|
|
459
|
+
}
|
|
460
|
+
function cssvar(str) {
|
|
461
|
+
if (str.match(/^\$\S/))
|
|
462
|
+
return `var(--${escapeSelector(str.slice(1))})`;
|
|
463
|
+
}
|
|
464
|
+
function time(str) {
|
|
465
|
+
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
466
|
+
if (!match)
|
|
467
|
+
return;
|
|
468
|
+
const [, n, unit] = match;
|
|
469
|
+
const num = parseFloat(n);
|
|
470
|
+
if (!Number.isNaN(num))
|
|
471
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
472
|
+
}
|
|
473
|
+
function degree(str) {
|
|
474
|
+
const match = str.match(/^(-?[0-9.]+)(deg|rad|grad|turn)?$/i);
|
|
475
|
+
if (!match)
|
|
476
|
+
return;
|
|
477
|
+
const [, n, unit] = match;
|
|
478
|
+
const num = parseFloat(n);
|
|
479
|
+
if (!Number.isNaN(num))
|
|
480
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
|
|
481
|
+
}
|
|
482
|
+
function global(str) {
|
|
483
|
+
if (globalKeywords.includes(str))
|
|
484
|
+
return str;
|
|
485
|
+
}
|
|
486
|
+
function properties(str) {
|
|
487
|
+
if (str.split(",").every((prop) => cssProps.includes(prop)))
|
|
488
|
+
return str;
|
|
489
|
+
}
|
|
490
|
+
function position(str) {
|
|
491
|
+
if (["top", "left", "right", "bottom", "center"].includes(str))
|
|
492
|
+
return str;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const valueHandlers = {
|
|
496
|
+
__proto__: null,
|
|
497
|
+
numberWithUnit: numberWithUnit,
|
|
498
|
+
auto: auto,
|
|
499
|
+
rem: rem,
|
|
500
|
+
px: px,
|
|
501
|
+
number: number,
|
|
502
|
+
percent: percent,
|
|
503
|
+
fraction: fraction,
|
|
504
|
+
bracket: bracket,
|
|
505
|
+
bracketOfColor: bracketOfColor,
|
|
506
|
+
bracketOfLength: bracketOfLength,
|
|
507
|
+
bracketOfPosition: bracketOfPosition,
|
|
508
|
+
cssvar: cssvar,
|
|
509
|
+
time: time,
|
|
510
|
+
degree: degree,
|
|
511
|
+
global: global,
|
|
512
|
+
properties: properties,
|
|
513
|
+
position: position
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
const handler = createValueHandler(valueHandlers);
|
|
517
|
+
const h = handler;
|
|
518
|
+
|
|
223
519
|
const CONTROL_MINI_NO_NEGATIVE = "$$mini-no-negative";
|
|
224
520
|
const directionSize = (propertyPrefix) => ([_, direction, size], { theme }) => {
|
|
225
521
|
const v = theme.spacing?.[size || "DEFAULT"] ?? handler.bracket.cssvar.auto.fraction.rem(size);
|
|
@@ -334,4 +630,4 @@ const resolveVerticalBreakpoints = ({ theme, generator }) => {
|
|
|
334
630
|
return verticalBreakpoints;
|
|
335
631
|
};
|
|
336
632
|
|
|
337
|
-
export { CONTROL_MINI_NO_NEGATIVE as C,
|
|
633
|
+
export { CONTROL_MINI_NO_NEGATIVE as C, hasParseableColor as a, colorToString as b, colorResolver as c, directionMap as d, cornerMap as e, colorableShadows as f, globalKeywords as g, handler as h, insetMap as i, resolveBreakpoints as j, directionSize as k, positionMap as l, hex2rgba as m, parseCssColor as n, getComponents as o, parseColor as p, h as q, resolveVerticalBreakpoints as r, valueHandlers as v, xyzMap as x };
|
package/dist/index.cjs
CHANGED
|
@@ -9,7 +9,6 @@ const _default$2 = require('./chunks/default3.cjs');
|
|
|
9
9
|
const colors = require('./chunks/colors.cjs');
|
|
10
10
|
const utilities = require('./chunks/utilities.cjs');
|
|
11
11
|
require('./chunks/transform.cjs');
|
|
12
|
-
require('./chunks/index.cjs');
|
|
13
12
|
require('./chunks/variants.cjs');
|
|
14
13
|
|
|
15
14
|
const preflights = [
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import { v as variants } from './chunks/default3.mjs';
|
|
|
6
6
|
export { c as colors } from './chunks/colors.mjs';
|
|
7
7
|
export { p as parseColor } from './chunks/utilities.mjs';
|
|
8
8
|
import './chunks/transform.mjs';
|
|
9
|
-
import './chunks/index.mjs';
|
|
10
9
|
import './chunks/variants.mjs';
|
|
11
10
|
|
|
12
11
|
const preflights = [
|