@unocss/preset-mini 0.35.4 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/dist/chunks/default.cjs +8 -1
- package/dist/chunks/default.mjs +8 -2
- package/dist/chunks/default2.cjs +83 -229
- package/dist/chunks/default2.mjs +4 -149
- package/dist/chunks/default3.cjs +17 -3
- package/dist/chunks/default3.mjs +17 -4
- package/dist/chunks/index.cjs +310 -0
- package/dist/chunks/index.mjs +300 -0
- package/dist/chunks/transform.cjs +129 -0
- package/dist/chunks/transform.mjs +126 -0
- package/dist/chunks/utilities.cjs +6 -311
- package/dist/chunks/utilities.mjs +3 -299
- package/dist/{colors-ce2fecb8.d.ts → colors-5590b862.d.ts} +1 -1
- package/dist/colors.d.ts +2 -2
- package/dist/{default-e6d1b2e8.d.ts → default-ee82f36d.d.ts} +1 -1
- package/dist/index.cjs +16 -2
- package/dist/index.d.ts +9 -7
- package/dist/index.mjs +16 -3
- package/dist/rules.cjs +5 -2
- package/dist/rules.d.ts +17 -2
- package/dist/rules.mjs +4 -2
- package/dist/theme.cjs +4 -0
- package/dist/theme.d.ts +21 -5
- package/dist/theme.mjs +4 -1
- package/dist/{types-f7b2c653.d.ts → types-0f7ef446.d.ts} +2 -0
- package/dist/{utilities-e7a7f845.d.ts → utilities-a77178bb.d.ts} +1 -1
- package/dist/utils.cjs +10 -9
- package/dist/utils.d.ts +4 -4
- package/dist/utils.mjs +2 -1
- package/dist/variants.cjs +3 -1
- package/dist/variants.d.ts +7 -6
- package/dist/variants.mjs +2 -1
- package/package.json +2 -2
package/dist/chunks/default2.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { g as globalKeywords, h as handler,
|
|
1
|
+
import { g as globalKeywords, h as handler, d as directionMap, c as cornerMap, i as insetMap } from './index.mjs';
|
|
2
|
+
import { c as colorResolver, h as hasParseableColor, p as parseColor, a as colorToString, b as colorableShadows, r as resolveVerticalBreakpoints, d as resolveBreakpoints, e as directionSize } from './utilities.mjs';
|
|
2
3
|
import { toArray, CONTROL_SHORTCUT_NO_MERGE } from '@unocss/core';
|
|
4
|
+
import { a as transforms } from './transform.mjs';
|
|
3
5
|
|
|
4
6
|
const verticalAlignAlias = {
|
|
5
7
|
"mid": "middle",
|
|
@@ -721,153 +723,6 @@ const margins = [
|
|
|
721
723
|
[/^m-?([bi][se])(?:-?(-?.+))?$/, directionSize("margin")]
|
|
722
724
|
];
|
|
723
725
|
|
|
724
|
-
const transformGpu = {
|
|
725
|
-
"--un-transform": [
|
|
726
|
-
"translate3d(var(--un-translate-x), var(--un-translate-y), var(--un-translate-z))",
|
|
727
|
-
"rotate(var(--un-rotate))",
|
|
728
|
-
"rotateX(var(--un-rotate-x))",
|
|
729
|
-
"rotateY(var(--un-rotate-y))",
|
|
730
|
-
"rotateZ(var(--un-rotate-z))",
|
|
731
|
-
"skewX(var(--un-skew-x))",
|
|
732
|
-
"skewY(var(--un-skew-y))",
|
|
733
|
-
"scaleX(var(--un-scale-x))",
|
|
734
|
-
"scaleY(var(--un-scale-y))",
|
|
735
|
-
"scaleZ(var(--un-scale-z))"
|
|
736
|
-
].join(" ")
|
|
737
|
-
};
|
|
738
|
-
const transformCpu = {
|
|
739
|
-
"--un-transform": [
|
|
740
|
-
"translateX(var(--un-translate-x))",
|
|
741
|
-
"translateY(var(--un-translate-y))",
|
|
742
|
-
"translateZ(var(--un-translate-z))",
|
|
743
|
-
"rotate(var(--un-rotate))",
|
|
744
|
-
"rotateX(var(--un-rotate-x))",
|
|
745
|
-
"rotateY(var(--un-rotate-y))",
|
|
746
|
-
"rotateZ(var(--un-rotate-z))",
|
|
747
|
-
"skewX(var(--un-skew-x))",
|
|
748
|
-
"skewY(var(--un-skew-y))",
|
|
749
|
-
"scaleX(var(--un-scale-x))",
|
|
750
|
-
"scaleY(var(--un-scale-y))",
|
|
751
|
-
"scaleZ(var(--un-scale-z))"
|
|
752
|
-
].join(" ")
|
|
753
|
-
};
|
|
754
|
-
const transformBase = {
|
|
755
|
-
"--un-rotate": 0,
|
|
756
|
-
"--un-rotate-x": 0,
|
|
757
|
-
"--un-rotate-y": 0,
|
|
758
|
-
"--un-rotate-z": 0,
|
|
759
|
-
"--un-scale-x": 1,
|
|
760
|
-
"--un-scale-y": 1,
|
|
761
|
-
"--un-scale-z": 1,
|
|
762
|
-
"--un-skew-x": 0,
|
|
763
|
-
"--un-skew-y": 0,
|
|
764
|
-
"--un-translate-x": 0,
|
|
765
|
-
"--un-translate-y": 0,
|
|
766
|
-
"--un-translate-z": 0,
|
|
767
|
-
...transformCpu,
|
|
768
|
-
[CONTROL_SHORTCUT_NO_MERGE]: "",
|
|
769
|
-
[CONTROL_MINI_NO_NEGATIVE]: ""
|
|
770
|
-
};
|
|
771
|
-
const transforms = [
|
|
772
|
-
[/^(?:transform-)?origin-(.+)$/, ([, s]) => ({ "transform-origin": positionMap[s] ?? handler.bracket.cssvar(s) }), { autocomplete: [`transform-origin-(${Object.keys(positionMap).join("|")})`, `origin-(${Object.keys(positionMap).join("|")})`] }],
|
|
773
|
-
[/^(?:transform-)?perspect(?:ive)?-(.+)$/, ([, s]) => {
|
|
774
|
-
const v = handler.bracket.cssvar.px.numberWithUnit(s);
|
|
775
|
-
if (v != null) {
|
|
776
|
-
return {
|
|
777
|
-
"-webkit-perspective": v,
|
|
778
|
-
"perspective": v
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
|
-
}],
|
|
782
|
-
[/^(?:transform-)?perspect(?:ive)?-origin-(.+)$/, ([, s]) => {
|
|
783
|
-
const v = handler.bracket.cssvar(s) ?? (s.length >= 3 ? positionMap[s] : void 0);
|
|
784
|
-
if (v != null) {
|
|
785
|
-
return {
|
|
786
|
-
"-webkit-perspective-origin": v,
|
|
787
|
-
"perspective-origin": v
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
|
-
}],
|
|
791
|
-
[/^(?:transform-)?translate-()(.+)$/, handleTranslate],
|
|
792
|
-
[/^(?:transform-)?translate-([xyz])-(.+)$/, handleTranslate],
|
|
793
|
-
[/^(?:transform-)?rotate-()(.+)$/, handleRotate],
|
|
794
|
-
[/^(?:transform-)?rotate-([xyz])-(.+)$/, handleRotate],
|
|
795
|
-
[/^(?:transform-)?skew-([xy])-(.+)$/, handleSkew],
|
|
796
|
-
[/^(?:transform-)?scale-()(.+)$/, handleScale],
|
|
797
|
-
[/^(?:transform-)?scale-([xyz])-(.+)$/, handleScale],
|
|
798
|
-
[/^(?:transform-)?preserve-3d$/, () => ({ "transform-style": "preserve-3d" })],
|
|
799
|
-
[/^(?:transform-)?preserve-flat$/, () => ({ "transform-style": "flat" })],
|
|
800
|
-
[/^transform$/, () => [
|
|
801
|
-
transformBase,
|
|
802
|
-
{ transform: "var(--un-transform)" }
|
|
803
|
-
]],
|
|
804
|
-
["transform-gpu", transformGpu],
|
|
805
|
-
["transform-cpu", transformCpu],
|
|
806
|
-
["transform-none", { transform: "none" }]
|
|
807
|
-
];
|
|
808
|
-
function handleTranslate([, d, b], { theme }) {
|
|
809
|
-
const v = theme.spacing?.[b] ?? handler.bracket.cssvar.fraction.rem(b);
|
|
810
|
-
if (v != null) {
|
|
811
|
-
return [
|
|
812
|
-
transformBase,
|
|
813
|
-
[
|
|
814
|
-
...xyzMap[d].map((i) => [`--un-translate${i}`, v]),
|
|
815
|
-
["transform", "var(--un-transform)"]
|
|
816
|
-
]
|
|
817
|
-
];
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
function handleScale([, d, b]) {
|
|
821
|
-
const v = handler.bracket.cssvar.fraction.percent(b);
|
|
822
|
-
if (v != null) {
|
|
823
|
-
return [
|
|
824
|
-
transformBase,
|
|
825
|
-
[
|
|
826
|
-
...xyzMap[d].map((i) => [`--un-scale${i}`, v]),
|
|
827
|
-
["transform", "var(--un-transform)"]
|
|
828
|
-
]
|
|
829
|
-
];
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
function handleRotate([, d = "", b]) {
|
|
833
|
-
const v = handler.bracket.cssvar.degree(b);
|
|
834
|
-
if (v != null) {
|
|
835
|
-
if (d) {
|
|
836
|
-
return [
|
|
837
|
-
transformBase,
|
|
838
|
-
{
|
|
839
|
-
"--un-rotate": 0,
|
|
840
|
-
[`--un-rotate-${d}`]: v,
|
|
841
|
-
"transform": "var(--un-transform)"
|
|
842
|
-
}
|
|
843
|
-
];
|
|
844
|
-
} else {
|
|
845
|
-
return [
|
|
846
|
-
transformBase,
|
|
847
|
-
{
|
|
848
|
-
"--un-rotate-x": 0,
|
|
849
|
-
"--un-rotate-y": 0,
|
|
850
|
-
"--un-rotate-z": 0,
|
|
851
|
-
"--un-rotate": v,
|
|
852
|
-
"transform": "var(--un-transform)"
|
|
853
|
-
}
|
|
854
|
-
];
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
function handleSkew([, d, b]) {
|
|
859
|
-
const v = handler.bracket.cssvar.degree(b);
|
|
860
|
-
if (v != null) {
|
|
861
|
-
return [
|
|
862
|
-
transformBase,
|
|
863
|
-
{
|
|
864
|
-
[`--un-skew-${d}`]: v,
|
|
865
|
-
transform: "var(--un-transform)"
|
|
866
|
-
}
|
|
867
|
-
];
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
|
|
871
726
|
const variablesAbbrMap = {
|
|
872
727
|
backface: "backface-visibility",
|
|
873
728
|
break: "word-break",
|
|
@@ -1003,4 +858,4 @@ const rules = [
|
|
|
1003
858
|
questionMark
|
|
1004
859
|
].flat(1);
|
|
1005
860
|
|
|
1006
|
-
export {
|
|
861
|
+
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, transitions as T, fonts as U, tabSizes as V, textIndents as W, textStrokes as X, textShadows as Y, cssVariables as Z, cssProperty 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 };
|
package/dist/chunks/default3.cjs
CHANGED
|
@@ -123,10 +123,22 @@ const variantSelector = {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
-
const
|
|
126
|
+
const variantCssLayer = {
|
|
127
127
|
name: "layer",
|
|
128
128
|
match(matcher) {
|
|
129
129
|
const match = matcher.match(/^layer-([_\d\w]+)[:-]/);
|
|
130
|
+
if (match) {
|
|
131
|
+
return {
|
|
132
|
+
matcher: matcher.slice(match[0].length),
|
|
133
|
+
parent: `@layer ${match[1]}`
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const variantInternalLayer = {
|
|
139
|
+
name: "uno-layer",
|
|
140
|
+
match(matcher) {
|
|
141
|
+
const match = matcher.match(/^uno-layer-([_\d\w]+)[:-]/);
|
|
130
142
|
if (match) {
|
|
131
143
|
return {
|
|
132
144
|
matcher: matcher.slice(match[0].length),
|
|
@@ -352,8 +364,9 @@ const partClasses = {
|
|
|
352
364
|
};
|
|
353
365
|
|
|
354
366
|
const variants = (options) => [
|
|
367
|
+
variantCssLayer,
|
|
355
368
|
variantSelector,
|
|
356
|
-
|
|
369
|
+
variantInternalLayer,
|
|
357
370
|
variantNegative,
|
|
358
371
|
variantImportant,
|
|
359
372
|
variantPrint,
|
|
@@ -373,10 +386,11 @@ exports.partClasses = partClasses;
|
|
|
373
386
|
exports.variantBreakpoints = variantBreakpoints;
|
|
374
387
|
exports.variantColorsMediaOrClass = variantColorsMediaOrClass;
|
|
375
388
|
exports.variantCombinators = variantCombinators;
|
|
389
|
+
exports.variantCssLayer = variantCssLayer;
|
|
376
390
|
exports.variantCustomMedia = variantCustomMedia;
|
|
377
391
|
exports.variantImportant = variantImportant;
|
|
392
|
+
exports.variantInternalLayer = variantInternalLayer;
|
|
378
393
|
exports.variantLanguageDirections = variantLanguageDirections;
|
|
379
|
-
exports.variantLayer = variantLayer;
|
|
380
394
|
exports.variantNegative = variantNegative;
|
|
381
395
|
exports.variantPrint = variantPrint;
|
|
382
396
|
exports.variantPseudoClassFunctions = variantPseudoClassFunctions;
|
package/dist/chunks/default3.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as resolveBreakpoints, C as CONTROL_MINI_NO_NEGATIVE } from './utilities.mjs';
|
|
2
2
|
import { v as variantParentMatcher, a as variantMatcher } from './variants.mjs';
|
|
3
3
|
import { escapeRegExp } from '@unocss/core';
|
|
4
4
|
|
|
@@ -121,10 +121,22 @@ const variantSelector = {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
-
const
|
|
124
|
+
const variantCssLayer = {
|
|
125
125
|
name: "layer",
|
|
126
126
|
match(matcher) {
|
|
127
127
|
const match = matcher.match(/^layer-([_\d\w]+)[:-]/);
|
|
128
|
+
if (match) {
|
|
129
|
+
return {
|
|
130
|
+
matcher: matcher.slice(match[0].length),
|
|
131
|
+
parent: `@layer ${match[1]}`
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const variantInternalLayer = {
|
|
137
|
+
name: "uno-layer",
|
|
138
|
+
match(matcher) {
|
|
139
|
+
const match = matcher.match(/^uno-layer-([_\d\w]+)[:-]/);
|
|
128
140
|
if (match) {
|
|
129
141
|
return {
|
|
130
142
|
matcher: matcher.slice(match[0].length),
|
|
@@ -350,8 +362,9 @@ const partClasses = {
|
|
|
350
362
|
};
|
|
351
363
|
|
|
352
364
|
const variants = (options) => [
|
|
365
|
+
variantCssLayer,
|
|
353
366
|
variantSelector,
|
|
354
|
-
|
|
367
|
+
variantInternalLayer,
|
|
355
368
|
variantNegative,
|
|
356
369
|
variantImportant,
|
|
357
370
|
variantPrint,
|
|
@@ -367,4 +380,4 @@ const variants = (options) => [
|
|
|
367
380
|
variantScope
|
|
368
381
|
];
|
|
369
382
|
|
|
370
|
-
export { variantBreakpoints as a, variantCombinators as b, variantPrint as c, variantCustomMedia as d, variantColorsMediaOrClass as e, variantLanguageDirections as f, variantSelector as g,
|
|
383
|
+
export { variantBreakpoints as a, variantCombinators as b, variantPrint as c, variantCustomMedia as d, variantColorsMediaOrClass as e, variantLanguageDirections as f, variantSelector as g, variantCssLayer as h, variantInternalLayer as i, variantScope as j, variantImportant as k, variantNegative as l, variantPseudoClassesAndElements as m, variantPseudoClassFunctions as n, variantTaggedPseudoClasses as o, partClasses as p, variants as v };
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const core = require('@unocss/core');
|
|
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
|
+
];
|
|
98
|
+
|
|
99
|
+
const cssProps = [
|
|
100
|
+
"color",
|
|
101
|
+
"border-color",
|
|
102
|
+
"background-color",
|
|
103
|
+
"flex-grow",
|
|
104
|
+
"flex",
|
|
105
|
+
"flex-shrink",
|
|
106
|
+
"caret-color",
|
|
107
|
+
"font",
|
|
108
|
+
"gap",
|
|
109
|
+
"opacity",
|
|
110
|
+
"visibility",
|
|
111
|
+
"z-index",
|
|
112
|
+
"font-weight",
|
|
113
|
+
"zoom",
|
|
114
|
+
"text-shadow",
|
|
115
|
+
"transform",
|
|
116
|
+
"box-shadow",
|
|
117
|
+
"backround-position",
|
|
118
|
+
"left",
|
|
119
|
+
"right",
|
|
120
|
+
"top",
|
|
121
|
+
"bottom",
|
|
122
|
+
"object-position",
|
|
123
|
+
"max-height",
|
|
124
|
+
"min-height",
|
|
125
|
+
"max-width",
|
|
126
|
+
"min-width",
|
|
127
|
+
"height",
|
|
128
|
+
"width",
|
|
129
|
+
"border-width",
|
|
130
|
+
"margin",
|
|
131
|
+
"padding",
|
|
132
|
+
"outline-width",
|
|
133
|
+
"outline-offset",
|
|
134
|
+
"font-size",
|
|
135
|
+
"line-height",
|
|
136
|
+
"text-indent",
|
|
137
|
+
"vertical-align",
|
|
138
|
+
"border-spacing",
|
|
139
|
+
"letter-spacing",
|
|
140
|
+
"word-spacing",
|
|
141
|
+
"stroke",
|
|
142
|
+
"filter",
|
|
143
|
+
"backdrop-filter",
|
|
144
|
+
"fill",
|
|
145
|
+
"mask",
|
|
146
|
+
"mask-size",
|
|
147
|
+
"mask-border",
|
|
148
|
+
"clip-path",
|
|
149
|
+
"clip",
|
|
150
|
+
"border-radius"
|
|
151
|
+
];
|
|
152
|
+
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax|rpx)?$/i;
|
|
153
|
+
const numberRE = /^(-?[0-9.]+)$/i;
|
|
154
|
+
const unitOnlyRE = /^(px)$/i;
|
|
155
|
+
function round(n) {
|
|
156
|
+
return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
|
|
157
|
+
}
|
|
158
|
+
function numberWithUnit(str) {
|
|
159
|
+
const match = str.match(numberWithUnitRE);
|
|
160
|
+
if (!match)
|
|
161
|
+
return;
|
|
162
|
+
const [, n, unit] = match;
|
|
163
|
+
const num = parseFloat(n);
|
|
164
|
+
if (unit && !Number.isNaN(num))
|
|
165
|
+
return `${round(num)}${unit}`;
|
|
166
|
+
}
|
|
167
|
+
function auto(str) {
|
|
168
|
+
if (str === "auto" || str === "a")
|
|
169
|
+
return "auto";
|
|
170
|
+
}
|
|
171
|
+
function rem(str) {
|
|
172
|
+
if (str.match(unitOnlyRE))
|
|
173
|
+
return `1${str}`;
|
|
174
|
+
const match = str.match(numberWithUnitRE);
|
|
175
|
+
if (!match)
|
|
176
|
+
return;
|
|
177
|
+
const [, n, unit] = match;
|
|
178
|
+
const num = parseFloat(n);
|
|
179
|
+
if (!Number.isNaN(num))
|
|
180
|
+
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
181
|
+
}
|
|
182
|
+
function px(str) {
|
|
183
|
+
if (str.match(unitOnlyRE))
|
|
184
|
+
return `1${str}`;
|
|
185
|
+
const match = str.match(numberWithUnitRE);
|
|
186
|
+
if (!match)
|
|
187
|
+
return;
|
|
188
|
+
const [, n, unit] = match;
|
|
189
|
+
const num = parseFloat(n);
|
|
190
|
+
if (!Number.isNaN(num))
|
|
191
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
192
|
+
}
|
|
193
|
+
function number(str) {
|
|
194
|
+
if (!numberRE.test(str))
|
|
195
|
+
return;
|
|
196
|
+
const num = parseFloat(str);
|
|
197
|
+
if (!Number.isNaN(num))
|
|
198
|
+
return round(num);
|
|
199
|
+
}
|
|
200
|
+
function percent(str) {
|
|
201
|
+
if (str.endsWith("%"))
|
|
202
|
+
str = str.slice(0, -1);
|
|
203
|
+
const num = parseFloat(str);
|
|
204
|
+
if (!Number.isNaN(num))
|
|
205
|
+
return `${round(num / 100)}`;
|
|
206
|
+
}
|
|
207
|
+
function fraction(str) {
|
|
208
|
+
if (str === "full")
|
|
209
|
+
return "100%";
|
|
210
|
+
const [left, right] = str.split("/");
|
|
211
|
+
const num = parseFloat(left) / parseFloat(right);
|
|
212
|
+
if (!Number.isNaN(num))
|
|
213
|
+
return `${round(num * 100)}%`;
|
|
214
|
+
}
|
|
215
|
+
const bracketTypeRe = /^\[(color|length|position):/i;
|
|
216
|
+
function bracketWithType(str, type) {
|
|
217
|
+
if (str && str.startsWith("[") && str.endsWith("]")) {
|
|
218
|
+
let base;
|
|
219
|
+
const match = str.match(bracketTypeRe);
|
|
220
|
+
if (!match)
|
|
221
|
+
base = str.slice(1, -1);
|
|
222
|
+
else if (type && match[1] === type)
|
|
223
|
+
base = str.slice(match[0].length, -1);
|
|
224
|
+
if (base !== void 0) {
|
|
225
|
+
return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/([^\\])_/g, "$1 ").replace(/calc\((.*)/g, (v) => {
|
|
226
|
+
return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function bracket(str) {
|
|
232
|
+
return bracketWithType(str);
|
|
233
|
+
}
|
|
234
|
+
function bracketOfColor(str) {
|
|
235
|
+
return bracketWithType(str, "color");
|
|
236
|
+
}
|
|
237
|
+
function bracketOfLength(str) {
|
|
238
|
+
return bracketWithType(str, "length");
|
|
239
|
+
}
|
|
240
|
+
function bracketOfPosition(str) {
|
|
241
|
+
return bracketWithType(str, "position");
|
|
242
|
+
}
|
|
243
|
+
function cssvar(str) {
|
|
244
|
+
if (str.match(/^\$\S/))
|
|
245
|
+
return `var(--${core.escapeSelector(str.slice(1))})`;
|
|
246
|
+
}
|
|
247
|
+
function time(str) {
|
|
248
|
+
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
249
|
+
if (!match)
|
|
250
|
+
return;
|
|
251
|
+
const [, n, unit] = match;
|
|
252
|
+
const num = parseFloat(n);
|
|
253
|
+
if (!Number.isNaN(num))
|
|
254
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
255
|
+
}
|
|
256
|
+
function degree(str) {
|
|
257
|
+
const match = str.match(/^(-?[0-9.]+)(deg|rad|grad|turn)?$/i);
|
|
258
|
+
if (!match)
|
|
259
|
+
return;
|
|
260
|
+
const [, n, unit] = match;
|
|
261
|
+
const num = parseFloat(n);
|
|
262
|
+
if (!Number.isNaN(num))
|
|
263
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
|
|
264
|
+
}
|
|
265
|
+
function global(str) {
|
|
266
|
+
if (globalKeywords.includes(str))
|
|
267
|
+
return str;
|
|
268
|
+
}
|
|
269
|
+
function properties(str) {
|
|
270
|
+
if (str.split(",").every((prop) => cssProps.includes(prop)))
|
|
271
|
+
return str;
|
|
272
|
+
}
|
|
273
|
+
function position(str) {
|
|
274
|
+
if (["top", "left", "right", "bottom", "center"].includes(str))
|
|
275
|
+
return str;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const valueHandlers = {
|
|
279
|
+
__proto__: null,
|
|
280
|
+
numberWithUnit: numberWithUnit,
|
|
281
|
+
auto: auto,
|
|
282
|
+
rem: rem,
|
|
283
|
+
px: px,
|
|
284
|
+
number: number,
|
|
285
|
+
percent: percent,
|
|
286
|
+
fraction: fraction,
|
|
287
|
+
bracket: bracket,
|
|
288
|
+
bracketOfColor: bracketOfColor,
|
|
289
|
+
bracketOfLength: bracketOfLength,
|
|
290
|
+
bracketOfPosition: bracketOfPosition,
|
|
291
|
+
cssvar: cssvar,
|
|
292
|
+
time: time,
|
|
293
|
+
degree: degree,
|
|
294
|
+
global: global,
|
|
295
|
+
properties: properties,
|
|
296
|
+
position: position
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
const handler = core.createValueHandler(valueHandlers);
|
|
300
|
+
const h = handler;
|
|
301
|
+
|
|
302
|
+
exports.cornerMap = cornerMap;
|
|
303
|
+
exports.directionMap = directionMap;
|
|
304
|
+
exports.globalKeywords = globalKeywords;
|
|
305
|
+
exports.h = h;
|
|
306
|
+
exports.handler = handler;
|
|
307
|
+
exports.insetMap = insetMap;
|
|
308
|
+
exports.positionMap = positionMap;
|
|
309
|
+
exports.valueHandlers = valueHandlers;
|
|
310
|
+
exports.xyzMap = xyzMap;
|